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/ipc_logging.h" | 11 #include "chrome/common/ipc_logging.h" |
12 #include "chrome/common/notification_service.h" | 12 #include "chrome/common/notification_service.h" |
13 #include "chrome/common/plugin_messages.h" | 13 #include "chrome/common/plugin_messages.h" |
14 #include "webkit/glue/webkit_glue.h" | 14 #include "webkit/glue/webkit_glue.h" |
15 | 15 |
16 | 16 |
17 ChildThread::ChildThread() | 17 ChildThread::ChildThread() { |
18 : check_with_browser_before_shutdown_(false), | |
19 message_loop_(MessageLoop::current()) { | |
20 channel_name_ = WideToASCII( | 18 channel_name_ = WideToASCII( |
21 CommandLine::ForCurrentProcess()->GetSwitchValue( | 19 CommandLine::ForCurrentProcess()->GetSwitchValue( |
22 switches::kProcessChannelID)); | 20 switches::kProcessChannelID)); |
| 21 Init(); |
| 22 } |
23 | 23 |
| 24 ChildThread::ChildThread(const std::string channel_name) |
| 25 : channel_name_(channel_name) { |
| 26 Init(); |
| 27 } |
| 28 |
| 29 void ChildThread::Init() { |
| 30 check_with_browser_before_shutdown_ = false; |
| 31 message_loop_ = MessageLoop::current(); |
24 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) { | 32 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) { |
25 webkit_glue::SetUserAgent(WideToUTF8( | 33 webkit_glue::SetUserAgent(WideToUTF8( |
26 CommandLine::ForCurrentProcess()->GetSwitchValue( | 34 CommandLine::ForCurrentProcess()->GetSwitchValue( |
27 switches::kUserAgent))); | 35 switches::kUserAgent))); |
28 } | 36 } |
29 | 37 |
30 channel_.reset(new IPC::SyncChannel(channel_name_, | 38 channel_.reset(new IPC::SyncChannel(channel_name_, |
31 IPC::Channel::MODE_CLIENT, this, NULL, | 39 IPC::Channel::MODE_CLIENT, this, NULL, |
32 ChildProcess::current()->io_message_loop(), true, | 40 ChildProcess::current()->io_message_loop(), true, |
33 ChildProcess::current()->GetShutDownEvent())); | 41 ChildProcess::current()->GetShutDownEvent())); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 MessageLoop::current()->Quit(); | 123 MessageLoop::current()->Quit(); |
116 return; | 124 return; |
117 } | 125 } |
118 | 126 |
119 // The child process shutdown sequence is a request response based mechanism, | 127 // The child process shutdown sequence is a request response based mechanism, |
120 // where we send out an initial feeler request to the child process host | 128 // where we send out an initial feeler request to the child process host |
121 // instance in the browser to verify if it's ok to shutdown the child process. | 129 // instance in the browser to verify if it's ok to shutdown the child process. |
122 // The browser then sends back a response if it's ok to shutdown. | 130 // The browser then sends back a response if it's ok to shutdown. |
123 Send(new PluginProcessHostMsg_ShutdownRequest); | 131 Send(new PluginProcessHostMsg_ShutdownRequest); |
124 } | 132 } |
OLD | NEW |