void getURLBytes(CFURLRef url, URLCharBuffer& result)
{
    CFIndex bytesLength = CFURLGetBytes(url, 0, 0);
    result.resize(bytesLength);
    CFIndex finalLength = CFURLGetBytes(url, reinterpret_cast<UInt8*>(result.data()), bytesLength);
    ASSERT_UNUSED(finalLength, finalLength == bytesLength);
}
示例#2
0
RetainPtr<CFURLRef> URL::createCFURL() const
{
    // FIXME: What should this return for invalid URLs?
    // Currently it throws away the high bytes of the characters in the string in that case,
    // which is clearly wrong.
    URLCharBuffer buffer;
    copyToBuffer(buffer);
    return createCFURLFromBuffer(buffer.data(), buffer.size());
}
示例#3
0
void encode(ArgumentEncoder& encoder, CFURLRef url)
{
    CFURLRef baseURL = CFURLGetBaseURL(url);
    encoder << static_cast<bool>(baseURL);
    if (baseURL)
        encode(encoder, baseURL);

    URLCharBuffer urlBytes;
    getURLBytes(url, urlBytes);
    IPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(urlBytes.data()), urlBytes.size());
    encoder << dataReference;
}