Commit ddeb4c0c authored by Peter Collingbourne's avatar Peter Collingbourne Committed by Commit Bot

content: Inline MachBroker::ChildSendTaskPortToParent into callers.

This function lives in //content/browser despite being intended to
be used by child processes. The function body is trivial and can be
inlined into every caller. This lets us remove one dependency from
app to browser.

Bug: 855193
Change-Id: Ia9558b4298275a5638500ebcd65361073be838b9
Reviewed-on: https://chromium-review.googlesource.com/1159394Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Peter Collingbourne <pcc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581342}
parent eea80c5f
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "content/app/mojo/mojo_init.h" #include "content/app/mojo/mojo_init.h"
#include "content/browser/browser_process_sub_thread.h" #include "content/browser/browser_process_sub_thread.h"
#include "content/browser/startup_data_impl.h" #include "content/browser/startup_data_impl.h"
#include "content/common/content_constants_internal.h"
#include "content/common/url_schemes.h" #include "content/common/url_schemes.h"
#include "content/public/app/content_main_delegate.h" #include "content/public/app/content_main_delegate.h"
#include "content/public/common/content_constants.h" #include "content/public/common/content_constants.h"
...@@ -73,8 +74,8 @@ ...@@ -73,8 +74,8 @@
#include "base/trace_event/trace_event_etw_export_win.h" #include "base/trace_event/trace_event_etw_export_win.h"
#include "ui/display/win/dpi.h" #include "ui/display/win/dpi.h"
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
#include "base/mac/mach_port_broker.h"
#include "base/power_monitor/power_monitor_device_source.h" #include "base/power_monitor/power_monitor_device_source.h"
#include "content/browser/mach_broker_mac.h"
#include "sandbox/mac/seatbelt_exec.h" #include "sandbox/mac/seatbelt_exec.h"
#endif // OS_WIN #endif // OS_WIN
...@@ -718,7 +719,7 @@ int ContentMainRunnerImpl::Initialize(const ContentMainParams& params) { ...@@ -718,7 +719,7 @@ int ContentMainRunnerImpl::Initialize(const ContentMainParams& params) {
} }
if (!process_type.empty() && delegate_->ShouldSendMachPort(process_type)) { if (!process_type.empty() && delegate_->ShouldSendMachPort(process_type)) {
MachBroker::ChildSendTaskPortToParent(); base::MachPortBroker::ChildSendTaskPortToParent(kMachBootstrapName);
} }
#endif #endif
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/logging.h" #include "base/logging.h"
#include "content/common/content_constants_internal.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h" #include "content/public/browser/child_process_data.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
...@@ -15,15 +16,6 @@ ...@@ -15,15 +16,6 @@
namespace content { namespace content {
namespace {
const char kBootstrapName[] = "rohitfork";
}
// static
bool MachBroker::ChildSendTaskPortToParent() {
return base::MachPortBroker::ChildSendTaskPortToParent(kBootstrapName);
}
MachBroker* MachBroker::GetInstance() { MachBroker* MachBroker::GetInstance() {
return base::Singleton<MachBroker, return base::Singleton<MachBroker,
base::LeakySingletonTraits<MachBroker>>::get(); base::LeakySingletonTraits<MachBroker>>::get();
...@@ -88,10 +80,10 @@ std::string MachBroker::GetMachPortName() { ...@@ -88,10 +80,10 @@ std::string MachBroker::GetMachPortName() {
const base::CommandLine* command_line = const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess(); base::CommandLine::ForCurrentProcess();
const bool is_child = command_line->HasSwitch(switches::kProcessType); const bool is_child = command_line->HasSwitch(switches::kProcessType);
return base::MachPortBroker::GetMachPortName(kBootstrapName, is_child); return base::MachPortBroker::GetMachPortName(kMachBootstrapName, is_child);
} }
MachBroker::MachBroker() : initialized_(false), broker_(kBootstrapName) { MachBroker::MachBroker() : initialized_(false), broker_(kMachBootstrapName) {
broker_.AddObserver(this); broker_.AddObserver(this);
} }
......
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
#include "content/browser/mach_broker_mac.h" #include "content/browser/mach_broker_mac.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/mac/mach_port_broker.h"
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "base/test/multiprocess_test.h" #include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h" #include "base/test/test_timeouts.h"
#include "content/common/content_constants_internal.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h" #include "testing/multiprocess_func_list.h"
...@@ -77,7 +79,7 @@ class MachBrokerTest : public testing::Test, ...@@ -77,7 +79,7 @@ class MachBrokerTest : public testing::Test,
}; };
MULTIPROCESS_TEST_MAIN(MachBrokerTestChild) { MULTIPROCESS_TEST_MAIN(MachBrokerTestChild) {
CHECK(MachBroker::ChildSendTaskPortToParent()); CHECK(base::MachPortBroker::ChildSendTaskPortToParent(kMachBootstrapName));
return 0; return 0;
} }
......
...@@ -33,4 +33,8 @@ const int kTraceEventRendererMainThreadSortIndex = -1; ...@@ -33,4 +33,8 @@ const int kTraceEventRendererMainThreadSortIndex = -1;
const char kDoNotTrackHeader[] = "DNT"; const char kDoNotTrackHeader[] = "DNT";
#if defined(OS_MACOSX)
const char kMachBootstrapName[] = "rohitfork";
#endif
} // namespace content } // namespace content
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "build/build_config.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
namespace content { namespace content {
...@@ -39,6 +40,11 @@ CONTENT_EXPORT extern const int kTraceEventRendererMainThreadSortIndex; ...@@ -39,6 +40,11 @@ CONTENT_EXPORT extern const int kTraceEventRendererMainThreadSortIndex;
// HTTP header set in requests to indicate they should be marked DoNotTrack. // HTTP header set in requests to indicate they should be marked DoNotTrack.
extern const char kDoNotTrackHeader[]; extern const char kDoNotTrackHeader[];
#if defined(OS_MACOSX)
// Name of Mach port used for communication between parent and child processes.
CONTENT_EXPORT extern const char kMachBootstrapName[];
#endif
} // namespace content } // namespace content
#endif // CONTENT_COMMON_CONTENT_CONSTANTS_INTERNAL_H_ #endif // CONTENT_COMMON_CONTENT_CONSTANTS_INTERNAL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment