| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/common/child_thread.h" | 5 #include "chrome/common/child_thread.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/common/child_process.h" | 9 #include "chrome/common/child_process.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/notification_service.h" | 11 #include "chrome/common/notification_service.h" |
| 12 #include "chrome/common/plugin_messages.h" | 12 #include "chrome/common/plugin_messages.h" |
| 13 #include "ipc/ipc_logging.h" | 13 #include "ipc/ipc_logging.h" |
| 14 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
| 15 #include "ipc/ipc_switches.h" | 15 #include "ipc/ipc_switches.h" |
| 16 #include "webkit/glue/webkit_glue.h" | 16 #include "webkit/glue/webkit_glue.h" |
| 17 | 17 |
| 18 | 18 |
| 19 ChildThread::ChildThread() { | 19 ChildThread::ChildThread() { |
| 20 channel_name_ = WideToASCII( | 20 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 21 CommandLine::ForCurrentProcess()->GetSwitchValue( | 21 switches::kProcessChannelID); |
| 22 switches::kProcessChannelID)); | |
| 23 Init(); | 22 Init(); |
| 24 } | 23 } |
| 25 | 24 |
| 26 ChildThread::ChildThread(const std::string& channel_name) | 25 ChildThread::ChildThread(const std::string& channel_name) |
| 27 : channel_name_(channel_name) { | 26 : channel_name_(channel_name) { |
| 28 Init(); | 27 Init(); |
| 29 } | 28 } |
| 30 | 29 |
| 31 void ChildThread::Init() { | 30 void ChildThread::Init() { |
| 32 check_with_browser_before_shutdown_ = false; | 31 check_with_browser_before_shutdown_ = false; |
| 33 message_loop_ = MessageLoop::current(); | 32 message_loop_ = MessageLoop::current(); |
| 34 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) { | 33 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) { |
| 35 webkit_glue::SetUserAgent(WideToUTF8( | 34 webkit_glue::SetUserAgent( |
| 36 CommandLine::ForCurrentProcess()->GetSwitchValue( | 35 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 37 switches::kUserAgent))); | 36 switches::kUserAgent)); |
| 38 } | 37 } |
| 39 | 38 |
| 40 channel_.reset(new IPC::SyncChannel(channel_name_, | 39 channel_.reset(new IPC::SyncChannel(channel_name_, |
| 41 IPC::Channel::MODE_CLIENT, this, NULL, | 40 IPC::Channel::MODE_CLIENT, this, NULL, |
| 42 ChildProcess::current()->io_message_loop(), true, | 41 ChildProcess::current()->io_message_loop(), true, |
| 43 ChildProcess::current()->GetShutDownEvent())); | 42 ChildProcess::current()->GetShutDownEvent())); |
| 44 #ifdef IPC_MESSAGE_LOG_ENABLED | 43 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 45 IPC::Logging::current()->SetIPCSender(this); | 44 IPC::Logging::current()->SetIPCSender(this); |
| 46 #endif | 45 #endif |
| 47 | 46 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 MessageLoop::current()->Quit(); | 145 MessageLoop::current()->Quit(); |
| 147 return; | 146 return; |
| 148 } | 147 } |
| 149 | 148 |
| 150 // The child process shutdown sequence is a request response based mechanism, | 149 // The child process shutdown sequence is a request response based mechanism, |
| 151 // where we send out an initial feeler request to the child process host | 150 // where we send out an initial feeler request to the child process host |
| 152 // instance in the browser to verify if it's ok to shutdown the child process. | 151 // instance in the browser to verify if it's ok to shutdown the child process. |
| 153 // The browser then sends back a response if it's ok to shutdown. | 152 // The browser then sends back a response if it's ok to shutdown. |
| 154 Send(new PluginProcessHostMsg_ShutdownRequest); | 153 Send(new PluginProcessHostMsg_ShutdownRequest); |
| 155 } | 154 } |
| OLD | NEW |