Changeset 230203 in webkit


Ignore:
Timestamp:
Apr 3, 2018 8:09:10 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:

[SOUP] Stop using ResourceHandle to load GResources
https://bugs.webkit.org/show_bug.cgi?id=184259

Reviewed by Sergio Villar Senin.

GResources are loaded in the WebProcess using ResourceHandle because soup handles them transparently. But now
that we no longer use ResourceHandle, we can add a simple loader for GResources, similar to the one used for
data URLS, since loading a GResource is a matter of calling g_resources_lookup_data() in the end.

  • SourcesGTK.txt:
  • SourcesWPE.txt:
  • loader/ResourceLoader.cpp:

(WebCore::ResourceLoader::start): Check if resource to load is a GResource and call loadGResource().

  • loader/ResourceLoader.h:
  • loader/soup/ResourceLoaderSoup.cpp: Added.

(WebCore::ResourceLoader::loadGResource): Load the GResource in a GTask thread.

  • platform/SharedBuffer.cpp:

(WebCore::SharedBuffer::DataSegment::data const):
(WebCore::SharedBuffer::DataSegment::size const):

  • platform/SharedBuffer.h:
  • platform/glib/SharedBufferGlib.cpp:

(WebCore::SharedBuffer::SharedBuffer):
(WebCore::SharedBuffer::create):

