summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authortonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-18 17:09:33 +0000
committertonyg@chromium.org <tonyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-18 17:09:33 +0000
commitb808eb6f0f47a7c4ad15dd8ec115404ce14b47b6 (patch)
tree8315454562119f7591028e5f13bb528abb1dc9ef /chrome/browser/renderer_host
parentcadf9b3f3fc8844f95b467afd40a2abf3cd615f9 (diff)
downloadchromium_src-b808eb6f0f47a7c4ad15dd8ec115404ce14b47b6.zip
chromium_src-b808eb6f0f47a7c4ad15dd8ec115404ce14b47b6.tar.gz
chromium_src-b808eb6f0f47a7c4ad15dd8ec115404ce14b47b6.tar.bz2
Wire sending/receiving cacheable metadata from the renderer
to the disk cache. BUG=32407 TEST=None Review URL: http://codereview.chromium.org/1698001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47522 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/async_resource_handler.cc9
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc32
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h7
3 files changed, 45 insertions, 3 deletions
diff --git a/chrome/browser/renderer_host/async_resource_handler.cc b/chrome/browser/renderer_host/async_resource_handler.cc
index a4a3494..30df3a2 100644
--- a/chrome/browser/renderer_host/async_resource_handler.cc
+++ b/chrome/browser/renderer_host/async_resource_handler.cc
@@ -124,6 +124,15 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id,
receiver_->Send(new ViewMsg_Resource_ReceivedResponse(
routing_id_, request_id, response->response_head));
+
+ if (request->response_info().metadata) {
+ std::vector<char> copy(request->response_info().metadata->data(),
+ request->response_info().metadata->data() +
+ request->response_info().metadata->size());
+ receiver_->Send(new ViewMsg_Resource_ReceivedCachedMetadata(
+ routing_id_, request_id, copy));
+ }
+
return true;
}
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index d27ec21..7de83a7 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -548,6 +548,8 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_CloseCurrentConnections,
OnCloseCurrentConnections)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetCacheMode, OnSetCacheMode)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata,
+ OnCacheableMetadataAvailable)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime,
OnGetFileModificationTime)
@@ -1300,7 +1302,7 @@ void ResourceMessageFilter::OnOpenChannelToTab(
}
}
-bool ResourceMessageFilter::CheckBenchmarkingEnabled() {
+bool ResourceMessageFilter::CheckBenchmarkingEnabled() const {
static bool checked = false;
static bool result = false;
if (!checked) {
@@ -1332,6 +1334,34 @@ void ResourceMessageFilter::OnSetCacheMode(bool enabled) {
http_transaction_factory()->GetCache()->set_mode(mode);
}
+bool ResourceMessageFilter::CheckPreparsedJsCachingEnabled() const {
+ static bool checked = false;
+ static bool result = false;
+ if (!checked) {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ result = command_line.HasSwitch(switches::kEnablePreparsedJsCaching);
+ checked = true;
+ }
+ return result;
+}
+
+void ResourceMessageFilter::OnCacheableMetadataAvailable(
+ const GURL& url,
+ double expected_response_time,
+ const std::vector<char>& data) {
+ if (!CheckPreparsedJsCachingEnabled())
+ return;
+
+ net::HttpCache* cache = request_context_->GetURLRequestContext()->
+ http_transaction_factory()->GetCache();
+ DCHECK(cache);
+
+ scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(data.size());
+ memcpy(buf->data(), &data.front(), data.size());
+ cache->WriteMetadata(
+ url, base::Time::FromDoubleT(expected_response_time), buf, data.size());
+}
+
void ResourceMessageFilter::OnGetFileSize(const FilePath& path,
IPC::Message* reply_msg) {
// Get file size only when the child process has been granted permission to
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index e3e9ef6..76e1ea1 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -315,7 +315,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnCloseCurrentConnections();
void OnSetCacheMode(bool enabled);
-
+ void OnCacheableMetadataAvailable(const GURL& url,
+ double expected_response_time,
+ const std::vector<char>& data);
void OnGetFileSize(const FilePath& path, IPC::Message* reply_msg);
void OnGetFileModificationTime(const FilePath& path, IPC::Message* reply_msg);
void OnGetFileInfoOnFileThread(const FilePath& path,
@@ -352,7 +354,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void DoOnAllocateTempFileForPrinting(IPC::Message* reply_msg);
#endif
- bool CheckBenchmarkingEnabled();
+ bool CheckBenchmarkingEnabled() const;
+ bool CheckPreparsedJsCachingEnabled() const;
// We have our own clipboard because we want to access the clipboard on the
// IO thread instead of forwarding (possibly synchronous) messages to the UI