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 #include "content/common/child_thread.h" | 5 #include "content/common/child_thread.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "content/common/child_process.h" | 10 #include "content/common/child_process.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 ChildThread::ChildThread(const std::string& channel_name) | 35 ChildThread::ChildThread(const std::string& channel_name) |
36 : channel_name_(channel_name) { | 36 : channel_name_(channel_name) { |
37 Init(); | 37 Init(); |
38 } | 38 } |
39 | 39 |
40 void ChildThread::Init() { | 40 void ChildThread::Init() { |
41 check_with_browser_before_shutdown_ = false; | 41 check_with_browser_before_shutdown_ = false; |
42 on_channel_error_called_ = false; | 42 on_channel_error_called_ = false; |
43 message_loop_ = MessageLoop::current(); | 43 message_loop_ = MessageLoop::current(); |
| 44 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserAgent)) { |
| 45 webkit_glue::SetUserAgent( |
| 46 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 47 switches::kUserAgent)); |
| 48 } |
| 49 |
44 channel_.reset(new IPC::SyncChannel(channel_name_, | 50 channel_.reset(new IPC::SyncChannel(channel_name_, |
45 IPC::Channel::MODE_CLIENT, this, | 51 IPC::Channel::MODE_CLIENT, this, |
46 ChildProcess::current()->io_message_loop_proxy(), true, | 52 ChildProcess::current()->io_message_loop_proxy(), true, |
47 ChildProcess::current()->GetShutDownEvent())); | 53 ChildProcess::current()->GetShutDownEvent())); |
48 #ifdef IPC_MESSAGE_LOG_ENABLED | 54 #ifdef IPC_MESSAGE_LOG_ENABLED |
49 IPC::Logging::GetInstance()->SetIPCSender(this); | 55 IPC::Logging::GetInstance()->SetIPCSender(this); |
50 #endif | 56 #endif |
51 | 57 |
52 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 58 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
53 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 59 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 MessageLoop::current()->Quit(); | 219 MessageLoop::current()->Quit(); |
214 return; | 220 return; |
215 } | 221 } |
216 | 222 |
217 // The child process shutdown sequence is a request response based mechanism, | 223 // The child process shutdown sequence is a request response based mechanism, |
218 // where we send out an initial feeler request to the child process host | 224 // where we send out an initial feeler request to the child process host |
219 // instance in the browser to verify if it's ok to shutdown the child process. | 225 // instance in the browser to verify if it's ok to shutdown the child process. |
220 // The browser then sends back a response if it's ok to shutdown. | 226 // The browser then sends back a response if it's ok to shutdown. |
221 Send(new ChildProcessHostMsg_ShutdownRequest); | 227 Send(new ChildProcessHostMsg_ShutdownRequest); |
222 } | 228 } |
OLD | NEW |