Location:
trunk/Source/WebCore
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r230198 r230203  
     12018-04-03  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [SOUP] Stop using ResourceHandle to load GResources
     4        https://bugs.webkit.org/show_bug.cgi?id=184259
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        GResources are loaded in the WebProcess using ResourceHandle because soup handles them transparently. But now
     9        that we no longer use ResourceHandle, we can add a simple loader for GResources, similar to the one used for
     10        data URLS, since loading a GResource is a matter of calling g_resources_lookup_data() in the end.
     11
     12        * SourcesGTK.txt:
     13        * SourcesWPE.txt:
     14        * loader/ResourceLoader.cpp:
     15        (WebCore::ResourceLoader::start): Check if resource to load is a GResource and call loadGResource().
     16        * loader/ResourceLoader.h:
     17        * loader/soup/ResourceLoaderSoup.cpp: Added.
     18        (WebCore::ResourceLoader::loadGResource): Load the GResource in a GTask thread.
     19        * platform/SharedBuffer.cpp:
     20        (WebCore::SharedBuffer::DataSegment::data const):
     21        (WebCore::SharedBuffer::DataSegment::size const):
     22        * platform/SharedBuffer.h:
     23        * platform/glib/SharedBufferGlib.cpp:
     24        (WebCore::SharedBuffer::SharedBuffer):
     25        (WebCore::SharedBuffer::create):
     26
    1272018-04-02  Carlos Garcia Campos  <cgarcia@igalia.com>
    228
  • trunk/Source/WebCore/SourcesGTK.txt

    r230152 r230203  
    4141
    4242editing/atk/FrameSelectionAtk.cpp
     43
     44loader/soup/ResourceLoaderSoup.cpp
    4345
    4446page/linux/ResourceUsageOverlayLinux.cpp
  • trunk/Source/WebCore/SourcesWPE.txt

    r229169 r230203  
    2626
    2727editing/wpe/EditorWPE.cpp
     28
     29loader/soup/ResourceLoaderSoup.cpp
    2830
    2931page/linux/ResourceUsageOverlayLinux.cpp
  • trunk/Source/WebCore/loader/ResourceLoader.cpp

    r229959 r230203  
    214214    }
    215215
     216#if USE(SOUP)
     217    if (m_request.url().protocolIs("resource")) {
     218        loadGResource();
     219        return;
     220    }
     221#endif
     222
    216223    m_handle = ResourceHandle::create(frameLoader()->networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent == SniffContent, m_options.sniffContentEncoding == ContentEncodingSniffingPolicy::Sniff);
    217224}
  • trunk/Source/WebCore/loader/ResourceLoader.h

    r229977 r230203  
    211211#endif
    212212
     213#if USE(SOUP)
     214    void loadGResource();
     215#endif
     216
    213217    ResourceRequest m_request;
    214218    ResourceRequest m_originalRequest; // Before redirects.
  • trunk/Source/WebCore/platform/SharedBuffer.cpp

    r225618 r230203  
    3232#include <wtf/unicode/UTF8.h>
    3333
    34 #if USE(SOUP)
    35 #include "GUniquePtrSoup.h"
    36 #endif
    37 
    3834namespace WebCore {
    3935
     
    213209        [](const GUniquePtr<SoupBuffer>& data) { return data->data; },
    214210#endif
     211#if USE(GLIB)
     212        [](const GRefPtr<GBytes>& data) { return reinterpret_cast<const char*>(g_bytes_get_data(data.get(), nullptr)); },
     213#endif
    215214        [](const FileSystem::MappedFileData& data) { return reinterpret_cast<const char*>(data.data()); }
    216215    );
     
    233232#if USE(SOUP)
    234233        [](const GUniquePtr<SoupBuffer>& data) { return static_cast<size_t>(data->length); },
     234#endif
     235#if USE(GLIB)
     236        [](const GRefPtr<GBytes>& data) { return g_bytes_get_size(data.get()); },
    235237#endif
    236238        [](const FileSystem::MappedFileData& data) { return data.size(); }
  • trunk/Source/WebCore/platform/SharedBuffer.h

    r229776 r230203  
    4444#endif
    4545
     46#if USE(GLIB)
     47#include <wtf/glib/GRefPtr.h>
     48typedef struct _GBytes GBytes;
     49#endif
     50
    4651#if USE(FOUNDATION)
    4752OBJC_CLASS NSArray;
     
    8085#endif
    8186
     87#if USE(GLIB)
     88    static Ref<SharedBuffer> create(GBytes*);
     89#endif
     90
    8291    // Calling data() causes all the data segments to be copied into one segment if they are not already.
    8392    // Iterate the segments using begin() and end() instead.
     
    115124        static Ref<DataSegment> create(GUniquePtr<SoupBuffer>&& data) { return adoptRef(*new DataSegment(WTFMove(data))); }
    116125#endif
     126#if USE(GLIB)
     127        static Ref<DataSegment> create(GRefPtr<GBytes>&& data) { return adoptRef(*new DataSegment(WTFMove(data))); }
     128#endif
    117129        static Ref<DataSegment> create(FileSystem::MappedFileData&& data) { return adoptRef(*new DataSegment(WTFMove(data))); }
    118130
     
    128140            : m_immutableData(WTFMove(data)) { }
    129141#endif
     142#if USE(GLIB)
     143        DataSegment(GRefPtr<GBytes>&& data)
     144            : m_immutableData(WTFMove(data)) { }
     145#endif
    130146        DataSegment(FileSystem::MappedFileData&& data)
    131147            : m_immutableData(WTFMove(data)) { }
     
    137153#if USE(SOUP)
    138154            GUniquePtr<SoupBuffer>,
     155#endif
     156#if USE(GLIB)
     157            GRefPtr<GBytes>,
    139158#endif
    140159            FileSystem::MappedFileData> m_immutableData;
     
    167186    explicit SharedBuffer(SoupBuffer*);
    168187#endif
     188#if USE(GLIB)
     189    explicit SharedBuffer(GBytes*);
     190#endif
    169191
    170192    void combineIntoOneSegment() const;
  • trunk/Source/WebCore/platform/glib/SharedBufferGlib.cpp

    r224371 r230203  
    2626#include <glib.h>
    2727
     28namespace WebCore {
    2829
    29 namespace WebCore {
     30SharedBuffer::SharedBuffer(GBytes* bytes)
     31{
     32    ASSERT(bytes);
     33    m_size = g_bytes_get_size(bytes);
     34    m_segments.append({ 0, DataSegment::create(GRefPtr<GBytes>(bytes)) });
     35}
     36
     37Ref<SharedBuffer> SharedBuffer::create(GBytes* bytes)
     38{
     39    return adoptRef(*new SharedBuffer(bytes));
     40}
    3041
    3142RefPtr<SharedBuffer> SharedBuffer::createFromReadingFile(const String& filePath)
Note: See TracChangeset for help on using the changeset viewer.