Changeset 88886 in webkit


Ignore:
Timestamp:
Jun 14, 2011 5:48:59 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-06-14 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.

Use new byte array encoding/decoding functions for WTF argument coders
https://bugs.webkit.org/show_bug.cgi?id=62682

  • Platform/CoreIPC/ArgumentCoders.cpp: (CoreIPC::::encode): (CoreIPC::::decode): Use the new functions for the string argument coders.


  • Platform/CoreIPC/ArgumentCoders.h: (CoreIPC::SimpleArgumentCoder::encode): (CoreIPC::SimpleArgumentCoder::decode): Use the new functions to avoid encoding/decoding the size when it's known at decode time.
  • Platform/CoreIPC/ArgumentDecoder.cpp: (CoreIPC::roundUpToAlignment): Assert that the alignment is a power of 2.

(CoreIPC::decodeFixedLengthData):
Alignment comes before the size.

  • UIProcess/cf/WebBackForwardListCF.cpp: (WebKit::WebBackForwardList::createCFDictionaryRepresentation): Add a FIXME about now using the internal CoreIPC encoding format here.
  • UIProcess/cf/WebPageProxyCF.cpp: Bump the current session state data version number.
Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r88880 r88886  
     12011-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
    1322011-06-14  No'am Rosenthal  <noam.rosenthal@nokia.com>
    233
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.cpp

    r88846 r88886  
    5757    uint32_t length = string.length();
    5858    encoder->encode(length);
    59     encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string.data()), length);
     59    encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.data()), length, 1);
    6060}
    6161
     
    8080    char* buffer;
    8181    CString string = CString::newUninitialized(length, buffer);
    82     if (!decoder->decodeBytes(reinterpret_cast<uint8_t*>(buffer), length))
     82    if (!decoder->decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length, 1))
    8383        return false;
    8484
     
    9898    uint32_t length = string.length();
    9999    encoder->encode(length);
    100     encoder->encodeBytes(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));
    101101}
    102102
     
    121121    UChar* buffer;
    122122    String string = String::createUninitialized(length, buffer);
    123     if (!decoder->decodeBytes(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar)))
     123    if (!decoder->decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar), __alignof(UChar)))
    124124        return false;
    125125   
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentCoders.h

    r88846 r88886  
    4141    static void encode(ArgumentEncoder* encoder, const T& t)
    4242    {
    43         encoder->encodeBytes(reinterpret_cast<const uint8_t*>(&t), sizeof(T));
     43        encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(&t), sizeof(T), __alignof(T));
    4444    }
     45
    4546    static bool decode(ArgumentDecoder* decoder, T& t)
    4647    {
    47         return decoder->decodeBytes(reinterpret_cast<uint8_t*>(&t), sizeof(T));
     48        return decoder->decodeFixedLengthData(reinterpret_cast<uint8_t*>(&t), sizeof(T), __alignof(T));
    4849    }
    4950};
     
    107108    {
    108109        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));
    112111    }
    113112   
     
    126125        }
    127126
    128         Vector<T> tmp;
    129         tmp.reserveCapacity(size);
     127        Vector<T> temp;
     128        temp.resize(size);
    130129
    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));
    138131
    139         vector.swap(tmp);
     132        vector.swap(temp);
    140133        return true;
    141134    }
     
    143136
    144137template<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 };
    158138
    159139template<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  
    5959static inline uint8_t* roundUpToAlignment(uint8_t* ptr, unsigned alignment)
    6060{
    61     ASSERT(alignment);
     61    // Assert that the alignment is a power of 2.
     62    ASSERT(alignment && !(alignment & (alignment - 1)));
     63
    6264    uintptr_t alignmentMask = alignment - 1;
    6365    return reinterpret_cast<uint8_t*>((reinterpret_cast<uintptr_t>(ptr) + alignmentMask) & ~alignmentMask);
     
    105107bool ArgumentDecoder::decodeFixedLengthData(uint8_t* data, size_t size, unsigned alignment)
    106108{
    107     if (!alignBufferPosition(size, alignment))
     109    if (!alignBufferPosition(alignment, size))
    108110        return false;
    109111
  • trunk/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp

    r85564 r88886  
    7171        RetainPtr<CFStringRef> title(AdoptCF, m_entries[i]->title().createCFString());
    7272        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.
    7376        RetainPtr<CFDataRef> entryData(AdoptCF, CFDataCreate(kCFAllocatorDefault, m_entries[i]->backForwardData().data(), m_entries[i]->backForwardData().size()));
    7477       
  • trunk/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp

    r84011 r88886  
    4545DEFINE_STATIC_GETTER(CFStringRef, ProvisionalURLKey, (CFSTR("ProvisionalURL")));
    4646
    47 static const UInt32 CurrentSessionStateDataVersion = 2;
     47static const UInt32 CurrentSessionStateDataVersion = 3;
    4848
    4949PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback filter, void* context) const
Note: See TracChangeset for help on using the changeset viewer.