Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: content/child/child_thread_impl.cc

Issue 1292263003: ipc: Use a global for the process's attachment broker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ipc_message2
Patch Set: Comments from avi. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/child/npapi/np_channel_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 return browser_process_io_runner_; 350 return browser_process_io_runner_;
351 return ChildProcess::current()->io_task_runner(); 351 return ChildProcess::current()->io_task_runner();
352 } 352 }
353 353
354 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) { 354 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel) {
355 bool create_pipe_now = true; 355 bool create_pipe_now = true;
356 if (use_mojo_channel) { 356 if (use_mojo_channel) {
357 VLOG(1) << "Mojo is enabled on child"; 357 VLOG(1) << "Mojo is enabled on child";
358 scoped_refptr<base::SequencedTaskRunner> io_task_runner = GetIOTaskRunner(); 358 scoped_refptr<base::SequencedTaskRunner> io_task_runner = GetIOTaskRunner();
359 DCHECK(io_task_runner); 359 DCHECK(io_task_runner);
360 channel_->Init(IPC::ChannelMojo::CreateClientFactory( 360 channel_->Init(
361 io_task_runner, channel_name_, attachment_broker_.get()), 361 IPC::ChannelMojo::CreateClientFactory(io_task_runner, channel_name_),
362 create_pipe_now); 362 create_pipe_now);
363 return; 363 return;
364 } 364 }
365 365
366 VLOG(1) << "Mojo is disabled on child"; 366 VLOG(1) << "Mojo is disabled on child";
367 channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now, 367 channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now);
368 attachment_broker_.get());
369 } 368 }
370 369
371 void ChildThreadImpl::Init(const Options& options) { 370 void ChildThreadImpl::Init(const Options& options) {
372 channel_name_ = options.channel_name; 371 channel_name_ = options.channel_name;
373 372
374 g_lazy_tls.Pointer()->Set(this); 373 g_lazy_tls.Pointer()->Set(this);
375 on_channel_error_called_ = false; 374 on_channel_error_called_ = false;
376 message_loop_ = base::MessageLoop::current(); 375 message_loop_ = base::MessageLoop::current();
377 #ifdef IPC_MESSAGE_LOG_ENABLED 376 #ifdef IPC_MESSAGE_LOG_ENABLED
378 // We must make sure to instantiate the IPC Logger *before* we create the 377 // We must make sure to instantiate the IPC Logger *before* we create the
379 // channel, otherwise we can get a callback on the IO thread which creates 378 // channel, otherwise we can get a callback on the IO thread which creates
380 // the logger, and the logger does not like being created on the IO thread. 379 // the logger, and the logger does not like being created on the IO thread.
381 IPC::Logging::GetInstance(); 380 IPC::Logging::GetInstance();
382 #endif 381 #endif
382
383 #if defined(OS_WIN)
384 // The only reason a global would already exist is if the thread is being run
385 // in the browser process because of a command line switch.
386 if (!IPC::AttachmentBroker::GetGlobal()) {
387 attachment_broker_.reset(new IPC::AttachmentBrokerUnprivilegedWin());
388 IPC::AttachmentBroker::SetGlobal(attachment_broker_.get());
389 }
390 #endif
391
383 channel_ = 392 channel_ =
384 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), 393 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(),
385 ChildProcess::current()->GetShutDownEvent()); 394 ChildProcess::current()->GetShutDownEvent());
386 #ifdef IPC_MESSAGE_LOG_ENABLED 395 #ifdef IPC_MESSAGE_LOG_ENABLED
387 if (!IsInBrowserProcess()) 396 if (!IsInBrowserProcess())
388 IPC::Logging::GetInstance()->SetIPCSender(this); 397 IPC::Logging::GetInstance()->SetIPCSender(this);
389 #endif 398 #endif
390 399
391 #if defined(OS_WIN)
392 attachment_broker_.reset(new IPC::AttachmentBrokerUnprivilegedWin());
393 #endif
394
395 mojo_application_.reset(new MojoApplication(GetIOTaskRunner())); 400 mojo_application_.reset(new MojoApplication(GetIOTaskRunner()));
396 401
397 sync_message_filter_ = channel_->CreateSyncMessageFilter(); 402 sync_message_filter_ = channel_->CreateSyncMessageFilter();
398 thread_safe_sender_ = new ThreadSafeSender( 403 thread_safe_sender_ = new ThreadSafeSender(
399 message_loop_->task_runner(), sync_message_filter_.get()); 404 message_loop_->task_runner(), sync_message_filter_.get());
400 405
401 resource_dispatcher_.reset(new ResourceDispatcher( 406 resource_dispatcher_.reset(new ResourceDispatcher(
402 this, message_loop()->task_runner())); 407 this, message_loop()->task_runner()));
403 websocket_dispatcher_.reset(new WebSocketDispatcher); 408 websocket_dispatcher_.reset(new WebSocketDispatcher);
404 file_system_dispatcher_.reset(new FileSystemDispatcher()); 409 file_system_dispatcher_.reset(new FileSystemDispatcher());
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 #if defined(OS_WIN) 563 #if defined(OS_WIN)
559 void ChildThreadImpl::PreCacheFont(const LOGFONT& log_font) { 564 void ChildThreadImpl::PreCacheFont(const LOGFONT& log_font) {
560 Send(new ChildProcessHostMsg_PreCacheFont(log_font)); 565 Send(new ChildProcessHostMsg_PreCacheFont(log_font));
561 } 566 }
562 567
563 void ChildThreadImpl::ReleaseCachedFonts() { 568 void ChildThreadImpl::ReleaseCachedFonts() {
564 Send(new ChildProcessHostMsg_ReleaseCachedFonts()); 569 Send(new ChildProcessHostMsg_ReleaseCachedFonts());
565 } 570 }
566 #endif 571 #endif
567 572
568 IPC::AttachmentBroker* ChildThreadImpl::GetAttachmentBroker() {
569 return attachment_broker_.get();
570 }
571
572 MessageRouter* ChildThreadImpl::GetRouter() { 573 MessageRouter* ChildThreadImpl::GetRouter() {
573 DCHECK(base::MessageLoop::current() == message_loop()); 574 DCHECK(base::MessageLoop::current() == message_loop());
574 return &router_; 575 return &router_;
575 } 576 }
576 577
577 scoped_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory( 578 scoped_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory(
578 size_t buf_size) { 579 size_t buf_size) {
579 DCHECK(base::MessageLoop::current() == message_loop()); 580 DCHECK(base::MessageLoop::current() == message_loop());
580 return AllocateSharedMemory(buf_size, this); 581 return AllocateSharedMemory(buf_size, this);
581 } 582 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 void ChildThreadImpl::EnsureConnected() { 738 void ChildThreadImpl::EnsureConnected() {
738 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 739 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
739 base::Process::Current().Terminate(0, false); 740 base::Process::Current().Terminate(0, false);
740 } 741 }
741 742
742 bool ChildThreadImpl::IsInBrowserProcess() const { 743 bool ChildThreadImpl::IsInBrowserProcess() const {
743 return browser_process_io_runner_; 744 return browser_process_io_runner_;
744 } 745 }
745 746
746 } // namespace content 747 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/child/npapi/np_channel_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698