diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 07:42:51 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 07:42:51 +0000 |
commit | 3cae153ece09c094253080735d5fdf4d42299d8c (patch) | |
tree | e77dbe6c5959982d7aef1ab6ac65d4c5ccdac8fd /webkit | |
parent | 4f17e3ba905f08c359ef9c50cc08ef36735af865 (diff) | |
download | chromium_src-3cae153ece09c094253080735d5fdf4d42299d8c.zip chromium_src-3cae153ece09c094253080735d5fdf4d42299d8c.tar.gz chromium_src-3cae153ece09c094253080735d5fdf4d42299d8c.tar.bz2 |
Break port dependency on glue. Create ResourceRequest::TargetType as a mirror to the enum defined in glue/resource_type.h
It is a bit annoying to define a mapping here, but I'm not sure how else to handle it.
R=eroman
Review URL: http://codereview.chromium.org/9768
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/resource_handle_impl.cc | 32 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 30 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.cc | 2 | ||||
-rw-r--r-- | webkit/port/platform/network/chromium/ResourceRequest.h | 32 |
4 files changed, 57 insertions, 39 deletions
diff --git a/webkit/glue/resource_handle_impl.cc b/webkit/glue/resource_handle_impl.cc index 7db50ca..a7d72a7 100644 --- a/webkit/glue/resource_handle_impl.cc +++ b/webkit/glue/resource_handle_impl.cc @@ -63,12 +63,28 @@ using base::Time; using base::TimeDelta; using net::HttpResponseHeaders; -namespace { +namespace WebCore { + +static ResourceType::Type FromTargetType(ResourceRequest::TargetType type) { + switch (type) { + case ResourceRequest::TargetIsMainFrame: + return ResourceType::MAIN_FRAME; + case ResourceRequest::TargetIsSubFrame: + return ResourceType::SUB_FRAME; + case ResourceRequest::TargetIsSubResource: + return ResourceType::SUB_RESOURCE; + case ResourceRequest::TargetIsObject: + return ResourceType::OBJECT; + default: + NOTREACHED(); + return ResourceType::SUB_RESOURCE; + } +} // Extracts the information from a data: url. -bool GetInfoFromDataUrl(const GURL& url, - ResourceLoaderBridge::ResponseInfo* info, - std::string* data, URLRequestStatus* status) { +static bool GetInfoFromDataUrl(const GURL& url, + ResourceLoaderBridge::ResponseInfo* info, + std::string* data, URLRequestStatus* status) { std::string mime_type; std::string charset; if (net::DataURL::Parse(url, &mime_type, &charset, data)) { @@ -84,10 +100,6 @@ bool GetInfoFromDataUrl(const GURL& url, return false; } -} // namespace - -namespace WebCore { - static void ExtractInfoFromHeaders(const HttpResponseHeaders* headers, HTTPHeaderMap* header_map, int* status_code, @@ -317,7 +329,7 @@ bool ResourceHandleInternal::Start( // document, so we leave policyURL empty to indicate that the request is a // first-party request. GURL policy_url; - if (request_.resourceType() != ResourceType::MAIN_FRAME && + if (request_.targetType() != ResourceRequest::TargetIsMainFrame && request_.frame() && request_.frame()->document()) { policy_url = GURL(webkit_glue::StringToStdString( request_.frame()->document()->policyBaseURL())); @@ -428,7 +440,7 @@ bool ResourceHandleInternal::Start( webkit_glue::CStringToStdString(headerBuf.latin1()), load_flags_, origin_pid, - request_.resourceType(), + FromTargetType(request_.targetType()), mixed_content)); if (!bridge_.get()) return false; diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 362ea58..946e784 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -161,25 +161,25 @@ void WebFrameLoaderClient::assignIdentifierToInitialRequest( } } -// Determines whether the request being loaded by |loader| is a frame -// or a subresource. A subresource in this context is anything other -// than a frame -- this includes images and xmlhttp requests. -// It is important to note that a subresource is NOT limited to stuff -// loaded through the frame's subresource loader. Synchronous xmlhttp -// requests for example, do not go through the subresource loader, -// but we still label them as SUB_RESOURCE. +// Determines whether the request being loaded by |loader| is a frame or a +// subresource. A subresource in this context is anything other than a frame -- +// this includes images and xmlhttp requests. It is important to note that a +// subresource is NOT limited to stuff loaded through the frame's subresource +// loader. Synchronous xmlhttp requests for example, do not go through the +// subresource loader, but we still label them as TargetIsSubResource. // // The important edge cases to consider when modifying this function are // how synchronous resource loads are treated during load/unload threshold. -static ResourceType::Type DetermineResourceTypeFromLoader(DocumentLoader* loader) { +static ResourceRequest::TargetType DetermineTargetTypeFromLoader( + DocumentLoader* loader) { if (loader == loader->frameLoader()->provisionalDocumentLoader()) { if (loader->frameLoader()->isLoadingMainFrame()) { - return ResourceType::MAIN_FRAME; + return ResourceRequest::TargetIsMainFrame; } else { - return ResourceType::SUB_FRAME; + return ResourceRequest::TargetIsSubFrame; } } - return ResourceType::SUB_RESOURCE; + return ResourceRequest::TargetIsSubResource; } void WebFrameLoaderClient::dispatchWillSendRequest( @@ -191,7 +191,7 @@ void WebFrameLoaderClient::dispatchWillSendRequest( // We want to distinguish between a request for a document to be loaded into // the main frame, a sub-frame, or the sub-objects in that document. - request.setResourceType(DetermineResourceTypeFromLoader(loader)); + request.setTargetType(DetermineTargetTypeFromLoader(loader)); // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document // with no URL. We don't like that, so we'll rename it to about:blank. @@ -227,7 +227,7 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, /* TODO(evanm): reenable this once we properly sniff XHTML from text/xml documents. // True if the request was for the page's main frame, or a subframe. - bool is_frame = ResourceType::IsFrame(DetermineResourceTypeFromLoader(loader)); + bool is_frame = ResourceType::IsFrame(DetermineTargetTypeFromLoader(loader)); if (is_frame && response.httpStatusCode() == 200 && mime_util::IsViewSourceMimeType( @@ -245,8 +245,10 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader* loader, // If it's a 404 page, we wait until we get 512 bytes of data before trying // to load the document. This allows us to put up an alternate 404 page if // there's short text. + ResourceRequest::TargetType target_type = + DetermineTargetTypeFromLoader(loader); postpone_loading_data_ = - ResourceType::MAIN_FRAME == DetermineResourceTypeFromLoader(loader) && + ResourceRequest::TargetIsMainFrame == target_type && !is_substitute_data && response.httpStatusCode() == 404 && GetAlt404PageUrl(loader).is_valid(); diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index 80936f9..787eff7 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -1227,7 +1227,7 @@ bool WebPluginImpl::InitiateHTTPRequest(int resource_id, info.request.setFrame(frame()); info.request.setURL(kurl); info.request.setOriginPid(delegate_->GetProcessId()); - info.request.setResourceType(ResourceType::OBJECT); + info.request.setTargetType(WebCore::ResourceRequest::TargetIsObject); info.request.setHTTPMethod(method); if (range_info) diff --git a/webkit/port/platform/network/chromium/ResourceRequest.h b/webkit/port/platform/network/chromium/ResourceRequest.h index 7fe8bab..a0c1bb7 100644 --- a/webkit/port/platform/network/chromium/ResourceRequest.h +++ b/webkit/port/platform/network/chromium/ResourceRequest.h @@ -31,20 +31,24 @@ #include "CString.h" #include "ResourceRequestBase.h" -// TODO(darin): Eliminate this dependency on glue! -#include "webkit/glue/resource_type.h" - namespace WebCore { class Frame; class ResourceRequest : public ResourceRequestBase { public: + enum TargetType { + TargetIsMainFrame, + TargetIsSubFrame, + TargetIsSubResource, + TargetIsObject + }; + ResourceRequest(const String& url) : ResourceRequestBase(KURL(url), UseProtocolCachePolicy) , m_frame(0) , m_originPid(0) - , m_resourceType(ResourceType::SUB_RESOURCE) + , m_targetType(TargetIsSubResource) { } @@ -52,16 +56,16 @@ namespace WebCore { : ResourceRequestBase(url, UseProtocolCachePolicy) , m_frame(0) , m_originPid(0) - , m_resourceType(ResourceType::SUB_RESOURCE) + , m_targetType(TargetIsSubResource) , m_securityInfo(securityInfo) { } ResourceRequest(const KURL& url) - : ResourceRequestBase(url, UseProtocolCachePolicy) - , m_frame(0) - , m_originPid(0) - , m_resourceType(ResourceType::SUB_RESOURCE) + : ResourceRequestBase(url, UseProtocolCachePolicy) + , m_frame(0) + , m_originPid(0) + , m_targetType(TargetIsSubResource) { } @@ -69,7 +73,7 @@ namespace WebCore { : ResourceRequestBase(url, policy) , m_frame(0) , m_originPid(0) - , m_resourceType(ResourceType::SUB_RESOURCE) + , m_targetType(TargetIsSubResource) { setHTTPReferrer(referrer); } @@ -78,7 +82,7 @@ namespace WebCore { : ResourceRequestBase(KURL(), UseProtocolCachePolicy) , m_frame(0) , m_originPid(0) - , m_resourceType(ResourceType::SUB_RESOURCE) + , m_targetType(TargetIsSubResource) { } @@ -87,8 +91,8 @@ namespace WebCore { void setFrame(Frame* frame) { m_frame = frame; } // What this request is for. - void setResourceType(ResourceType::Type type) { m_resourceType = type; } - ResourceType::Type resourceType() const { return m_resourceType; } + void setTargetType(TargetType type) { m_targetType = type; } + TargetType targetType() const { return m_targetType; } // The origin pid is the process id of the process from which this // request originated. In the case of out-of-process plugins, this @@ -114,7 +118,7 @@ namespace WebCore { Frame* m_frame; int m_originPid; - ResourceType::Type m_resourceType; + TargetType m_targetType; CString m_securityInfo; }; |