| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/renderer_host/resource_message_filter.h" | 5 #include "chrome/browser/renderer_host/resource_message_filter.h" |
| 6 | 6 |
| 7 #include "app/clipboard/clipboard.h" | 7 #include "app/clipboard/clipboard.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 OnAllocTransportDIB) | 541 OnAllocTransportDIB) |
| 542 IPC_MESSAGE_HANDLER(ViewHostMsg_FreeTransportDIB, | 542 IPC_MESSAGE_HANDLER(ViewHostMsg_FreeTransportDIB, |
| 543 OnFreeTransportDIB) | 543 OnFreeTransportDIB) |
| 544 #endif | 544 #endif |
| 545 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, | 545 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, |
| 546 OnOpenChannelToExtension) | 546 OnOpenChannelToExtension) |
| 547 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToTab, OnOpenChannelToTab) | 547 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToTab, OnOpenChannelToTab) |
| 548 IPC_MESSAGE_HANDLER(ViewHostMsg_CloseCurrentConnections, | 548 IPC_MESSAGE_HANDLER(ViewHostMsg_CloseCurrentConnections, |
| 549 OnCloseCurrentConnections) | 549 OnCloseCurrentConnections) |
| 550 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCacheMode, OnSetCacheMode) | 550 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCacheMode, OnSetCacheMode) |
| 551 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata, |
| 552 OnCacheableMetadataAvailable) |
| 551 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize) | 553 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize) |
| 552 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime, | 554 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime, |
| 553 OnGetFileModificationTime) | 555 OnGetFileModificationTime) |
| 554 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenFile, OnOpenFile) | 556 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenFile, OnOpenFile) |
| 555 IPC_MESSAGE_HANDLER(ViewHostMsg_Keygen, OnKeygen) | 557 IPC_MESSAGE_HANDLER(ViewHostMsg_Keygen, OnKeygen) |
| 556 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetExtensionMessageBundle, | 558 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetExtensionMessageBundle, |
| 557 OnGetExtensionMessageBundle) | 559 OnGetExtensionMessageBundle) |
| 558 #if defined(USE_TCMALLOC) | 560 #if defined(USE_TCMALLOC) |
| 559 IPC_MESSAGE_HANDLER(ViewHostMsg_RendererTcmalloc, OnRendererTcmalloc) | 561 IPC_MESSAGE_HANDLER(ViewHostMsg_RendererTcmalloc, OnRendererTcmalloc) |
| 560 #endif | 562 #endif |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 int routing_id, int tab_id, const std::string& extension_id, | 1295 int routing_id, int tab_id, const std::string& extension_id, |
| 1294 const std::string& channel_name, int* port_id) { | 1296 const std::string& channel_name, int* port_id) { |
| 1295 if (extensions_message_service_.get()) { | 1297 if (extensions_message_service_.get()) { |
| 1296 *port_id = extensions_message_service_-> | 1298 *port_id = extensions_message_service_-> |
| 1297 OpenChannelToTab(routing_id, tab_id, extension_id, channel_name, this); | 1299 OpenChannelToTab(routing_id, tab_id, extension_id, channel_name, this); |
| 1298 } else { | 1300 } else { |
| 1299 *port_id = -1; | 1301 *port_id = -1; |
| 1300 } | 1302 } |
| 1301 } | 1303 } |
| 1302 | 1304 |
| 1303 bool ResourceMessageFilter::CheckBenchmarkingEnabled() { | 1305 bool ResourceMessageFilter::CheckBenchmarkingEnabled() const { |
| 1304 static bool checked = false; | 1306 static bool checked = false; |
| 1305 static bool result = false; | 1307 static bool result = false; |
| 1306 if (!checked) { | 1308 if (!checked) { |
| 1307 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1309 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1308 result = command_line.HasSwitch(switches::kEnableBenchmarking); | 1310 result = command_line.HasSwitch(switches::kEnableBenchmarking); |
| 1309 checked = true; | 1311 checked = true; |
| 1310 } | 1312 } |
| 1311 return result; | 1313 return result; |
| 1312 } | 1314 } |
| 1313 | 1315 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1325 // benchmarking extensions. | 1327 // benchmarking extensions. |
| 1326 if (!CheckBenchmarkingEnabled()) | 1328 if (!CheckBenchmarkingEnabled()) |
| 1327 return; | 1329 return; |
| 1328 | 1330 |
| 1329 net::HttpCache::Mode mode = enabled ? | 1331 net::HttpCache::Mode mode = enabled ? |
| 1330 net::HttpCache::NORMAL : net::HttpCache::DISABLE; | 1332 net::HttpCache::NORMAL : net::HttpCache::DISABLE; |
| 1331 request_context_->GetURLRequestContext()-> | 1333 request_context_->GetURLRequestContext()-> |
| 1332 http_transaction_factory()->GetCache()->set_mode(mode); | 1334 http_transaction_factory()->GetCache()->set_mode(mode); |
| 1333 } | 1335 } |
| 1334 | 1336 |
| 1337 bool ResourceMessageFilter::CheckPreparsedJsCachingEnabled() const { |
| 1338 static bool checked = false; |
| 1339 static bool result = false; |
| 1340 if (!checked) { |
| 1341 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1342 result = command_line.HasSwitch(switches::kEnablePreparsedJsCaching); |
| 1343 checked = true; |
| 1344 } |
| 1345 return result; |
| 1346 } |
| 1347 |
| 1348 void ResourceMessageFilter::OnCacheableMetadataAvailable( |
| 1349 const GURL& url, |
| 1350 double expected_response_time, |
| 1351 const std::vector<char>& data) { |
| 1352 if (!CheckPreparsedJsCachingEnabled()) |
| 1353 return; |
| 1354 |
| 1355 net::HttpCache* cache = request_context_->GetURLRequestContext()-> |
| 1356 http_transaction_factory()->GetCache(); |
| 1357 DCHECK(cache); |
| 1358 |
| 1359 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(data.size()); |
| 1360 memcpy(buf->data(), &data.front(), data.size()); |
| 1361 cache->WriteMetadata( |
| 1362 url, base::Time::FromDoubleT(expected_response_time), buf, data.size()); |
| 1363 } |
| 1364 |
| 1335 void ResourceMessageFilter::OnGetFileSize(const FilePath& path, | 1365 void ResourceMessageFilter::OnGetFileSize(const FilePath& path, |
| 1336 IPC::Message* reply_msg) { | 1366 IPC::Message* reply_msg) { |
| 1337 // Get file size only when the child process has been granted permission to | 1367 // Get file size only when the child process has been granted permission to |
| 1338 // upload the file. | 1368 // upload the file. |
| 1339 if (!ChildProcessSecurityPolicy::GetInstance()->CanUploadFile(id(), path)) { | 1369 if (!ChildProcessSecurityPolicy::GetInstance()->CanUploadFile(id(), path)) { |
| 1340 ViewHostMsg_GetFileSize::WriteReplyParams( | 1370 ViewHostMsg_GetFileSize::WriteReplyParams( |
| 1341 reply_msg, static_cast<int64>(-1)); | 1371 reply_msg, static_cast<int64>(-1)); |
| 1342 Send(reply_msg); | 1372 Send(reply_msg); |
| 1343 return; | 1373 return; |
| 1344 } | 1374 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 dictionary_map.insert( | 1571 dictionary_map.insert( |
| 1542 std::make_pair(ExtensionMessageBundle::kExtensionIdKey, extension_id)); | 1572 std::make_pair(ExtensionMessageBundle::kExtensionIdKey, extension_id)); |
| 1543 | 1573 |
| 1544 ViewHostMsg_GetExtensionMessageBundle::WriteReplyParams( | 1574 ViewHostMsg_GetExtensionMessageBundle::WriteReplyParams( |
| 1545 reply_msg, dictionary_map); | 1575 reply_msg, dictionary_map); |
| 1546 | 1576 |
| 1547 ChromeThread::PostTask( | 1577 ChromeThread::PostTask( |
| 1548 ChromeThread::IO, FROM_HERE, | 1578 ChromeThread::IO, FROM_HERE, |
| 1549 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg)); | 1579 NewRunnableMethod(this, &ResourceMessageFilter::Send, reply_msg)); |
| 1550 } | 1580 } |
| OLD | NEW |