Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2904)

Unified Diff: chrome/browser/renderer_host/resource_message_filter.cc

Issue 1698001: Receive cacheable metadata from the renderer and... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/renderer_host/resource_message_filter.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698