| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "content/browser/renderer_host/browser_render_process_host.h" | 8 #include "content/browser/renderer_host/browser_render_process_host.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/metrics/field_trial.h" | 21 #include "base/metrics/field_trial.h" |
| 22 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
| 23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 24 #include "base/platform_file.h" | 24 #include "base/platform_file.h" |
| 25 #include "base/stl_util-inl.h" | 25 #include "base/stl_util-inl.h" |
| 26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
| 27 #include "base/threading/thread.h" | 27 #include "base/threading/thread.h" |
| 28 #include "base/threading/thread_restrictions.h" | 28 #include "base/threading/thread_restrictions.h" |
| 29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/history/history.h" | 30 #include "chrome/browser/history/history.h" |
| 31 #include "chrome/browser/io_thread.h" | |
| 32 #include "chrome/browser/net/resolve_proxy_msg_helper.h" | 31 #include "chrome/browser/net/resolve_proxy_msg_helper.h" |
| 33 #include "chrome/browser/platform_util.h" | 32 #include "chrome/browser/platform_util.h" |
| 34 #include "chrome/browser/prefs/pref_service.h" | 33 #include "chrome/browser/prefs/pref_service.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/renderer_host/web_cache_manager.h" | 35 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 37 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 36 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 38 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
| 39 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/logging_chrome.h" | 39 #include "chrome/common/logging_chrome.h" |
| 41 #include "chrome/common/pref_names.h" | 40 #include "chrome/common/pref_names.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // for the view host which may not be sure in some cases | 250 // for the view host which may not be sure in some cases |
| 252 if (channel_.get()) | 251 if (channel_.get()) |
| 253 return true; | 252 return true; |
| 254 | 253 |
| 255 accessibility_enabled_ = is_accessibility_enabled; | 254 accessibility_enabled_ = is_accessibility_enabled; |
| 256 | 255 |
| 257 // It is possible for an extension process to be reused for non-extension | 256 // It is possible for an extension process to be reused for non-extension |
| 258 // content, e.g. if an extension calls window.open. | 257 // content, e.g. if an extension calls window.open. |
| 259 extension_process_ = extension_process_ || is_extensions_process; | 258 extension_process_ = extension_process_ || is_extensions_process; |
| 260 | 259 |
| 261 // run the IPC channel on the shared IO thread. | |
| 262 base::Thread* io_thread = g_browser_process->io_thread(); | |
| 263 | |
| 264 CommandLine::StringType renderer_prefix; | 260 CommandLine::StringType renderer_prefix; |
| 265 #if defined(OS_POSIX) | 261 #if defined(OS_POSIX) |
| 266 // A command prefix is something prepended to the command line of the spawned | 262 // A command prefix is something prepended to the command line of the spawned |
| 267 // process. It is supported only on POSIX systems. | 263 // process. It is supported only on POSIX systems. |
| 268 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 264 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 269 renderer_prefix = | 265 renderer_prefix = |
| 270 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); | 266 browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); |
| 271 #endif // defined(OS_POSIX) | 267 #endif // defined(OS_POSIX) |
| 272 | 268 |
| 273 // Find the renderer before creating the channel so if this fails early we | 269 // Find the renderer before creating the channel so if this fails early we |
| 274 // return without creating the channel. | 270 // return without creating the channel. |
| 275 FilePath renderer_path = | 271 FilePath renderer_path = |
| 276 ChildProcessHost::GetChildPath(renderer_prefix.empty()); | 272 ChildProcessHost::GetChildPath(renderer_prefix.empty()); |
| 277 if (renderer_path.empty()) | 273 if (renderer_path.empty()) |
| 278 return false; | 274 return false; |
| 279 | 275 |
| 280 // Setup the IPC channel. | 276 // Setup the IPC channel. |
| 281 const std::string channel_id = | 277 const std::string channel_id = |
| 282 ChildProcessInfo::GenerateRandomChannelID(this); | 278 ChildProcessInfo::GenerateRandomChannelID(this); |
| 283 channel_.reset( | 279 channel_.reset(new IPC::SyncChannel( |
| 284 new IPC::SyncChannel(channel_id, IPC::Channel::MODE_SERVER, this, | 280 channel_id, IPC::Channel::MODE_SERVER, this, |
| 285 io_thread->message_loop(), true, | 281 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), true, |
| 286 g_browser_process->shutdown_event())); | 282 g_browser_process->shutdown_event())); |
| 287 // As a preventive mesure, we DCHECK if someone sends a synchronous message | 283 // As a preventive mesure, we DCHECK if someone sends a synchronous message |
| 288 // with no time-out, which in the context of the browser process we should not | 284 // with no time-out, which in the context of the browser process we should not |
| 289 // be doing. | 285 // be doing. |
| 290 channel_->set_sync_messages_with_no_timeout_allowed(false); | 286 channel_->set_sync_messages_with_no_timeout_allowed(false); |
| 291 | 287 |
| 292 CreateMessageFilters(); | 288 CreateMessageFilters(); |
| 293 | 289 |
| 294 content::GetContentClient()->browser()->BrowserRenderProcessHostCreated(this); | 290 content::GetContentClient()->browser()->BrowserRenderProcessHostCreated(this); |
| 295 | 291 |
| 296 if (run_renderer_in_process()) { | 292 if (run_renderer_in_process()) { |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 IPC::PlatformFileForTransit file; | 988 IPC::PlatformFileForTransit file; |
| 993 #if defined(OS_POSIX) | 989 #if defined(OS_POSIX) |
| 994 file = base::FileDescriptor(model_file, false); | 990 file = base::FileDescriptor(model_file, false); |
| 995 #elif defined(OS_WIN) | 991 #elif defined(OS_WIN) |
| 996 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, | 992 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, |
| 997 false, DUPLICATE_SAME_ACCESS); | 993 false, DUPLICATE_SAME_ACCESS); |
| 998 #endif | 994 #endif |
| 999 Send(new SafeBrowsingMsg_SetPhishingModel(file)); | 995 Send(new SafeBrowsingMsg_SetPhishingModel(file)); |
| 1000 } | 996 } |
| 1001 } | 997 } |
| OLD | NEW |