diff options
author | 2014-06-27 10:37:27 -0700 | |
---|---|---|
committer | 2014-06-27 10:37:27 -0700 | |
commit | 1f8ed022226c9f960b9fc95af9297d5111a07ead (patch) | |
tree | f87515d7c897addf9e90c1df29a5669b4f086fb0 /src/pdf/SkPDFTypes.h | |
parent | e5c1e3cd63e22bb06c24dd051f4d814f24786c08 (diff) |
Add lock to SkPDFDict
Add mutex lock to all functions. Remove dictionary iterator, and
replace with new thread-safe functions.
BUG=skia:2683
R=mtklein@google.com, djsollen@google.com
Author: halcanary@google.com
Review URL: https://codereview.chromium.org/360473005
Diffstat (limited to 'src/pdf/SkPDFTypes.h')
-rw-r--r-- | src/pdf/SkPDFTypes.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h index 1f06c4c5fe..004c767843 100644 --- a/src/pdf/SkPDFTypes.h +++ b/src/pdf/SkPDFTypes.h @@ -369,7 +369,7 @@ public: /** The size of the dictionary. */ - int size() { return fValue.count(); } + int size() const; /** Add the value to the dictionary with the given key. Refs value. * @param key The key for this dictionary entry. @@ -424,28 +424,30 @@ public: */ void clear(); +protected: + /** Use to remove a single key from the dictionary. + */ + void remove(const char key[]); + + /** Insert references to all of the key-value pairs from the other + * dictionary into this one. + */ + void mergeFrom(const SkPDFDict& other); + private: struct Rec { - SkPDFName* key; - SkPDFObject* value; + SkPDFName* key; + SkPDFObject* value; + Rec(SkPDFName* k, SkPDFObject* v) : key(k), value(v) {} }; -public: - class Iter { - public: - explicit Iter(const SkPDFDict& dict); - SkPDFName* next(SkPDFObject** value); - - private: - const Rec* fIter; - const Rec* fStop; - }; - -private: static const int kMaxLen = 4095; + mutable SkMutex fMutex; // protects modifications to fValue SkTDArray<struct Rec> fValue; + SkPDFObject* append(SkPDFName* key, SkPDFObject* value); + typedef SkPDFObject INHERITED; }; |