Index: chrome/browser/renderer_host/resource_message_filter.cc |
=================================================================== |
--- chrome/browser/renderer_host/resource_message_filter.cc (revision 47510) |
+++ chrome/browser/renderer_host/resource_message_filter.cc (working copy) |
@@ -548,6 +548,8 @@ |
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 @@ |
} |
} |
-bool ResourceMessageFilter::CheckBenchmarkingEnabled() { |
+bool ResourceMessageFilter::CheckBenchmarkingEnabled() const { |
static bool checked = false; |
static bool result = false; |
if (!checked) { |
@@ -1332,6 +1334,34 @@ |
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 |