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

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

Issue 2434103002: Remove uses of AttachmentBroker from //content and //components/nacl. (Closed)
Patch Set: Created 4 years, 1 month 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
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 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "content/child/resource_dispatcher.h" 49 #include "content/child/resource_dispatcher.h"
50 #include "content/child/service_worker/service_worker_message_filter.h" 50 #include "content/child/service_worker/service_worker_message_filter.h"
51 #include "content/child/thread_safe_sender.h" 51 #include "content/child/thread_safe_sender.h"
52 #include "content/common/child_process_messages.h" 52 #include "content/common/child_process_messages.h"
53 #include "content/common/in_process_child_thread_params.h" 53 #include "content/common/in_process_child_thread_params.h"
54 #include "content/public/common/connection_filter.h" 54 #include "content/public/common/connection_filter.h"
55 #include "content/public/common/content_switches.h" 55 #include "content/public/common/content_switches.h"
56 #include "content/public/common/mojo_channel_switches.h" 56 #include "content/public/common/mojo_channel_switches.h"
57 #include "content/public/common/service_manager_connection.h" 57 #include "content/public/common/service_manager_connection.h"
58 #include "content/public/common/service_names.h" 58 #include "content/public/common/service_names.h"
59 #include "ipc/attachment_broker.h"
60 #include "ipc/attachment_broker_unprivileged.h"
61 #include "ipc/ipc_channel_mojo.h" 59 #include "ipc/ipc_channel_mojo.h"
62 #include "ipc/ipc_logging.h" 60 #include "ipc/ipc_logging.h"
63 #include "ipc/ipc_platform_file.h" 61 #include "ipc/ipc_platform_file.h"
64 #include "ipc/ipc_sync_channel.h" 62 #include "ipc/ipc_sync_channel.h"
65 #include "ipc/ipc_sync_message_filter.h" 63 #include "ipc/ipc_sync_message_filter.h"
66 #include "mojo/edk/embedder/embedder.h" 64 #include "mojo/edk/embedder/embedder.h"
67 #include "mojo/edk/embedder/named_platform_channel_pair.h" 65 #include "mojo/edk/embedder/named_platform_channel_pair.h"
68 #include "mojo/edk/embedder/platform_channel_pair.h" 66 #include "mojo/edk/embedder/platform_channel_pair.h"
69 #include "mojo/edk/embedder/scoped_ipc_support.h" 67 #include "mojo/edk/embedder/scoped_ipc_support.h"
70 #include "services/service_manager/public/cpp/connector.h" 68 #include "services/service_manager/public/cpp/connector.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 g_lazy_tls.Pointer()->Set(this); 415 g_lazy_tls.Pointer()->Set(this);
418 on_channel_error_called_ = false; 416 on_channel_error_called_ = false;
419 message_loop_ = base::MessageLoop::current(); 417 message_loop_ = base::MessageLoop::current();
420 #ifdef IPC_MESSAGE_LOG_ENABLED 418 #ifdef IPC_MESSAGE_LOG_ENABLED
421 // We must make sure to instantiate the IPC Logger *before* we create the 419 // We must make sure to instantiate the IPC Logger *before* we create the
422 // channel, otherwise we can get a callback on the IO thread which creates 420 // channel, otherwise we can get a callback on the IO thread which creates
423 // the logger, and the logger does not like being created on the IO thread. 421 // the logger, and the logger does not like being created on the IO thread.
424 IPC::Logging::GetInstance(); 422 IPC::Logging::GetInstance();
425 #endif 423 #endif
426 424
427 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
428
429 channel_ = 425 channel_ =
430 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), 426 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(),
431 ChildProcess::current()->GetShutDownEvent()); 427 ChildProcess::current()->GetShutDownEvent());
432 #ifdef IPC_MESSAGE_LOG_ENABLED 428 #ifdef IPC_MESSAGE_LOG_ENABLED
433 if (!IsInBrowserProcess()) 429 if (!IsInBrowserProcess())
434 IPC::Logging::GetInstance()->SetIPCSender(this); 430 IPC::Logging::GetInstance()->SetIPCSender(this);
435 #endif 431 #endif
436 432
437 if (!IsInBrowserProcess()) { 433 if (!IsInBrowserProcess()) {
438 // Don't double-initialize IPC support in single-process mode. 434 // Don't double-initialize IPC support in single-process mode.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // and single-process mode. 524 // and single-process mode.
529 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType)) 525 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessType))
530 channel_->AddFilter(new SuicideOnChannelErrorFilter()); 526 channel_->AddFilter(new SuicideOnChannelErrorFilter());
531 #endif 527 #endif
532 528
533 // Add filters passed here via options. 529 // Add filters passed here via options.
534 for (auto* startup_filter : options.startup_filters) { 530 for (auto* startup_filter : options.startup_filters) {
535 channel_->AddFilter(startup_filter); 531 channel_->AddFilter(startup_filter);
536 } 532 }
537 533
538 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
539 if (broker && !broker->IsPrivilegedBroker())
540 broker->RegisterBrokerCommunicationChannel(channel_.get());
541
542 channel_->AddAssociatedInterface( 534 channel_->AddAssociatedInterface(
543 base::Bind(&ChildThreadImpl::OnRouteProviderRequest, 535 base::Bind(&ChildThreadImpl::OnRouteProviderRequest,
544 base::Unretained(this))); 536 base::Unretained(this)));
545 537
546 ConnectChannel(); 538 ConnectChannel();
547 539
548 // This must always be done after ConnectChannel, because ConnectChannel() may 540 // This must always be done after ConnectChannel, because ConnectChannel() may
549 // add a ConnectionFilter to the connection. 541 // add a ConnectionFilter to the connection.
550 if (options.auto_start_service_manager_connection && 542 if (options.auto_start_service_manager_connection &&
551 service_manager_connection_) { 543 service_manager_connection_) {
(...skipping 24 matching lines...) Expand all
576 568
577 discardable_shared_memory_manager_.reset( 569 discardable_shared_memory_manager_.reset(
578 new ChildDiscardableSharedMemoryManager(thread_safe_sender())); 570 new ChildDiscardableSharedMemoryManager(thread_safe_sender()));
579 } 571 }
580 572
581 ChildThreadImpl::~ChildThreadImpl() { 573 ChildThreadImpl::~ChildThreadImpl() {
582 #ifdef IPC_MESSAGE_LOG_ENABLED 574 #ifdef IPC_MESSAGE_LOG_ENABLED
583 IPC::Logging::GetInstance()->SetIPCSender(NULL); 575 IPC::Logging::GetInstance()->SetIPCSender(NULL);
584 #endif 576 #endif
585 577
586 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
587 if (broker && !broker->IsPrivilegedBroker())
588 broker->DeregisterBrokerCommunicationChannel(channel_.get());
589
590 channel_->RemoveFilter(histogram_message_filter_.get()); 578 channel_->RemoveFilter(histogram_message_filter_.get());
591 channel_->RemoveFilter(sync_message_filter_.get()); 579 channel_->RemoveFilter(sync_message_filter_.get());
592 580
593 // The ChannelProxy object caches a pointer to the IPC thread, so need to 581 // The ChannelProxy object caches a pointer to the IPC thread, so need to
594 // reset it as it's not guaranteed to outlive this object. 582 // reset it as it's not guaranteed to outlive this object.
595 // NOTE: this also has the side-effect of not closing the main IPC channel to 583 // NOTE: this also has the side-effect of not closing the main IPC channel to
596 // the browser process. This is needed because this is the signal that the 584 // the browser process. This is needed because this is the signal that the
597 // browser uses to know that this process has died, so we need it to be alive 585 // browser uses to know that this process has died, so we need it to be alive
598 // until this process is shut down, and the OS closes the handle 586 // until this process is shut down, and the OS closes the handle
599 // automatically. We used to watch the object handle on Windows to do this, 587 // automatically. We used to watch the object handle on Windows to do this,
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 Listener* route = router_.GetRoute(routing_id); 852 Listener* route = router_.GetRoute(routing_id);
865 if (route) 853 if (route)
866 route->OnAssociatedInterfaceRequest(name, request.PassHandle()); 854 route->OnAssociatedInterfaceRequest(name, request.PassHandle());
867 } 855 }
868 856
869 bool ChildThreadImpl::IsInBrowserProcess() const { 857 bool ChildThreadImpl::IsInBrowserProcess() const {
870 return static_cast<bool>(browser_process_io_runner_); 858 return static_cast<bool>(browser_process_io_runner_);
871 } 859 }
872 860
873 } // namespace content 861 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/common/child_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698