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_impl.h" | 5 #include "content/child/child_thread_impl.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 | 238 |
239 void ChildThreadImpl::SingleProcessChannelDelegateDeleter::operator()( | 239 void ChildThreadImpl::SingleProcessChannelDelegateDeleter::operator()( |
240 SingleProcessChannelDelegate* delegate) const { | 240 SingleProcessChannelDelegate* delegate) const { |
241 delegate->DeleteSoon(); | 241 delegate->DeleteSoon(); |
242 } | 242 } |
243 | 243 |
244 ChildThreadImpl::Options::Options() | 244 ChildThreadImpl::Options::Options() |
245 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 245 : channel_name(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
246 switches::kProcessChannelID)), | 246 switches::kProcessChannelID)), |
247 use_mojo_channel(false), | 247 use_mojo_channel(false), |
248 in_browser_process(false) { | 248 in_browser_process(false), |
249 task_runner(base::MessageLoopProxy::current()) { | |
249 } | 250 } |
250 | 251 |
251 ChildThreadImpl::Options::~Options() { | 252 ChildThreadImpl::Options::~Options() { |
252 } | 253 } |
253 | 254 |
254 ChildThreadImpl::Options::Builder::Builder() { | 255 ChildThreadImpl::Options::Builder::Builder() { |
255 } | 256 } |
256 | 257 |
257 ChildThreadImpl::Options::Builder& | 258 ChildThreadImpl::Options::Builder& |
258 ChildThreadImpl::Options::Builder::InBrowserProcess(bool in_browser_process) { | 259 ChildThreadImpl::Options::Builder::InBrowserProcess(bool in_browser_process) { |
(...skipping 14 matching lines...) Expand all Loading... | |
273 return *this; | 274 return *this; |
274 } | 275 } |
275 | 276 |
276 ChildThreadImpl::Options::Builder& | 277 ChildThreadImpl::Options::Builder& |
277 ChildThreadImpl::Options::Builder::AddStartupFilter( | 278 ChildThreadImpl::Options::Builder::AddStartupFilter( |
278 IPC::MessageFilter* filter) { | 279 IPC::MessageFilter* filter) { |
279 options_.startup_filters.push_back(filter); | 280 options_.startup_filters.push_back(filter); |
280 return *this; | 281 return *this; |
281 } | 282 } |
282 | 283 |
284 ChildThreadImpl::Options::Builder& | |
285 ChildThreadImpl::Options::Builder::WithTaskRunner( | |
286 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | |
287 options_.task_runner = task_runner; | |
288 return *this; | |
289 } | |
290 | |
283 ChildThreadImpl::Options ChildThreadImpl::Options::Builder::Build() { | 291 ChildThreadImpl::Options ChildThreadImpl::Options::Builder::Build() { |
284 return options_; | 292 return options_; |
285 } | 293 } |
286 | 294 |
287 ChildThreadImpl::ChildThreadMessageRouter::ChildThreadMessageRouter( | 295 ChildThreadImpl::ChildThreadMessageRouter::ChildThreadMessageRouter( |
288 IPC::Sender* sender) | 296 IPC::Sender* sender) |
289 : sender_(sender) {} | 297 : sender_(sender) {} |
290 | 298 |
291 bool ChildThreadImpl::ChildThreadMessageRouter::Send(IPC::Message* msg) { | 299 bool ChildThreadImpl::ChildThreadMessageRouter::Send(IPC::Message* msg) { |
292 return sender_->Send(msg); | 300 return sender_->Send(msg); |
293 } | 301 } |
294 | 302 |
295 ChildThreadImpl::ChildThreadImpl() | 303 ChildThreadImpl::ChildThreadImpl() |
296 : router_(this), | 304 : ChildThreadImpl(Options::Builder().Build()) { |
Sami
2015/03/06 17:01:34
So turns out this was triggering an MSVC compiler
| |
297 in_browser_process_(false), | |
298 channel_connected_factory_(this) { | |
299 Init(Options::Builder().Build()); | |
300 } | 305 } |
301 | 306 |
302 ChildThreadImpl::ChildThreadImpl(const Options& options) | 307 ChildThreadImpl::ChildThreadImpl(const Options& options) |
303 : router_(this), | 308 : router_(this), |
309 task_runner_(options.task_runner), | |
304 in_browser_process_(options.in_browser_process), | 310 in_browser_process_(options.in_browser_process), |
305 channel_connected_factory_(this) { | 311 channel_connected_factory_(this) { |
306 Init(options); | 312 Init(options); |
307 } | 313 } |
308 | 314 |
309 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) { | 315 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) { |
310 bool create_pipe_now = true; | 316 bool create_pipe_now = true; |
311 if (use_mojo_channel) { | 317 if (use_mojo_channel) { |
312 VLOG(1) << "Mojo is enabled on child"; | 318 VLOG(1) << "Mojo is enabled on child"; |
313 scoped_refptr<base::TaskRunner> io_task_runner = | 319 scoped_refptr<base::TaskRunner> io_task_runner = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 IPC::Logging::GetInstance()->SetIPCSender(this); | 357 IPC::Logging::GetInstance()->SetIPCSender(this); |
352 #endif | 358 #endif |
353 | 359 |
354 mojo_application_.reset(new MojoApplication); | 360 mojo_application_.reset(new MojoApplication); |
355 | 361 |
356 sync_message_filter_ = | 362 sync_message_filter_ = |
357 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); | 363 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); |
358 thread_safe_sender_ = new ThreadSafeSender( | 364 thread_safe_sender_ = new ThreadSafeSender( |
359 base::MessageLoopProxy::current().get(), sync_message_filter_.get()); | 365 base::MessageLoopProxy::current().get(), sync_message_filter_.get()); |
360 | 366 |
361 resource_dispatcher_.reset(new ResourceDispatcher( | 367 resource_dispatcher_.reset(new ResourceDispatcher(this, GetTaskRunner())); |
362 this, message_loop()->task_runner())); | |
363 websocket_dispatcher_.reset(new WebSocketDispatcher); | 368 websocket_dispatcher_.reset(new WebSocketDispatcher); |
364 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 369 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
365 | 370 |
366 histogram_message_filter_ = new ChildHistogramMessageFilter(); | 371 histogram_message_filter_ = new ChildHistogramMessageFilter(); |
367 resource_message_filter_ = | 372 resource_message_filter_ = |
368 new ChildResourceMessageFilter(resource_dispatcher()); | 373 new ChildResourceMessageFilter(resource_dispatcher()); |
369 | 374 |
370 service_worker_message_filter_ = | 375 service_worker_message_filter_ = |
371 new ServiceWorkerMessageFilter(thread_safe_sender_.get()); | 376 new ServiceWorkerMessageFilter(thread_safe_sender_.get()); |
372 | 377 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 bool ChildThreadImpl::Send(IPC::Message* msg) { | 522 bool ChildThreadImpl::Send(IPC::Message* msg) { |
518 DCHECK(base::MessageLoop::current() == message_loop()); | 523 DCHECK(base::MessageLoop::current() == message_loop()); |
519 if (!channel_) { | 524 if (!channel_) { |
520 delete msg; | 525 delete msg; |
521 return false; | 526 return false; |
522 } | 527 } |
523 | 528 |
524 return channel_->Send(msg); | 529 return channel_->Send(msg); |
525 } | 530 } |
526 | 531 |
532 scoped_refptr<base::SingleThreadTaskRunner> ChildThreadImpl::GetTaskRunner() { | |
533 return task_runner_; | |
534 } | |
535 | |
527 #if defined(OS_WIN) | 536 #if defined(OS_WIN) |
528 void ChildThreadImpl::PreCacheFont(const LOGFONT& log_font) { | 537 void ChildThreadImpl::PreCacheFont(const LOGFONT& log_font) { |
529 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); | 538 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); |
530 } | 539 } |
531 | 540 |
532 void ChildThreadImpl::ReleaseCachedFonts() { | 541 void ChildThreadImpl::ReleaseCachedFonts() { |
533 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); | 542 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); |
534 } | 543 } |
535 #endif | 544 #endif |
536 | 545 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
735 // doesn't cause such issues. TODO(gab): Remove this once the experiment is | 744 // doesn't cause such issues. TODO(gab): Remove this once the experiment is |
736 // over (http://crbug.com/458594). | 745 // over (http://crbug.com/458594). |
737 base::FieldTrial* trial = | 746 base::FieldTrial* trial = |
738 base::FieldTrialList::Find("BackgroundRendererProcesses"); | 747 base::FieldTrialList::Find("BackgroundRendererProcesses"); |
739 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer") | 748 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer") |
740 base::Process::Current().SetProcessBackgrounded(background); | 749 base::Process::Current().SetProcessBackgrounded(background); |
741 #endif // OS_WIN | 750 #endif // OS_WIN |
742 } | 751 } |
743 | 752 |
744 } // namespace content | 753 } // namespace content |
OLD | NEW |