Commit f8d43691 authored by japhet@chromium.org's avatar japhet@chromium.org

2010-12-10 Nate Chapin <japhet@chromium.org>

        Reviewed by Antti Koivisto.

        Merge Loader and Request. Currently, Loader is a singleton attached
        to MemoryCache. Our goal is to remove knowledge of the loading process
        from MemoryCache, so we should attach Loader to CachedResourceLoader instead.
        Once Loader is moved off of MemoryCache, there's no reason it needs to be a singleton,
        which removes the main reason for Request existing as a separate class (to store per-request
        state that Loader couldn't).

        Loader will be given a more descriptive name in a later patch.

        https://bugs.webkit.org/show_bug.cgi?id=49837

        Refactor only, no new tests.

        * Android.mk:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * loader/FrameLoader.cpp:
        * loader/Request.cpp:
        * loader/Request.h:
        * loader/cache/CachedFont.cpp:
        * loader/cache/CachedImage.cpp:
        * loader/cache/CachedResource.cpp:
        * loader/cache/CachedResource.h:
        * loader/cache/CachedResourceLoader.cpp:
        (WebCore::CachedResourceLoader::CachedResourceLoader):
        (WebCore::CachedResourceLoader::~CachedResourceLoader):
        (WebCore::CachedResourceLoader::requestImage):
        (WebCore::CachedResourceLoader::setAutoLoadImages):
        (WebCore::CachedResourceLoader::load):
        (WebCore::CachedResourceLoader::loadDone): Was setLoadInProgress(false),
            plus other CachedResourceLoader cleanup that had been handled in Loader.
        (WebCore::CachedResourceLoader::cancelRequests): Moved from Loader.
        (WebCore::CachedResourceLoader::requestCount):
        * loader/cache/CachedResourceLoader.h:
        (WebCore::CachedResourceLoader::loadFinishing): Was setLoadInProgress(true)
        * loader/cache/MemoryCache.h:
        * loader/loader.cpp:
        (WebCore::Loader::Loader):
        (WebCore::Loader::~Loader):
        (WebCore::Loader::load):
        (WebCore::Loader::willSendRequest):
        (WebCore::Loader::didFinishLoading):
        (WebCore::Loader::didFail):
        (WebCore::Loader::didReceiveResponse):
        (WebCore::Loader::didReceiveData):
        (WebCore::Loader::didReceiveCachedMetadata):
        * loader/loader.h:
        (WebCore::Loader::cachedResourceLoader):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73749 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 044b6030
......@@ -372,7 +372,6 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
loader/PolicyChecker.cpp \
loader/ProgressTracker.cpp \
loader/NavigationScheduler.cpp \
loader/Request.cpp \
loader/ResourceLoadNotifier.cpp \
loader/ResourceLoader.cpp \
loader/SubframeLoader.cpp \
......
......@@ -1189,7 +1189,6 @@ SET(WebCore_SOURCES
loader/PolicyChecker.cpp
loader/ProgressTracker.cpp
loader/NavigationScheduler.cpp
loader/Request.cpp
loader/ResourceLoadNotifier.cpp
loader/ResourceLoadScheduler.cpp
loader/ResourceLoader.cpp
......
2010-12-10 Nate Chapin <japhet@chromium.org>
Reviewed by Antti Koivisto.
Merge Loader and Request. Currently, Loader is a singleton attached
to MemoryCache. Our goal is to remove knowledge of the loading process
from MemoryCache, so we should attach Loader to CachedResourceLoader instead.
Once Loader is moved off of MemoryCache, there's no reason it needs to be a singleton,
which removes the main reason for Request existing as a separate class (to store per-request
state that Loader couldn't).
Loader will be given a more descriptive name in a later patch.
https://bugs.webkit.org/show_bug.cgi?id=49837
Refactor only, no new tests.
* Android.mk:
* CMakeLists.txt:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* loader/FrameLoader.cpp:
* loader/Request.cpp:
* loader/Request.h:
* loader/cache/CachedFont.cpp:
* loader/cache/CachedImage.cpp:
* loader/cache/CachedResource.cpp:
* loader/cache/CachedResource.h:
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::CachedResourceLoader):
(WebCore::CachedResourceLoader::~CachedResourceLoader):
(WebCore::CachedResourceLoader::requestImage):
(WebCore::CachedResourceLoader::setAutoLoadImages):
(WebCore::CachedResourceLoader::load):
(WebCore::CachedResourceLoader::loadDone): Was setLoadInProgress(false),
plus other CachedResourceLoader cleanup that had been handled in Loader.
(WebCore::CachedResourceLoader::cancelRequests): Moved from Loader.
(WebCore::CachedResourceLoader::requestCount):
* loader/cache/CachedResourceLoader.h:
(WebCore::CachedResourceLoader::loadFinishing): Was setLoadInProgress(true)
* loader/cache/MemoryCache.h:
* loader/loader.cpp:
(WebCore::Loader::Loader):
(WebCore::Loader::~Loader):
(WebCore::Loader::load):
(WebCore::Loader::willSendRequest):
(WebCore::Loader::didFinishLoading):
(WebCore::Loader::didFail):
(WebCore::Loader::didReceiveResponse):
(WebCore::Loader::didReceiveData):
(WebCore::Loader::didReceiveCachedMetadata):
* loader/loader.h:
(WebCore::Loader::cachedResourceLoader):
2010-12-10 Martin Robinson <mrobinson@igalia.com>
Unreviewed, rolling out r73703.
......
......@@ -2076,8 +2076,6 @@ webcore_sources += \
WebCore/loader/ProgressTracker.h \
WebCore/loader/NavigationScheduler.cpp \
WebCore/loader/NavigationScheduler.h \
WebCore/loader/Request.cpp \
WebCore/loader/Request.h \
WebCore/loader/ResourceLoader.cpp \
WebCore/loader/ResourceLoader.h \
WebCore/loader/ResourceLoadNotifier.cpp \
......
......@@ -2148,8 +2148,6 @@
'loader/ProgressTracker.h',
'loader/NavigationScheduler.cpp',
'loader/NavigationScheduler.h',
'loader/Request.cpp',
'loader/Request.h',
'loader/ResourceLoader.cpp',
'loader/ResourceLoader.h',
'loader/ResourceLoadNotifier.cpp',
......
......@@ -1082,7 +1082,6 @@ SOURCES += \
loader/PolicyChecker.cpp \
loader/ProgressTracker.cpp \
loader/NavigationScheduler.cpp \
loader/Request.cpp \
loader/ResourceLoader.cpp \
loader/ResourceLoadNotifier.cpp \
loader/ResourceLoadScheduler.cpp \
......
......@@ -24925,13 +24925,6 @@
RelativePath="..\loader\ProgressTracker.h"
>
</File>
<File
RelativePath="..\loader\Request.cpp"
>
</File>
<File
RelativePath="..\loader\Request.h"
>
</File>
<File
RelativePath="..\loader\ResourceLoader.cpp"
......@@ -5062,8 +5062,6 @@
BCB16C2A0979C3BD00467741 /* CachedResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16C110979C3BD00467741 /* CachedResourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCB16C2C0979C3BD00467741 /* loader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16C130979C3BD00467741 /* loader.cpp */; };
BCB16C2D0979C3BD00467741 /* loader.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16C140979C3BD00467741 /* loader.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCB16C2E0979C3BD00467741 /* Request.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16C150979C3BD00467741 /* Request.cpp */; };
BCB16C2F0979C3BD00467741 /* Request.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16C160979C3BD00467741 /* Request.h */; };
BCB773610C17853D00132BA4 /* JSNodeFilterCondition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB7735E0C17853D00132BA4 /* JSNodeFilterCondition.cpp */; };
BCB773620C17853D00132BA4 /* JSNodeFilterCondition.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */; };
BCB773630C17853D00132BA4 /* JSNodeFilterCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */; };
......@@ -11309,8 +11307,6 @@
BCB16C110979C3BD00467741 /* CachedResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CachedResourceLoader.h; sourceTree = "<group>"; };
BCB16C130979C3BD00467741 /* loader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = loader.cpp; sourceTree = "<group>"; };
BCB16C140979C3BD00467741 /* loader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = loader.h; sourceTree = "<group>"; };
BCB16C150979C3BD00467741 /* Request.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Request.cpp; sourceTree = "<group>"; };
BCB16C160979C3BD00467741 /* Request.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Request.h; sourceTree = "<group>"; };
BCB7735E0C17853D00132BA4 /* JSNodeFilterCondition.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCondition.cpp; sourceTree = "<group>"; };
BCB7735F0C17853D00132BA4 /* JSNodeFilterCondition.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSNodeFilterCondition.h; sourceTree = "<group>"; };
BCB773600C17853D00132BA4 /* JSNodeFilterCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeFilterCustom.cpp; sourceTree = "<group>"; };
......@@ -17838,8 +17834,6 @@
97059976107D975200A50A7C /* PolicyChecker.h */,
1A2A68210B5BEDE70002A480 /* ProgressTracker.cpp */,
1A2A68220B5BEDE70002A480 /* ProgressTracker.h */,
BCB16C150979C3BD00467741 /* Request.cpp */,
BCB16C160979C3BD00467741 /* Request.h */,
93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */,
656D37270ADBA5DE00A4554D /* ResourceLoader.h */,
973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */,
......@@ -21445,7 +21439,6 @@
93799EF90BF2743600D0F230 /* RenderWordBreak.h in Headers */,
A89CCC530F44E98100B5DA10 /* ReplaceNodeWithSpanCommand.h in Headers */,
93309E0A099E64920056E581 /* ReplaceSelectionCommand.h in Headers */,
BCB16C2F0979C3BD00467741 /* Request.h in Headers */,
F55B3DD01251F12D003EF269 /* ResetInputType.h in Headers */,
934F71420D5A6F4400018D69 /* ResourceError.h in Headers */,
934F713C0D5A6F1900018D69 /* ResourceErrorBase.h in Headers */,
......@@ -24217,7 +24210,6 @@
93799EF80BF2743600D0F230 /* RenderWordBreak.cpp in Sources */,
A89CCC520F44E98100B5DA10 /* ReplaceNodeWithSpanCommand.cpp in Sources */,
93309E09099E64920056E581 /* ReplaceSelectionCommand.cpp in Sources */,
BCB16C2E0979C3BD00467741 /* Request.cpp in Sources */,
F55B3DCF1251F12D003EF269 /* ResetInputType.cpp in Sources */,
934F713E0D5A6F2800018D69 /* ResourceErrorBase.cpp in Sources */,
514C76500CE9234E007EF3CD /* ResourceErrorMac.mm in Sources */,
......@@ -429,7 +429,7 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy, DatabasePolic
doc->setReadyState(Document::Complete);
if (CachedResourceLoader* cachedResourceLoader = doc->cachedResourceLoader())
cache()->loader()->cancelRequests(cachedResourceLoader);
cachedResourceLoader->cancelRequests();
#if ENABLE(DATABASE)
if (databasePolicy == DatabasePolicyStop)
......
/*
Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "Request.h"
#include "CachedResource.h"
namespace WebCore {
Request::Request(CachedResourceLoader* cachedResourceLoader, CachedResource* object, bool incremental, SecurityCheckPolicy shouldDoSecurityCheck, bool sendResourceLoadCallbacks)
: m_object(object)
, m_cachedResourceLoader(cachedResourceLoader)
, m_incremental(incremental)
, m_multipart(false)
, m_shouldDoSecurityCheck(shouldDoSecurityCheck)
, m_sendResourceLoadCallbacks(sendResourceLoadCallbacks)
{
m_object->setRequest(this);
}
Request::~Request()
{
m_object->setRequest(0);
}
} //namespace WebCore
/*
Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef Request_h
#define Request_h
#include "FrameLoaderTypes.h"
#include <wtf/Vector.h>
namespace WebCore {
class CachedResource;
class CachedResourceLoader;
class Request : public Noncopyable {
public:
Request(CachedResourceLoader*, CachedResource*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks);
~Request();
CachedResource* cachedResource() const { return m_object; }
CachedResourceLoader* cachedResourceLoader() const { return m_cachedResourceLoader; }
bool isIncremental() const { return m_incremental; }
void setIsIncremental(bool b = true) { m_incremental = b; }
bool isMultipart() const { return m_multipart; }
void setIsMultipart(bool b = true) { m_multipart = b; }
SecurityCheckPolicy shouldDoSecurityCheck() const { return m_shouldDoSecurityCheck; }
bool sendResourceLoadCallbacks() const { return m_sendResourceLoadCallbacks; }
private:
CachedResource* m_object;
CachedResourceLoader* m_cachedResourceLoader;
bool m_incremental;
bool m_multipart;
SecurityCheckPolicy m_shouldDoSecurityCheck;
bool m_sendResourceLoadCallbacks;
};
} //namespace WebCore
#endif // Request_h
......@@ -33,6 +33,7 @@
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "CachedResourceLoader.h"
#include "FontPlatformData.h"
#include "MemoryCache.h"
#include "SharedBuffer.h"
......@@ -98,7 +99,7 @@ void CachedFont::beginLoadIfNeeded(CachedResourceLoader* dl)
{
if (!m_loadInitiated) {
m_loadInitiated = true;
cache()->loader()->load(dl, this, false);
dl->load(this, false);
}
}
......
......@@ -32,7 +32,6 @@
#include "Frame.h"
#include "FrameLoaderTypes.h"
#include "FrameView.h"
#include "Request.h"
#include "Settings.h"
#include "SharedBuffer.h"
#include <wtf/CurrentTime.h>
......
......@@ -35,9 +35,9 @@
#include "KURL.h"
#include "Logging.h"
#include "PurgeableBuffer.h"
#include "Request.h"
#include "ResourceHandle.h"
#include "SharedBuffer.h"
#include "loader.h"
#include <wtf/CurrentTime.h>
#include <wtf/MathExtras.h>
#include <wtf/RefCountedLeakCounter.h>
......@@ -106,7 +106,7 @@ CachedResource::~CachedResource()
void CachedResource::load(CachedResourceLoader* cachedResourceLoader, bool incremental, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks)
{
m_sendResourceLoadCallbacks = sendResourceLoadCallbacks;
cache()->loader()->load(cachedResourceLoader, this, incremental, securityCheck, sendResourceLoadCallbacks);
cachedResourceLoader->load(this, incremental, securityCheck, sendResourceLoadCallbacks);
m_loading = true;
}
......@@ -202,7 +202,7 @@ CachedMetadata* CachedResource::cachedMetadata(unsigned dataTypeID) const
return m_cachedMetadata.get();
}
void CachedResource::setRequest(Request* request)
void CachedResource::setRequest(Loader* request)
{
if (request && !m_request)
m_status = Pending;
......
......@@ -43,8 +43,8 @@ class CachedResourceHandleBase;
class CachedResourceLoader;
class Frame;
class InspectorResource;
class Loader;
class PurgeableBuffer;
class Request;
// A resource that is held in the cache. Classes who want to use this object should derive
// from CachedResourceClient, to get the function calls in case the requested data has arrived.
......@@ -150,7 +150,7 @@ public:
void setInLiveDecodedResourcesList(bool b) { m_inLiveDecodedResourcesList = b; }
bool inLiveDecodedResourcesList() { return m_inLiveDecodedResourcesList; }
void setRequest(Request*);
void setRequest(Loader*);
SharedBuffer* data() const { ASSERT(!m_purgeableData); return m_data.get(); }
......@@ -216,7 +216,7 @@ protected:
String m_url;
String m_accept;
Request* m_request;
Loader* m_request;
ResourceResponse m_response;
double m_responseTimestamp;
......
......@@ -55,7 +55,7 @@ CachedResourceLoader::CachedResourceLoader(Document* document)
, m_document(document)
, m_requestCount(0)
, m_autoLoadImages(true)
, m_loadInProgress(false)
, m_loadFinishing(false)
, m_allowStaleResources(false)
{
m_cache->addCachedResourceLoader(this);
......@@ -63,9 +63,7 @@ CachedResourceLoader::CachedResourceLoader(Document* document)
CachedResourceLoader::~CachedResourceLoader()
{
if (m_requestCount)
m_cache->loader()->cancelRequests(this);
cancelRequests();
clearPreloads();
DocumentResourceMap::iterator end = m_documentResources.end();
for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != end; ++it)
......@@ -137,7 +135,7 @@ CachedImage* CachedResourceLoader::requestImage(const String& url)
CachedImage* resource = static_cast<CachedImage*>(requestResource(CachedResource::ImageResource, url, String()));
if (autoLoadImages() && resource && resource->stillNeedsLoad()) {
resource->setLoading(true);
cache()->loader()->load(this, resource, true);
load(resource, true);
}
return resource;
}
......@@ -314,7 +312,7 @@ void CachedResourceLoader::setAutoLoadImages(bool enable)
CachedImage* image = const_cast<CachedImage*>(static_cast<const CachedImage*>(resource));
if (image->stillNeedsLoad())
cache()->loader()->load(this, image, true);
load(image, true);
}
}
}
......@@ -334,11 +332,36 @@ void CachedResourceLoader::removeCachedResource(CachedResource* resource) const
m_documentResources.remove(resource->url());
}
void CachedResourceLoader::setLoadInProgress(bool load)
void CachedResourceLoader::load(CachedResource* resource, bool incremental, SecurityCheckPolicy securityCheck, bool sendResourceLoadCallbacks)
{
incrementRequestCount(resource);
RefPtr<Loader> request = Loader::load(this, resource, incremental, securityCheck, sendResourceLoadCallbacks);
if (request)
m_requests.add(request);
}
void CachedResourceLoader::loadDone(Loader* request)
{
m_loadInProgress = load;
if (!load && frame())
m_loadFinishing = false;
RefPtr<Loader> protect(request);
if (request)
m_requests.remove(request);
if (frame())
frame()->loader()->loadDone();
checkForPendingPreloads();
}
void CachedResourceLoader::cancelRequests()
{
clearPendingPreloads();
Vector<Loader*, 256> requestsToCancel;
RequestSet::iterator end = m_requests.end();
for (RequestSet::iterator i = m_requests.begin(); i != end; ++i)
requestsToCancel.append((*i).get());
for (unsigned i = 0; i < requestsToCancel.size(); ++i)
requestsToCancel[i]->didFail(true);
}
void CachedResourceLoader::checkCacheObjectStatus(CachedResource* resource)
......@@ -370,7 +393,7 @@ void CachedResourceLoader::decrementRequestCount(const CachedResource* res)
int CachedResourceLoader::requestCount()
{
if (loadInProgress())
if (m_loadFinishing)
return m_requestCount + 1;
return m_requestCount;
}
......
......@@ -29,6 +29,7 @@
#include "CachedResource.h"
#include "CachedResourceHandle.h"
#include "CachePolicy.h"
#include "loader.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/ListHashSet.h>
......@@ -86,8 +87,10 @@ public:
void removeCachedResource(CachedResource*) const;
void setLoadInProgress(bool);
bool loadInProgress() const { return m_loadInProgress; }
void load(CachedResource*, bool incremental = false, SecurityCheckPolicy = DoSecurityCheck, bool sendResourceLoadCallbacks = true);
void loadFinishing() { m_loadFinishing = true; }
void loadDone(Loader*);
void cancelRequests();
void setAllowStaleResources(bool allowStaleResources) { m_allowStaleResources = allowStaleResources; }
......@@ -113,6 +116,9 @@ private:
HashSet<String> m_reloadedURLs;
mutable DocumentResourceMap m_documentResources;
Document* m_document;
typedef HashSet<RefPtr<Loader> > RequestSet;
RequestSet m_requests;
int m_requestCount;
......@@ -126,7 +132,7 @@ private:
//29 bits left
bool m_autoLoadImages : 1;
bool m_loadInProgress : 1;
bool m_loadFinishing : 1;
bool m_allowStaleResources : 1;
};
......
......@@ -28,7 +28,6 @@
#include "CachePolicy.h"
#include "CachedResource.h"
#include "PlatformString.h"
#include "loader.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
......@@ -104,9 +103,6 @@ public:
TypeStatistic fonts;
};
// The loader that fetches resources.
Loader* loader() { return &m_loader; }
// Request resources from the cache. A load will be initiated and a cache object created if the object is not
// found in the cache.
CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false, bool forHistory = false);
......@@ -191,7 +187,6 @@ private:
// Member variables.
HashSet<CachedResourceLoader*> m_cachedResourceLoaders;
Loader m_loader;
bool m_disabled; // Whether or not the cache is enabled.
bool m_pruneEnabled;
......
This diff is collapsed.
......@@ -35,24 +35,29 @@ namespace WebCore {
class CachedResourceLoader;
class Request;
class Loader : public Noncopyable, private SubresourceLoaderClient {
class Loader : public RefCounted<Loader>, private SubresourceLoaderClient {
public:
static PassRefPtr<Loader> load(CachedResourceLoader*, CachedResource*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks);\
~Loader();
void didFail(bool cancelled = false);
void load(CachedResourceLoader*, CachedResource*, bool incremental = true, SecurityCheckPolicy = DoSecurityCheck, bool sendResourceLoadCallbacks = true);
void cancelRequests(CachedResourceLoader*);
CachedResourceLoader* cachedResourceLoader() const { return m_cachedResourceLoader; }
private:
Loader(CachedResourceLoader*, CachedResource*, bool incremental);
virtual void willSendRequest(SubresourceLoader*, ResourceRequest&, const ResourceResponse&);
virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
virtual void didReceiveData(SubresourceLoader*, const char*, int);
virtual void didReceiveCachedMetadata(SubresourceLoader*, const char*, int);
virtual void didFinishLoading(SubresourceLoader*);
virtual void didFail(SubresourceLoader*, const ResourceError&);
void didFail(SubresourceLoader*, bool cancelled = false);
typedef HashMap<RefPtr<SubresourceLoader>, Request*> RequestMap;
RequestMap m_requestsLoading;
RefPtr<SubresourceLoader> m_loader;
CachedResourceLoader* m_cachedResourceLoader;
CachedResource* m_resource;
bool m_incremental;
bool m_multipart;
bool m_finishing;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment