diff options
author | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-02 20:13:28 +0000 |
---|---|---|
committer | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-02 20:13:28 +0000 |
commit | 704359693f5c8507635155ae117c466a7149065a (patch) | |
tree | 55778bdae67f960440441085372fc98c1f974c80 | |
parent | 89b2312b5aca51da726b93e966842ffd5f642402 (diff) | |
download | chromium_src-704359693f5c8507635155ae117c466a7149065a.zip chromium_src-704359693f5c8507635155ae117c466a7149065a.tar.gz chromium_src-704359693f5c8507635155ae117c466a7149065a.tar.bz2 |
Inform disk cache of WebKit memory cache hits.
BUG=37112
TEST=net_unittests
Review URL: http://codereview.chromium.org/7461106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95145 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host.cc | 22 | ||||
-rw-r--r-- | content/browser/renderer_host/resource_dispatcher_host.h | 6 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 4 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 5 | ||||
-rw-r--r-- | content/common/view_messages.h | 6 | ||||
-rw-r--r-- | content/renderer/render_view.cc | 4 | ||||
-rw-r--r-- | net/disk_cache/backend_impl.cc | 16 | ||||
-rw-r--r-- | net/disk_cache/backend_impl.h | 2 | ||||
-rw-r--r-- | net/disk_cache/backend_unittest.cc | 23 | ||||
-rw-r--r-- | net/disk_cache/disk_cache.h | 4 | ||||
-rw-r--r-- | net/disk_cache/in_flight_backend_io.cc | 17 | ||||
-rw-r--r-- | net/disk_cache/in_flight_backend_io.h | 5 | ||||
-rw-r--r-- | net/disk_cache/mem_backend_impl.cc | 7 | ||||
-rw-r--r-- | net/disk_cache/mem_backend_impl.h | 1 | ||||
-rw-r--r-- | net/http/http_cache.cc | 12 | ||||
-rw-r--r-- | net/http/http_cache.h | 5 | ||||
-rw-r--r-- | net/http/http_cache_unittest.cc | 10 | ||||
-rw-r--r-- | webkit/glue/resource_type.cc | 47 | ||||
-rw-r--r-- | webkit/glue/resource_type.h | 3 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.gypi | 1 | ||||
-rw-r--r-- | webkit/glue/weburlloader_impl.cc | 39 |
21 files changed, 190 insertions, 49 deletions
diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index 0b78183..f0d933b 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -68,7 +68,9 @@ #include "net/base/request_priority.h" #include "net/base/ssl_cert_request_info.h" #include "net/base/upload_data.h" +#include "net/http/http_cache.h" #include "net/http/http_response_headers.h" +#include "net/http/http_transaction_factory.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_job_factory.h" @@ -338,9 +340,17 @@ bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, IPC_MESSAGE_HANDLER(ResourceHostMsg_CancelRequest, OnCancelRequest) IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, + OnDidLoadResourceFromMemoryCache) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() + if (message.type() == ViewHostMsg_DidLoadResourceFromMemoryCache::ID) { + // We just needed to peek at this message. We still want it to reach its + // normal destination. + handled = false; + } + filter_ = NULL; return handled; } @@ -675,6 +685,18 @@ void ResourceDispatcherHost::OnSwapOutACK( &RenderViewHost::OnSwapOutACK); } +void ResourceDispatcherHost::OnDidLoadResourceFromMemoryCache( + const GURL& url, + const std::string& security_info, + const std::string& http_method, + ResourceType::Type resource_type) { + if (!url.is_valid() || !(url.SchemeIs("http") || url.SchemeIs("https"))) + return; + + filter_->GetURLRequestContext(resource_type)->http_transaction_factory()-> + GetCache()->OnExternalCacheHit(url, http_method); +} + // We are explicitly forcing the download of 'url'. void ResourceDispatcherHost::BeginDownload( const GURL& url, diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host.h index 415d0c2..d6c5ce7 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.h +++ b/content/browser/renderer_host/resource_dispatcher_host.h @@ -160,6 +160,12 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate { // Called when the unload handler for a cross-site request has finished. void OnSwapOutACK(const ViewMsg_SwapOut_Params& params); + // Called when the renderer loads a resource from its internal cache. + void OnDidLoadResourceFromMemoryCache(const GURL& url, + const std::string& security_info, + const std::string& http_method, + ResourceType::Type resource_type); + // Force cancels any pending requests for the given process. void CancelRequestsForProcess(int process_unique_id); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 65ae370..2197339 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -978,7 +978,9 @@ void TabContents::OnDidFailProvisionalLoadWithError( void TabContents::OnDidLoadResourceFromMemoryCache( const GURL& url, - const std::string& security_info) { + const std::string& security_info, + const std::string& http_method, + ResourceType::Type resource_type) { base::StatsCounter cache("WebKit.CacheHit"); cache.Increment(); diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index bbf7694..f7b71c5 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -29,6 +29,7 @@ #include "content/common/renderer_preferences.h" #include "net/base/load_states.h" #include "ui/gfx/native_widget_types.h" +#include "webkit/glue/resource_type.h" #if defined(OS_WIN) #include "base/win/scoped_handle.h" @@ -553,7 +554,9 @@ class TabContents : public PageNavigator, const GURL& url, bool showing_repost_interstitial); void OnDidLoadResourceFromMemoryCache(const GURL& url, - const std::string& security_info); + const std::string& security_info, + const std::string& http_request, + ResourceType::Type resource_type); void OnDidDisplayInsecureContent(); void OnDidRunInsecureContent(const std::string& security_origin, const GURL& target_url); diff --git a/content/common/view_messages.h b/content/common/view_messages.h index df1ac83..0698af6 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -1418,9 +1418,11 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_DocumentOnLoadCompletedInMainFrame, // The security info is non empty if the resource was originally loaded over // a secure connection. // Note: May only be sent once per URL per frame per committed load. -IPC_MESSAGE_ROUTED2(ViewHostMsg_DidLoadResourceFromMemoryCache, +IPC_MESSAGE_ROUTED4(ViewHostMsg_DidLoadResourceFromMemoryCache, GURL /* url */, - std::string /* security info */) + std::string /* security info */, + std::string /* http method */, + ResourceType::Type /* resource type */) // Sent when the renderer displays insecure content in a secure page. IPC_MESSAGE_ROUTED0(ViewHostMsg_DidDisplayInsecureContent) diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index f5b0cbe..d5cedec 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -2742,7 +2742,9 @@ void RenderView::didLoadResourceFromMemoryCache( Send(new ViewHostMsg_DidLoadResourceFromMemoryCache( routing_id_, request.url(), - response.securityInfo())); + response.securityInfo(), + request.httpMethod().utf8(), + ResourceType::FromTargetType(request.targetType()))); } void RenderView::didDisplayInsecureContent(WebFrame* frame) { diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc index b03ecda..deacdd3 100644 --- a/net/disk_cache/backend_impl.cc +++ b/net/disk_cache/backend_impl.cc @@ -682,6 +682,18 @@ void BackendImpl::SyncEndEnumeration(void* iter) { reinterpret_cast<Rankings::Iterator*>(iter)); } +void BackendImpl::SyncOnExternalCacheHit(const std::string& key) { + uint32 hash = Hash(key); + bool error; + EntryImpl* cache_entry = MatchEntry(key, hash, false, Addr(), &error); + if (cache_entry) { + if (ENTRY_NORMAL == cache_entry->entry()->Data()->state) { + UpdateRank(cache_entry, false); + } + cache_entry->Release(); + } +} + EntryImpl* BackendImpl::OpenEntryImpl(const std::string& key) { if (disabled_) return NULL; @@ -1356,6 +1368,10 @@ void BackendImpl::GetStats(StatsItems* stats) { stats_.GetItems(stats); } +void BackendImpl::OnExternalCacheHit(const std::string& key) { + background_queue_.OnExternalCacheHit(key); +} + // ------------------------------------------------------------------------ // We just created a new file so we're going to write the header and set the diff --git a/net/disk_cache/backend_impl.h b/net/disk_cache/backend_impl.h index cbf6b86..1ead317 100644 --- a/net/disk_cache/backend_impl.h +++ b/net/disk_cache/backend_impl.h @@ -79,6 +79,7 @@ class NET_TEST BackendImpl : public Backend { int SyncOpenNextEntry(void** iter, Entry** next_entry); int SyncOpenPrevEntry(void** iter, Entry** prev_entry); void SyncEndEnumeration(void* iter); + void SyncOnExternalCacheHit(const std::string& key); // Open or create an entry for the given |key| or |iter|. EntryImpl* OpenEntryImpl(const std::string& key); @@ -263,6 +264,7 @@ class NET_TEST BackendImpl : public Backend { CompletionCallback* callback); virtual void EndEnumeration(void** iter); virtual void GetStats(StatsItems* stats); + virtual void OnExternalCacheHit(const std::string& key); private: typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap; diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc index 1cde9b6..3bf1aac 100644 --- a/net/disk_cache/backend_unittest.cc +++ b/net/disk_cache/backend_unittest.cc @@ -2118,3 +2118,26 @@ TEST_F(DiskCacheBackendTest, FileSharing) { EXPECT_TRUE(disk_cache::DeleteCacheFile(name)); } + +TEST_F(DiskCacheBackendTest, UpdateRankForExternalCacheHit) { + SetDirectMode(); + InitCache(); + + disk_cache::Entry* entry; + + for (int i = 0; i < 2; ++i) { + std::string key = StringPrintf("key%d", i); + ASSERT_EQ(net::OK, CreateEntry(key, &entry)); + entry->Close(); + } + + // Ping the oldest entry. + cache_->OnExternalCacheHit("key0"); + + TrimForTest(false); + + // Make sure the older key remains. + EXPECT_EQ(1, cache_->GetEntryCount()); + ASSERT_EQ(net::OK, OpenEntry("key0", &entry)); + entry->Close(); +} diff --git a/net/disk_cache/disk_cache.h b/net/disk_cache/disk_cache.h index 973b6e6..dc320cc 100644 --- a/net/disk_cache/disk_cache.h +++ b/net/disk_cache/disk_cache.h @@ -137,6 +137,10 @@ class NET_API Backend { // Return a list of cache statistics. virtual void GetStats( std::vector<std::pair<std::string, std::string> >* stats) = 0; + + // Called whenever an external cache in the system reuses the resource + // referred to by |key|. + virtual void OnExternalCacheHit(const std::string& key) = 0; }; // This interface represents an entry in the disk cache. diff --git a/net/disk_cache/in_flight_backend_io.cc b/net/disk_cache/in_flight_backend_io.cc index 5d4be18..259d888 100644 --- a/net/disk_cache/in_flight_backend_io.cc +++ b/net/disk_cache/in_flight_backend_io.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -105,6 +105,11 @@ void BackendIO::EndEnumeration(void* iterator) { iter_ = iterator; } +void BackendIO::OnExternalCacheHit(const std::string& key) { + operation_ = OP_ON_EXTERNAL_CACHE_HIT; + key_ = key; +} + void BackendIO::CloseEntryImpl(EntryImpl* entry) { operation_ = OP_CLOSE_ENTRY; entry_ = entry; @@ -218,6 +223,10 @@ void BackendIO::ExecuteBackendOperation() { backend_->SyncEndEnumeration(iter_); result_ = net::OK; break; + case OP_ON_EXTERNAL_CACHE_HIT: + backend_->SyncOnExternalCacheHit(key_); + result_ = net::OK; + break; case OP_CLOSE_ENTRY: entry_->Release(); result_ = net::OK; @@ -358,6 +367,12 @@ void InFlightBackendIO::EndEnumeration(void* iterator) { PostOperation(operation); } +void InFlightBackendIO::OnExternalCacheHit(const std::string& key) { + scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); + operation->OnExternalCacheHit(key); + PostOperation(operation); +} + void InFlightBackendIO::CloseEntryImpl(EntryImpl* entry) { scoped_refptr<BackendIO> operation(new BackendIO(this, backend_, NULL)); operation->CloseEntryImpl(entry); diff --git a/net/disk_cache/in_flight_backend_io.h b/net/disk_cache/in_flight_backend_io.h index 659a33a..a8a86eb 100644 --- a/net/disk_cache/in_flight_backend_io.h +++ b/net/disk_cache/in_flight_backend_io.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -55,6 +55,7 @@ class BackendIO : public BackgroundIO { void OpenNextEntry(void** iter, Entry** next_entry); void OpenPrevEntry(void** iter, Entry** prev_entry); void EndEnumeration(void* iterator); + void OnExternalCacheHit(const std::string& key); void CloseEntryImpl(EntryImpl* entry); void DoomEntryImpl(EntryImpl* entry); void FlushQueue(); // Dummy operation. @@ -89,6 +90,7 @@ class BackendIO : public BackgroundIO { OP_OPEN_NEXT, OP_OPEN_PREV, OP_END_ENUMERATION, + OP_ON_EXTERNAL_CACHE_HIT, OP_CLOSE_ENTRY, OP_DOOM_ENTRY, OP_FLUSH_QUEUE, @@ -159,6 +161,7 @@ class InFlightBackendIO : public InFlightIO { void OpenPrevEntry(void** iter, Entry** prev_entry, net::CompletionCallback* callback); void EndEnumeration(void* iterator); + void OnExternalCacheHit(const std::string& key); void CloseEntryImpl(EntryImpl* entry); void DoomEntryImpl(EntryImpl* entry); void FlushQueue(net::CompletionCallback* callback); diff --git a/net/disk_cache/mem_backend_impl.cc b/net/disk_cache/mem_backend_impl.cc index 6915ede..2f7713b 100644 --- a/net/disk_cache/mem_backend_impl.cc +++ b/net/disk_cache/mem_backend_impl.cc @@ -188,6 +188,13 @@ void MemBackendImpl::EndEnumeration(void** iter) { *iter = NULL; } +void MemBackendImpl::OnExternalCacheHit(const std::string& key) { + EntryMap::iterator it = entries_.find(key); + if (it != entries_.end()) { + UpdateRank(it->second); + } +} + bool MemBackendImpl::OpenEntry(const std::string& key, Entry** entry) { EntryMap::iterator it = entries_.find(key); if (it == entries_.end()) diff --git a/net/disk_cache/mem_backend_impl.h b/net/disk_cache/mem_backend_impl.h index 52a78f6..26a2556 100644 --- a/net/disk_cache/mem_backend_impl.h +++ b/net/disk_cache/mem_backend_impl.h @@ -80,6 +80,7 @@ class NET_TEST MemBackendImpl : public Backend { virtual void EndEnumeration(void** iter); virtual void GetStats( std::vector<std::pair<std::string, std::string> >* stats) {} + virtual void OnExternalCacheHit(const std::string& key); private: typedef base::hash_map<std::string, MemEntryImpl*> EntryMap; diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 157059df..c1bb0d8 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -463,6 +463,18 @@ void HttpCache::CloseAllConnections() { session->CloseAllConnections(); } +void HttpCache::OnExternalCacheHit(const GURL& url, + const std::string& http_method) { + if (!disk_cache_.get()) + return; + + HttpRequestInfo request_info; + request_info.url = url; + request_info.method = http_method; + std::string key = GenerateCacheKey(&request_info); + disk_cache_->OnExternalCacheHit(key); +} + int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { // Do lazy initialization of disk cache if needed. if (!disk_cache_.get()) diff --git a/net/http/http_cache.h b/net/http/http_cache.h index 861d36b..1f5fa5f1 100644 --- a/net/http/http_cache.h +++ b/net/http/http_cache.h @@ -179,6 +179,10 @@ class NET_API HttpCache : public HttpTransactionFactory, // immediately, but they will not be reusable. This is for debugging. void CloseAllConnections(); + // Called whenever an external cache in the system reuses the resource + // referred to by |url| and |http_method|. + void OnExternalCacheHit(const GURL& url, const std::string& http_method); + // HttpTransactionFactory implementation: virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); virtual HttpCache* GetCache(); @@ -345,7 +349,6 @@ class NET_API HttpCache : public HttpTransactionFactory, // Processes the backend creation notification. void OnBackendCreated(int result, PendingOp* pending_op); - // Variables ---------------------------------------------------------------- NetLog* net_log_; diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 493c4e6..b467dc5 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -72,13 +72,13 @@ class MockDiskEntry : public disk_cache::Entry, public base::RefCounted<MockDiskEntry> { public: MockDiskEntry() - : test_mode_(0), doomed_(false), sparse_(false), fail_requests_(false), - busy_(false), delayed_(false) { + : test_mode_(0), doomed_(false), sparse_(false), + fail_requests_(false), busy_(false), delayed_(false) { } explicit MockDiskEntry(const std::string& key) - : key_(key), doomed_(false), sparse_(false), fail_requests_(false), - busy_(false), delayed_(false) { + : key_(key), doomed_(false), sparse_(false), + fail_requests_(false), busy_(false), delayed_(false) { test_mode_ = GetTestModeForEntry(key); } @@ -487,6 +487,8 @@ class MockDiskCache : public disk_cache::Backend { std::vector<std::pair<std::string, std::string> >* stats) { } + virtual void OnExternalCacheHit(const std::string& key) {} + // returns number of times a cache entry was successfully opened int open_count() const { return open_count_; } diff --git a/webkit/glue/resource_type.cc b/webkit/glue/resource_type.cc new file mode 100644 index 0000000..228bfc6 --- /dev/null +++ b/webkit/glue/resource_type.cc @@ -0,0 +1,47 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/glue/resource_type.h" + +#include "base/logging.h" + +using WebKit::WebURLRequest; + +// static +ResourceType::Type ResourceType::FromTargetType( + WebURLRequest::TargetType type) { + switch (type) { + case WebURLRequest::TargetIsMainFrame: + return ResourceType::MAIN_FRAME; + case WebURLRequest::TargetIsSubframe: + return ResourceType::SUB_FRAME; + case WebURLRequest::TargetIsSubresource: + return ResourceType::SUB_RESOURCE; + case WebURLRequest::TargetIsStyleSheet: + return ResourceType::STYLESHEET; + case WebURLRequest::TargetIsScript: + return ResourceType::SCRIPT; + case WebURLRequest::TargetIsFontResource: + return ResourceType::FONT_RESOURCE; + case WebURLRequest::TargetIsImage: + return ResourceType::IMAGE; + case WebURLRequest::TargetIsObject: + return ResourceType::OBJECT; + case WebURLRequest::TargetIsMedia: + return ResourceType::MEDIA; + case WebURLRequest::TargetIsWorker: + return ResourceType::WORKER; + case WebURLRequest::TargetIsSharedWorker: + return ResourceType::SHARED_WORKER; + case WebURLRequest::TargetIsPrefetch: + return ResourceType::PREFETCH; + case WebURLRequest::TargetIsPrerender: + return ResourceType::PRERENDER; + case WebURLRequest::TargetIsFavicon: + return ResourceType::FAVICON; + default: + NOTREACHED(); + return ResourceType::SUB_RESOURCE; + } +} diff --git a/webkit/glue/resource_type.h b/webkit/glue/resource_type.h index e9ae3b6..2e26732 100644 --- a/webkit/glue/resource_type.h +++ b/webkit/glue/resource_type.h @@ -6,6 +6,7 @@ #define WEBKIT_GLUE_RESOURCE_TYPE_H__ #include "base/basictypes.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" class ResourceType { public: @@ -37,6 +38,8 @@ class ResourceType { return static_cast<Type>(type); } + static Type FromTargetType(WebKit::WebURLRequest::TargetType type); + static bool IsFrame(ResourceType::Type type) { return type == MAIN_FRAME || type == SUB_FRAME; } diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index 076d6f6..686876d 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -382,6 +382,7 @@ 'resource_fetcher.h', 'resource_loader_bridge.cc', 'resource_loader_bridge.h', + 'resource_type.cc', 'resource_type.h', 'request_extra_data.cc', 'request_extra_data.h', diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 5e3ddef..7eaa37a 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -109,42 +109,6 @@ class HeaderFlattener : public WebHTTPHeaderVisitor { bool has_accept_header_; }; -ResourceType::Type FromTargetType(WebURLRequest::TargetType type) { - switch (type) { - case WebURLRequest::TargetIsMainFrame: - return ResourceType::MAIN_FRAME; - case WebURLRequest::TargetIsSubframe: - return ResourceType::SUB_FRAME; - case WebURLRequest::TargetIsSubresource: - return ResourceType::SUB_RESOURCE; - case WebURLRequest::TargetIsStyleSheet: - return ResourceType::STYLESHEET; - case WebURLRequest::TargetIsScript: - return ResourceType::SCRIPT; - case WebURLRequest::TargetIsFontResource: - return ResourceType::FONT_RESOURCE; - case WebURLRequest::TargetIsImage: - return ResourceType::IMAGE; - case WebURLRequest::TargetIsObject: - return ResourceType::OBJECT; - case WebURLRequest::TargetIsMedia: - return ResourceType::MEDIA; - case WebURLRequest::TargetIsWorker: - return ResourceType::WORKER; - case WebURLRequest::TargetIsSharedWorker: - return ResourceType::SHARED_WORKER; - case WebURLRequest::TargetIsPrefetch: - return ResourceType::PREFETCH; - case WebURLRequest::TargetIsPrerender: - return ResourceType::PRERENDER; - case WebURLRequest::TargetIsFavicon: - return ResourceType::FAVICON; - default: - NOTREACHED(); - return ResourceType::SUB_RESOURCE; - } -} - // Extracts the information from a data: url. bool GetInfoFromDataURL(const GURL& url, ResourceResponseInfo* info, @@ -434,7 +398,8 @@ void WebURLLoaderImpl::Context::Start( // the render process, so we can use requestorProcessID even for requests // from in-process plugins. request_info.requestor_pid = request.requestorProcessID(); - request_info.request_type = FromTargetType(request.targetType()); + request_info.request_type = + ResourceType::FromTargetType(request.targetType()); request_info.appcache_host_id = request.appCacheHostID(); request_info.routing_id = request.requestorID(); request_info.download_to_file = request.downloadToFile(); |