OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/child/child_thread.h" | 5 #include "content/child/child_thread.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 g_lazy_child_thread_cv = LAZY_INSTANCE_INITIALIZER; | 185 g_lazy_child_thread_cv = LAZY_INSTANCE_INITIALIZER; |
186 | 186 |
187 void QuitMainThreadMessageLoop() { | 187 void QuitMainThreadMessageLoop() { |
188 base::MessageLoop::current()->Quit(); | 188 base::MessageLoop::current()->Quit(); |
189 } | 189 } |
190 | 190 |
191 #endif | 191 #endif |
192 | 192 |
193 } // namespace | 193 } // namespace |
194 | 194 |
| 195 ChildThread::ChildThreadMessageRouter::ChildThreadMessageRouter( |
| 196 IPC::Sender* sender) |
| 197 : sender_(sender) {} |
| 198 |
| 199 bool ChildThread::ChildThreadMessageRouter::Send(IPC::Message* msg) { |
| 200 return sender_->Send(msg); |
| 201 } |
| 202 |
195 ChildThread::ChildThread() | 203 ChildThread::ChildThread() |
196 : channel_connected_factory_(this), | 204 : router_(this), |
| 205 channel_connected_factory_(this), |
197 in_browser_process_(false) { | 206 in_browser_process_(false) { |
198 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 207 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
199 switches::kProcessChannelID); | 208 switches::kProcessChannelID); |
200 Init(); | 209 Init(); |
201 } | 210 } |
202 | 211 |
203 ChildThread::ChildThread(const std::string& channel_name) | 212 ChildThread::ChildThread(const std::string& channel_name) |
204 : channel_name_(channel_name), | 213 : channel_name_(channel_name), |
| 214 router_(this), |
205 channel_connected_factory_(this), | 215 channel_connected_factory_(this), |
206 in_browser_process_(true) { | 216 in_browser_process_(true) { |
207 Init(); | 217 Init(); |
208 } | 218 } |
209 | 219 |
210 void ChildThread::Init() { | 220 void ChildThread::Init() { |
211 g_lazy_tls.Pointer()->Set(this); | 221 g_lazy_tls.Pointer()->Set(this); |
212 on_channel_error_called_ = false; | 222 on_channel_error_called_ = false; |
213 message_loop_ = base::MessageLoop::current(); | 223 message_loop_ = base::MessageLoop::current(); |
214 #ifdef IPC_MESSAGE_LOG_ENABLED | 224 #ifdef IPC_MESSAGE_LOG_ENABLED |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 bool ChildThread::Send(IPC::Message* msg) { | 352 bool ChildThread::Send(IPC::Message* msg) { |
343 DCHECK(base::MessageLoop::current() == message_loop()); | 353 DCHECK(base::MessageLoop::current() == message_loop()); |
344 if (!channel_) { | 354 if (!channel_) { |
345 delete msg; | 355 delete msg; |
346 return false; | 356 return false; |
347 } | 357 } |
348 | 358 |
349 return channel_->Send(msg); | 359 return channel_->Send(msg); |
350 } | 360 } |
351 | 361 |
352 void ChildThread::AddRoute(int32 routing_id, IPC::Listener* listener) { | 362 MessageRouter* ChildThread::GetRouter() { |
353 DCHECK(base::MessageLoop::current() == message_loop()); | 363 DCHECK(base::MessageLoop::current() == message_loop()); |
354 | 364 return &router_; |
355 router_.AddRoute(routing_id, listener); | |
356 } | |
357 | |
358 void ChildThread::RemoveRoute(int32 routing_id) { | |
359 DCHECK(base::MessageLoop::current() == message_loop()); | |
360 | |
361 router_.RemoveRoute(routing_id); | |
362 } | 365 } |
363 | 366 |
364 webkit_glue::ResourceLoaderBridge* ChildThread::CreateBridge( | 367 webkit_glue::ResourceLoaderBridge* ChildThread::CreateBridge( |
365 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { | 368 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { |
366 return resource_dispatcher()->CreateBridge(request_info); | 369 return resource_dispatcher()->CreateBridge(request_info); |
367 } | 370 } |
368 | 371 |
369 base::SharedMemory* ChildThread::AllocateSharedMemory(size_t buf_size) { | 372 base::SharedMemory* ChildThread::AllocateSharedMemory(size_t buf_size) { |
370 return AllocateSharedMemory(buf_size, this); | 373 return AllocateSharedMemory(buf_size, this); |
371 } | 374 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // inflight that would addref it. | 535 // inflight that would addref it. |
533 Send(new ChildProcessHostMsg_ShutdownRequest); | 536 Send(new ChildProcessHostMsg_ShutdownRequest); |
534 } | 537 } |
535 | 538 |
536 void ChildThread::EnsureConnected() { | 539 void ChildThread::EnsureConnected() { |
537 VLOG(0) << "ChildThread::EnsureConnected()"; | 540 VLOG(0) << "ChildThread::EnsureConnected()"; |
538 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 541 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
539 } | 542 } |
540 | 543 |
541 } // namespace content | 544 } // namespace content |
OLD | NEW |