Changeset 88886 in webkit
- Timestamp:
- Jun 14, 2011 5:48:59 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r88880 r88886 1 2011-06-14 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Use new byte array encoding/decoding functions for WTF argument coders 6 https://bugs.webkit.org/show_bug.cgi?id=62682 7 8 * Platform/CoreIPC/ArgumentCoders.cpp: 9 (CoreIPC::::encode): 10 (CoreIPC::::decode): 11 Use the new functions for the string argument coders. 12 13 * Platform/CoreIPC/ArgumentCoders.h: 14 (CoreIPC::SimpleArgumentCoder::encode): 15 (CoreIPC::SimpleArgumentCoder::decode): 16 Use the new functions to avoid encoding/decoding the size when it's known at decode time. 17 18 * Platform/CoreIPC/ArgumentDecoder.cpp: 19 (CoreIPC::roundUpToAlignment): 20 Assert that the alignment is a power of 2. 21 22 (CoreIPC::decodeFixedLengthData): 23 Alignment comes before the size. 24 25 * UIProcess/cf/WebBackForwardListCF.cpp: 26 (WebKit::WebBackForwardList::createCFDictionaryRepresentation): 27 Add a FIXME about now using the internal CoreIPC encoding format here. 28 29 * UIProcess/cf/WebPageProxyCF.cpp: 30 Bump the current session state data version number. 31 1 32 2011-06-14 No'am Rosenthal <noam.rosenthal@nokia.com> 2 33 -
trunk/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp
r88846 r88886 57 57 uint32_t length = string.length(); 58 58 encoder->encode(length); 59 encoder->encode Bytes(reinterpret_cast<const uint8_t*>(string.data()), length);59 encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.data()), length, 1); 60 60 } 61 61 … … 80 80 char* buffer; 81 81 CString string = CString::newUninitialized(length, buffer); 82 if (!decoder->decode Bytes(reinterpret_cast<uint8_t*>(buffer), length))82 if (!decoder->decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length, 1)) 83 83 return false; 84 84 … … 98 98 uint32_t length = string.length(); 99 99 encoder->encode(length); 100 encoder->encode Bytes(reinterpret_cast<const uint8_t*>(string.characters()), length * sizeof(UChar));100 encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters()), length * sizeof(UChar), __alignof(UChar)); 101 101 } 102 102 … … 121 121 UChar* buffer; 122 122 String string = String::createUninitialized(length, buffer); 123 if (!decoder->decode Bytes(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar)))123 if (!decoder->decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar), __alignof(UChar))) 124 124 return false; 125 125 -
trunk/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h
r88846 r88886 41 41 static void encode(ArgumentEncoder* encoder, const T& t) 42 42 { 43 encoder->encode Bytes(reinterpret_cast<const uint8_t*>(&t), sizeof(T));43 encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(&t), sizeof(T), __alignof(T)); 44 44 } 45 45 46 static bool decode(ArgumentDecoder* decoder, T& t) 46 47 { 47 return decoder->decode Bytes(reinterpret_cast<uint8_t*>(&t), sizeof(T));48 return decoder->decodeFixedLengthData(reinterpret_cast<uint8_t*>(&t), sizeof(T), __alignof(T)); 48 49 } 49 50 }; … … 107 108 { 108 109 encoder->encodeUInt64(vector.size()); 109 // FIXME: If we could tell the encoder to align the buffer, we could just do an encodeBytes here. 110 for (size_t i = 0; i < vector.size(); ++i) 111 encoder->encode(vector[i]); 110 encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(vector.data()), vector.size(), __alignof(T)); 112 111 } 113 112 … … 126 125 } 127 126 128 Vector<T> t mp;129 t mp.reserveCapacity(size);127 Vector<T> temp; 128 temp.resize(size); 130 129 131 for (size_t i = 0; i < size; ++i) { 132 T element; 133 if (!decoder->decode(element)) 134 return false; 135 136 tmp.uncheckedAppend(element); 137 } 130 decoder->decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size, __alignof(T)); 138 131 139 vector.swap(t mp);132 vector.swap(temp); 140 133 return true; 141 134 } … … 143 136 144 137 template<typename T> struct ArgumentCoder<Vector<T> > : VectorArgumentCoder<WTF::IsArithmetic<T>::value, T> { }; 145 146 // Specialization for Vector<uint8_t>147 template<> struct ArgumentCoder<Vector<uint8_t> > {148 static void encode(ArgumentEncoder* encoder, const Vector<uint8_t>& vector)149 {150 encoder->encodeBytes(vector.data(), vector.size());151 }152 153 static bool decode(ArgumentDecoder* decoder, Vector<uint8_t>& vector)154 {155 return decoder->decodeBytes(vector);156 }157 };158 138 159 139 template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg> struct ArgumentCoder<HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> > { -
trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp
r88869 r88886 59 59 static inline uint8_t* roundUpToAlignment(uint8_t* ptr, unsigned alignment) 60 60 { 61 ASSERT(alignment); 61 // Assert that the alignment is a power of 2. 62 ASSERT(alignment && !(alignment & (alignment - 1))); 63 62 64 uintptr_t alignmentMask = alignment - 1; 63 65 return reinterpret_cast<uint8_t*>((reinterpret_cast<uintptr_t>(ptr) + alignmentMask) & ~alignmentMask); … … 105 107 bool ArgumentDecoder::decodeFixedLengthData(uint8_t* data, size_t size, unsigned alignment) 106 108 { 107 if (!alignBufferPosition( size, alignment))109 if (!alignBufferPosition(alignment, size)) 108 110 return false; 109 111 -
trunk/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
r85564 r88886 71 71 RetainPtr<CFStringRef> title(AdoptCF, m_entries[i]->title().createCFString()); 72 72 RetainPtr<CFStringRef> originalURL(AdoptCF, m_entries[i]->originalURL().createCFString()); 73 74 // FIXME: This uses the CoreIPC data encoding format, which means that whenever we change the CoreIPC encoding we need to bump the CurrentSessionStateDataVersion 75 // constant in WebPageProxyCF.cpp. The CoreIPC data format is meant to be an implementation detail, and not something that should be written to disk. 73 76 RetainPtr<CFDataRef> entryData(AdoptCF, CFDataCreate(kCFAllocatorDefault, m_entries[i]->backForwardData().data(), m_entries[i]->backForwardData().size())); 74 77 -
trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp
r84011 r88886 45 45 DEFINE_STATIC_GETTER(CFStringRef, ProvisionalURLKey, (CFSTR("ProvisionalURL"))); 46 46 47 static const UInt32 CurrentSessionStateDataVersion = 2;47 static const UInt32 CurrentSessionStateDataVersion = 3; 48 48 49 49 PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback filter, void* context) const
Note: See TracChangeset
for help on using the changeset viewer.