OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/clipboard.h" | 7 #include "base/clipboard.h" |
| 8 #include "base/command_line.h" |
8 #include "base/gfx/native_widget_types.h" | 9 #include "base/gfx/native_widget_types.h" |
9 #include "base/histogram.h" | 10 #include "base/histogram.h" |
10 #include "base/process_util.h" | 11 #include "base/process_util.h" |
11 #include "base/thread.h" | 12 #include "base/thread.h" |
12 #include "chrome/browser/chrome_plugin_browsing_context.h" | 13 #include "chrome/browser/chrome_plugin_browsing_context.h" |
13 #include "chrome/browser/chrome_thread.h" | 14 #include "chrome/browser/chrome_thread.h" |
14 #include "chrome/browser/extensions/extension_message_service.h" | 15 #include "chrome/browser/extensions/extension_message_service.h" |
15 #include "chrome/browser/net/dns_global.h" | 16 #include "chrome/browser/net/dns_global.h" |
16 #include "chrome/browser/plugin_service.h" | 17 #include "chrome/browser/plugin_service.h" |
17 #include "chrome/browser/profile.h" | 18 #include "chrome/browser/profile.h" |
18 #include "chrome/browser/renderer_host/audio_renderer_host.h" | 19 #include "chrome/browser/renderer_host/audio_renderer_host.h" |
19 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 20 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
20 #include "chrome/browser/renderer_host/render_widget_helper.h" | 21 #include "chrome/browser/renderer_host/render_widget_helper.h" |
21 #include "chrome/browser/spellchecker.h" | 22 #include "chrome/browser/spellchecker.h" |
22 #include "chrome/browser/worker_host/worker_service.h" | 23 #include "chrome/browser/worker_host/worker_service.h" |
23 #include "chrome/common/app_cache/app_cache_dispatcher_host.h" | 24 #include "chrome/common/app_cache/app_cache_dispatcher_host.h" |
24 #include "chrome/common/chrome_plugin_lib.h" | 25 #include "chrome/common/chrome_plugin_lib.h" |
25 #include "chrome/common/chrome_plugin_util.h" | 26 #include "chrome/common/chrome_plugin_util.h" |
| 27 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/histogram_synchronizer.h" | 28 #include "chrome/common/histogram_synchronizer.h" |
27 #include "chrome/common/notification_service.h" | 29 #include "chrome/common/notification_service.h" |
28 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
29 #include "chrome/common/pref_service.h" | 31 #include "chrome/common/pref_service.h" |
30 #include "chrome/common/render_messages.h" | 32 #include "chrome/common/render_messages.h" |
31 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
32 #include "net/base/cookie_monster.h" | 34 #include "net/base/cookie_monster.h" |
33 #include "net/base/mime_util.h" | 35 #include "net/base/mime_util.h" |
34 #include "net/base/load_flags.h" | 36 #include "net/base/load_flags.h" |
| 37 #include "net/http/http_cache.h" |
| 38 #include "net/http/http_transaction_factory.h" |
35 #include "net/url_request/url_request_context.h" | 39 #include "net/url_request/url_request_context.h" |
36 #include "webkit/glue/webkit_glue.h" | 40 #include "webkit/glue/webkit_glue.h" |
37 #include "webkit/glue/webplugin.h" | 41 #include "webkit/glue/webplugin.h" |
38 | 42 |
39 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
40 #include "chrome/browser/printing/print_job_manager.h" | 44 #include "chrome/browser/printing/print_job_manager.h" |
41 #include "chrome/browser/printing/printer_query.h" | 45 #include "chrome/browser/printing/printer_query.h" |
42 #elif defined(OS_MACOSX) || defined(OS_LINUX) | 46 #elif defined(OS_MACOSX) || defined(OS_LINUX) |
43 // TODO(port) remove this. | 47 // TODO(port) remove this. |
44 #include "chrome/common/temp_scaffolding_stubs.h" | 48 #include "chrome/common/temp_scaffolding_stubs.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 OnScriptedPrint) | 300 OnScriptedPrint) |
297 #endif | 301 #endif |
298 #if defined(OS_MACOSX) | 302 #if defined(OS_MACOSX) |
299 IPC_MESSAGE_HANDLER(ViewHostMsg_AllocTransportDIB, | 303 IPC_MESSAGE_HANDLER(ViewHostMsg_AllocTransportDIB, |
300 OnAllocTransportDIB) | 304 OnAllocTransportDIB) |
301 IPC_MESSAGE_HANDLER(ViewHostMsg_FreeTransportDIB, | 305 IPC_MESSAGE_HANDLER(ViewHostMsg_FreeTransportDIB, |
302 OnFreeTransportDIB) | 306 OnFreeTransportDIB) |
303 #endif | 307 #endif |
304 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, | 308 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, |
305 OnOpenChannelToExtension) | 309 OnOpenChannelToExtension) |
| 310 IPC_MESSAGE_HANDLER(ViewHostMsg_CloseIdleConnections, |
| 311 OnCloseIdleConnections) |
| 312 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCacheMode, |
| 313 OnSetCacheMode) |
| 314 |
306 IPC_MESSAGE_UNHANDLED( | 315 IPC_MESSAGE_UNHANDLED( |
307 handled = false) | 316 handled = false) |
308 IPC_END_MESSAGE_MAP_EX() | 317 IPC_END_MESSAGE_MAP_EX() |
309 } | 318 } |
310 | 319 |
311 if (!msg_is_ok) { | 320 if (!msg_is_ok) { |
312 BrowserRenderProcessHost::BadMessageTerminateProcess(message.type(), | 321 BrowserRenderProcessHost::BadMessageTerminateProcess(message.type(), |
313 handle()); | 322 handle()); |
314 } | 323 } |
315 | 324 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 TransportDIB::Id dib_id) { | 854 TransportDIB::Id dib_id) { |
846 render_widget_helper_->FreeTransportDIB(dib_id); | 855 render_widget_helper_->FreeTransportDIB(dib_id); |
847 } | 856 } |
848 #endif | 857 #endif |
849 | 858 |
850 void ResourceMessageFilter::OnOpenChannelToExtension( | 859 void ResourceMessageFilter::OnOpenChannelToExtension( |
851 int routing_id, const std::string& extension_id, int* port_id) { | 860 int routing_id, const std::string& extension_id, int* port_id) { |
852 *port_id = ExtensionMessageService::GetInstance(request_context_.get())-> | 861 *port_id = ExtensionMessageService::GetInstance(request_context_.get())-> |
853 OpenChannelToExtension(routing_id, extension_id, this); | 862 OpenChannelToExtension(routing_id, extension_id, this); |
854 } | 863 } |
| 864 |
| 865 bool ResourceMessageFilter::CheckBenchmarkingEnabled() { |
| 866 static bool checked = false; |
| 867 static bool result = false; |
| 868 if (!checked) { |
| 869 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 870 result = command_line.HasSwitch(switches::kEnableBenchmarking); |
| 871 checked = true; |
| 872 } |
| 873 return result; |
| 874 } |
| 875 |
| 876 void ResourceMessageFilter::OnCloseIdleConnections() { |
| 877 // This function is disabled unless the user has enabled |
| 878 // benchmarking extensions. |
| 879 if (!CheckBenchmarkingEnabled()) |
| 880 return; |
| 881 request_context_-> |
| 882 http_transaction_factory()->GetCache()->CloseIdleConnections(); |
| 883 } |
| 884 |
| 885 void ResourceMessageFilter::OnSetCacheMode(bool enabled) { |
| 886 // This function is disabled unless the user has enabled |
| 887 // benchmarking extensions. |
| 888 if (!CheckBenchmarkingEnabled()) |
| 889 return; |
| 890 |
| 891 net::HttpCache::Mode mode = enabled ? |
| 892 net::HttpCache::NORMAL : net::HttpCache::DISABLE; |
| 893 request_context_->http_transaction_factory()->GetCache()->set_mode(mode); |
| 894 } |
OLD | NEW |