Changeset 66693 in webkit
- Timestamp:
- Sep 2, 2010 4:57:22 PM (14 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r66688 r66693 1 2010-09-02 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Anders Carlsson. 4 5 Add ability to send WKDictionaryRefs via post message. 6 https://bugs.webkit.org/show_bug.cgi?id=45151 7 8 * Shared/ImmutableDictionary.cpp: 9 (WebKit::ImmutableDictionary::ImmutableDictionary): 10 * Shared/ImmutableDictionary.h: 11 (WebKit::ImmutableDictionary::adopt): Remove tag, it wasn't doing anything. 12 (WebKit::ImmutableDictionary::isMutable): 13 (WebKit::ImmutableDictionary::map): Add accessor of internal 14 map for encoder. 15 16 * Shared/UserMessageCoders.h: 17 (WebKit::UserMessageEncoder::baseEncode): 18 (WebKit::UserMessageDecoder::baseDecode): 19 Add encoder/decoder. 20 1 21 2010-09-02 Sam Weinig <sam@webkit.org> 2 22 -
trunk/WebKit2/Shared/ImmutableDictionary.cpp
r66679 r66693 35 35 } 36 36 37 ImmutableDictionary::ImmutableDictionary(MapType& map , AdoptTag)37 ImmutableDictionary::ImmutableDictionary(MapType& map) 38 38 { 39 39 m_map.swap(map); -
trunk/WebKit2/Shared/ImmutableDictionary.h
r66676 r66693 51 51 static PassRefPtr<ImmutableDictionary> adopt(MapType& map) 52 52 { 53 return adoptRef(new ImmutableDictionary(map , Adopt));53 return adoptRef(new ImmutableDictionary(map)); 54 54 } 55 55 ~ImmutableDictionary(); 56 57 virtual bool isMutable() { return false; } 56 58 57 59 template<typename T> … … 77 79 size_t size() { return m_map.size(); } 78 80 79 virtual bool isMutable() { return false; }81 const MapType& map() { return m_map; } 80 82 81 83 protected: 82 84 ImmutableDictionary(); 83 enum AdoptTag { Adopt }; 84 ImmutableDictionary(MapType& map, AdoptTag); 85 ImmutableDictionary(MapType& map); 85 86 86 87 virtual Type type() const { return APIType; } -
trunk/WebKit2/Shared/UserMessageCoders.h
r66688 r66693 24 24 */ 25 25 26 #include "ArgumentDecoder.h" 26 27 #include "ArgumentEncoder.h" 27 #include "ArgumentDecoder.h"28 28 #include "ImmutableArray.h" 29 #include "ImmutableDictionary.h" 30 #include "WebCoreArgumentCoders.h" 29 31 #include "WebString.h" 30 32 … … 32 34 33 35 // - Array -> Array 36 // - Dictionary -> Dictionary 34 37 // - String -> String 35 38 … … 45 48 for (size_t i = 0; i < array->size(); ++i) 46 49 encoder->encode(Owner(array->at(i))); 50 return true; 51 } 52 case APIObject::TypeDictionary: { 53 ImmutableDictionary* dictionary = static_cast<ImmutableDictionary*>(m_root); 54 const ImmutableDictionary::MapType& map = dictionary->map(); 55 encoder->encode(static_cast<uint64_t>(map.size())); 56 57 ImmutableDictionary::MapType::const_iterator it = map.begin(); 58 ImmutableDictionary::MapType::const_iterator end = map.end(); 59 for (; it != end; ++it) { 60 encoder->encode(it->first); 61 encoder->encode(Owner(it->second.get())); 62 } 47 63 return true; 48 64 } … … 71 87 // Handles 72 88 // - Array -> Array 89 // - Dictionary -> Dictionary 73 90 // - String -> String 74 91 … … 94 111 95 112 coder.m_root = ImmutableArray::adopt(vector); 113 break; 114 } 115 case APIObject::TypeDictionary: { 116 uint64_t size; 117 if (!decoder->decode(size)) 118 return false; 119 120 ImmutableDictionary::MapType map; 121 for (size_t i = 0; i < size; ++i) { 122 String key; 123 if (!decoder->decode(key)) 124 return false; 125 126 RefPtr<APIObject> element; 127 Owner messageCoder(coder, element); 128 if (!decoder->decode(messageCoder)) 129 return false; 130 131 std::pair<ImmutableDictionary::MapType::iterator, bool> result = map.set(key, element.release()); 132 if (!result.second) 133 return false; 134 } 135 136 coder.m_root = ImmutableDictionary::adopt(map); 96 137 break; 97 138 }
Note: See TracChangeset
for help on using the changeset viewer.