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

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

Issue 1679763002: Clean up public interface of AttachmentBrokerUnprivileged. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove CHECK. Created 4 years, 10 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') | ipc/attachment_broker.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 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 g_lazy_tls.Pointer()->Set(this); 360 g_lazy_tls.Pointer()->Set(this);
361 on_channel_error_called_ = false; 361 on_channel_error_called_ = false;
362 message_loop_ = base::MessageLoop::current(); 362 message_loop_ = base::MessageLoop::current();
363 #ifdef IPC_MESSAGE_LOG_ENABLED 363 #ifdef IPC_MESSAGE_LOG_ENABLED
364 // We must make sure to instantiate the IPC Logger *before* we create the 364 // We must make sure to instantiate the IPC Logger *before* we create the
365 // channel, otherwise we can get a callback on the IO thread which creates 365 // channel, otherwise we can get a callback on the IO thread which creates
366 // the logger, and the logger does not like being created on the IO thread. 366 // the logger, and the logger does not like being created on the IO thread.
367 IPC::Logging::GetInstance(); 367 IPC::Logging::GetInstance();
368 #endif 368 #endif
369 369
370 #if USE_ATTACHMENT_BROKER 370 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded();
371 // The only reason a global would already exist is if the thread is being run
372 // in the browser process because of a command line switch.
373 if (!IPC::AttachmentBroker::GetGlobal()) {
374 attachment_broker_.reset(
375 IPC::AttachmentBrokerUnprivileged::CreateBroker().release());
376 }
377 #endif
378 371
379 channel_ = 372 channel_ =
380 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), 373 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(),
381 ChildProcess::current()->GetShutDownEvent()); 374 ChildProcess::current()->GetShutDownEvent());
382 #ifdef IPC_MESSAGE_LOG_ENABLED 375 #ifdef IPC_MESSAGE_LOG_ENABLED
383 if (!IsInBrowserProcess()) 376 if (!IsInBrowserProcess())
384 IPC::Logging::GetInstance()->SetIPCSender(this); 377 IPC::Logging::GetInstance()->SetIPCSender(this);
385 #endif 378 #endif
386 379
387 if (!IsInBrowserProcess()) { 380 if (!IsInBrowserProcess()) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 #if defined(USE_OZONE) 446 #if defined(USE_OZONE)
454 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); 447 channel_->AddFilter(new ClientNativePixmapFactoryFilter());
455 #endif 448 #endif
456 449
457 // Add filters passed here via options. 450 // Add filters passed here via options.
458 for (auto startup_filter : options.startup_filters) { 451 for (auto startup_filter : options.startup_filters) {
459 channel_->AddFilter(startup_filter); 452 channel_->AddFilter(startup_filter);
460 } 453 }
461 454
462 ConnectChannel(options.use_mojo_channel); 455 ConnectChannel(options.use_mojo_channel);
463 if (attachment_broker_) 456 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
464 attachment_broker_->DesignateBrokerCommunicationChannel(channel_.get()); 457 if (broker && !broker->IsPrivilegedBroker())
458 broker->RegisterBrokerCommunicationChannel(channel_.get());
465 459
466 int connection_timeout = kConnectionTimeoutS; 460 int connection_timeout = kConnectionTimeoutS;
467 std::string connection_override = 461 std::string connection_override =
468 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 462 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
469 switches::kIPCConnectionTimeout); 463 switches::kIPCConnectionTimeout);
470 if (!connection_override.empty()) { 464 if (!connection_override.empty()) {
471 int temp; 465 int temp;
472 if (base::StringToInt(connection_override, &temp)) 466 if (base::StringToInt(connection_override, &temp))
473 connection_timeout = temp; 467 connection_timeout = temp;
474 } 468 }
(...skipping 15 matching lines...) Expand all
490 484
491 discardable_shared_memory_manager_.reset( 485 discardable_shared_memory_manager_.reset(
492 new ChildDiscardableSharedMemoryManager(thread_safe_sender())); 486 new ChildDiscardableSharedMemoryManager(thread_safe_sender()));
493 } 487 }
494 488
495 ChildThreadImpl::~ChildThreadImpl() { 489 ChildThreadImpl::~ChildThreadImpl() {
496 #ifdef IPC_MESSAGE_LOG_ENABLED 490 #ifdef IPC_MESSAGE_LOG_ENABLED
497 IPC::Logging::GetInstance()->SetIPCSender(NULL); 491 IPC::Logging::GetInstance()->SetIPCSender(NULL);
498 #endif 492 #endif
499 493
494 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
495 if (broker && !broker->IsPrivilegedBroker())
496 broker->DeregisterBrokerCommunicationChannel(channel_.get());
497
500 channel_->RemoveFilter(histogram_message_filter_.get()); 498 channel_->RemoveFilter(histogram_message_filter_.get());
501 channel_->RemoveFilter(sync_message_filter_.get()); 499 channel_->RemoveFilter(sync_message_filter_.get());
502 500
503 // The ChannelProxy object caches a pointer to the IPC thread, so need to 501 // The ChannelProxy object caches a pointer to the IPC thread, so need to
504 // reset it as it's not guaranteed to outlive this object. 502 // reset it as it's not guaranteed to outlive this object.
505 // NOTE: this also has the side-effect of not closing the main IPC channel to 503 // NOTE: this also has the side-effect of not closing the main IPC channel to
506 // the browser process. This is needed because this is the signal that the 504 // the browser process. This is needed because this is the signal that the
507 // browser uses to know that this process has died, so we need it to be alive 505 // browser uses to know that this process has died, so we need it to be alive
508 // until this process is shut down, and the OS closes the handle 506 // until this process is shut down, and the OS closes the handle
509 // automatically. We used to watch the object handle on Windows to do this, 507 // automatically. We used to watch the object handle on Windows to do this,
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 void ChildThreadImpl::EnsureConnected() { 729 void ChildThreadImpl::EnsureConnected() {
732 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 730 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
733 base::Process::Current().Terminate(0, false); 731 base::Process::Current().Terminate(0, false);
734 } 732 }
735 733
736 bool ChildThreadImpl::IsInBrowserProcess() const { 734 bool ChildThreadImpl::IsInBrowserProcess() const {
737 return browser_process_io_runner_; 735 return browser_process_io_runner_;
738 } 736 }
739 737
740 } // namespace content 738 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | ipc/attachment_broker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698