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

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

Issue 1704743002: Revert of Clean up public interface of AttachmentBrokerUnprivileged. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 IPC::AttachmentBrokerUnprivileged::CreateBrokerIfNeeded(); 370 #if USE_ATTACHMENT_BROKER
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
371 378
372 channel_ = 379 channel_ =
373 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(), 380 IPC::SyncChannel::Create(this, ChildProcess::current()->io_task_runner(),
374 ChildProcess::current()->GetShutDownEvent()); 381 ChildProcess::current()->GetShutDownEvent());
375 #ifdef IPC_MESSAGE_LOG_ENABLED 382 #ifdef IPC_MESSAGE_LOG_ENABLED
376 if (!IsInBrowserProcess()) 383 if (!IsInBrowserProcess())
377 IPC::Logging::GetInstance()->SetIPCSender(this); 384 IPC::Logging::GetInstance()->SetIPCSender(this);
378 #endif 385 #endif
379 386
380 if (!IsInBrowserProcess()) { 387 if (!IsInBrowserProcess()) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 #if defined(USE_OZONE) 453 #if defined(USE_OZONE)
447 channel_->AddFilter(new ClientNativePixmapFactoryFilter()); 454 channel_->AddFilter(new ClientNativePixmapFactoryFilter());
448 #endif 455 #endif
449 456
450 // Add filters passed here via options. 457 // Add filters passed here via options.
451 for (auto startup_filter : options.startup_filters) { 458 for (auto startup_filter : options.startup_filters) {
452 channel_->AddFilter(startup_filter); 459 channel_->AddFilter(startup_filter);
453 } 460 }
454 461
455 ConnectChannel(options.use_mojo_channel); 462 ConnectChannel(options.use_mojo_channel);
456 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal(); 463 if (attachment_broker_)
457 if (broker && !broker->IsPrivilegedBroker()) 464 attachment_broker_->DesignateBrokerCommunicationChannel(channel_.get());
458 broker->RegisterBrokerCommunicationChannel(channel_.get());
459 465
460 int connection_timeout = kConnectionTimeoutS; 466 int connection_timeout = kConnectionTimeoutS;
461 std::string connection_override = 467 std::string connection_override =
462 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 468 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
463 switches::kIPCConnectionTimeout); 469 switches::kIPCConnectionTimeout);
464 if (!connection_override.empty()) { 470 if (!connection_override.empty()) {
465 int temp; 471 int temp;
466 if (base::StringToInt(connection_override, &temp)) 472 if (base::StringToInt(connection_override, &temp))
467 connection_timeout = temp; 473 connection_timeout = temp;
468 } 474 }
(...skipping 15 matching lines...) Expand all
484 490
485 discardable_shared_memory_manager_.reset( 491 discardable_shared_memory_manager_.reset(
486 new ChildDiscardableSharedMemoryManager(thread_safe_sender())); 492 new ChildDiscardableSharedMemoryManager(thread_safe_sender()));
487 } 493 }
488 494
489 ChildThreadImpl::~ChildThreadImpl() { 495 ChildThreadImpl::~ChildThreadImpl() {
490 #ifdef IPC_MESSAGE_LOG_ENABLED 496 #ifdef IPC_MESSAGE_LOG_ENABLED
491 IPC::Logging::GetInstance()->SetIPCSender(NULL); 497 IPC::Logging::GetInstance()->SetIPCSender(NULL);
492 #endif 498 #endif
493 499
494 IPC::AttachmentBroker* broker = IPC::AttachmentBroker::GetGlobal();
495 if (broker && !broker->IsPrivilegedBroker())
496 broker->DeregisterBrokerCommunicationChannel(channel_.get());
497
498 channel_->RemoveFilter(histogram_message_filter_.get()); 500 channel_->RemoveFilter(histogram_message_filter_.get());
499 channel_->RemoveFilter(sync_message_filter_.get()); 501 channel_->RemoveFilter(sync_message_filter_.get());
500 502
501 // The ChannelProxy object caches a pointer to the IPC thread, so need to 503 // The ChannelProxy object caches a pointer to the IPC thread, so need to
502 // reset it as it's not guaranteed to outlive this object. 504 // reset it as it's not guaranteed to outlive this object.
503 // NOTE: this also has the side-effect of not closing the main IPC channel to 505 // NOTE: this also has the side-effect of not closing the main IPC channel to
504 // the browser process. This is needed because this is the signal that the 506 // the browser process. This is needed because this is the signal that the
505 // browser uses to know that this process has died, so we need it to be alive 507 // browser uses to know that this process has died, so we need it to be alive
506 // until this process is shut down, and the OS closes the handle 508 // until this process is shut down, and the OS closes the handle
507 // automatically. We used to watch the object handle on Windows to do this, 509 // 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
729 void ChildThreadImpl::EnsureConnected() { 731 void ChildThreadImpl::EnsureConnected() {
730 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 732 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
731 base::Process::Current().Terminate(0, false); 733 base::Process::Current().Terminate(0, false);
732 } 734 }
733 735
734 bool ChildThreadImpl::IsInBrowserProcess() const { 736 bool ChildThreadImpl::IsInBrowserProcess() const {
735 return browser_process_io_runner_; 737 return browser_process_io_runner_;
736 } 738 }
737 739
738 } // namespace content 740 } // 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