summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-09 20:28:44 +0000
committerpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-09 20:28:44 +0000
commita1a130f7da9191abecf15b3c27e2aa7ee1faacb3 (patch)
tree3a9c6ad25ec53f05a4380ffac1a7932f66107a0d
parentfd26b925c589b600c7d12f55554ad1097bad6b87 (diff)
downloadchromium_src-a1a130f7da9191abecf15b3c27e2aa7ee1faacb3.zip
chromium_src-a1a130f7da9191abecf15b3c27e2aa7ee1faacb3.tar.gz
chromium_src-a1a130f7da9191abecf15b3c27e2aa7ee1faacb3.tar.bz2
remove chrome dependencies from win sandboxing headers. Wrap sandbox code to
make the main routine a little cleaner. Unify the parameters of each of the "main" entry points so we can more easily abstract platform differences in the future. BUG=5323 Review URL: http://codereview.chromium.org/17426 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7825 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/chrome_dll_main.cc87
-rw-r--r--chrome/app/scoped_ole_initializer.h36
-rw-r--r--chrome/browser/browser_main.cc14
-rw-r--r--chrome/chrome.xcodeproj/project.pbxproj10
-rw-r--r--chrome/common/common.scons1
-rw-r--r--chrome/common/common.vcproj8
-rw-r--r--chrome/common/main_function_params.h24
-rw-r--r--chrome/common/sandbox_init_wrapper.cc50
-rw-r--r--chrome/common/sandbox_init_wrapper.h62
-rw-r--r--chrome/plugin/plugin_main.cc8
-rw-r--r--chrome/renderer/renderer_main.cc8
-rw-r--r--sandbox/src/sandbox.h6
12 files changed, 233 insertions, 81 deletions
diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc
index ba7884fe..3fd4fc7 100644
--- a/chrome/app/chrome_dll_main.cc
+++ b/chrome/app/chrome_dll_main.cc
@@ -14,10 +14,6 @@
#include <atlapp.h>
#include <malloc.h>
#include <new.h>
-#elif defined(OS_MACOSX)
-extern "C" {
-#include <sandbox.h>
-}
#endif
#include "base/at_exit.h"
@@ -32,22 +28,25 @@ extern "C" {
#include "base/win_util.h"
#include "chrome/browser/render_process_host.h"
#endif
+#include "chrome/app/scoped_ole_initializer.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_counters.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h"
+#include "chrome/common/main_function_params.h"
#if defined(OS_WIN)
#include "chrome/common/resource_bundle.h"
#endif
-#include "sandbox/src/sandbox.h"
+#include "chrome/common/sandbox_init_wrapper.h"
#if defined(OS_WIN)
+#include "sandbox/src/sandbox.h"
#include "tools/memory_watcher/memory_watcher.h"
#endif
-extern int BrowserMain(CommandLine&, sandbox::BrokerServices*);
-extern int RendererMain(CommandLine&, sandbox::TargetServices*);
-extern int PluginMain(CommandLine&, sandbox::TargetServices*);
+extern int BrowserMain(const MainFunctionParams&);
+extern int RendererMain(const MainFunctionParams&);
+extern int PluginMain(const MainFunctionParams&);
#if defined(OS_WIN)
// TODO(erikkay): isn't this already defined somewhere?
@@ -115,21 +114,6 @@ void ChromeAssert(const std::string& str) {
#endif // OS_WIN
-// Called before/after the call to BrowseMain() to handle platform-specific
-// setup/teardown.
-void PreBrowserMain() {
-#if defined(OS_WIN)
- int ole_result = OleInitialize(NULL);
- DCHECK(ole_result == S_OK);
-#endif
-}
-
-void PostBrowserMain() {
-#if defined(OS_WIN)
- OleUninitialize();
-#endif
-}
-
// Register the invalid param handler and pure call handler to be able to
// notify breakpad when it happens.
void RegisterInvalidParamHandler() {
@@ -180,32 +164,6 @@ void EnableHeapProfiler(const CommandLine& parsed_command_line) {
#endif
}
-// Checks if the sandbox is enabled in this process and initializes it if this
-// is the case. Sandboxing is only valid on render and plugin processes. It's
-// meaningless for the browser process.
-void InitializeSandbox(const CommandLine& parsed_command_line,
- const std::wstring process_type,
- sandbox::BrokerServices* broker_services,
- sandbox::TargetServices* target_services) {
- if (target_services && !parsed_command_line.HasSwitch(switches::kNoSandbox)) {
- if ((process_type == switches::kRendererProcess) ||
- (process_type == switches::kPluginProcess &&
- parsed_command_line.HasSwitch(switches::kSafePlugins))) {
-#if defined(OS_WIN)
- target_services->Init();
-#elif defined(OS_MACOSX)
- // TODO(pinkerton): note, this leaks |error_buff|. What do we want to
- // do with the error? Pass it back to main?
- char* error_buff;
- int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED,
- &error_buff);
- if (error)
- exit(-1);
-#endif
- }
- }
-}
-
void CommonSubprocessInit() {
#if defined(OS_WIN)
// Initialize ResourceBundle which handles files loaded from external
@@ -274,22 +232,16 @@ int ChromeMain(int argc, const char** argv) {
std::wstring process_type =
parsed_command_line.GetSwitchValue(switches::kProcessType);
-
- sandbox::BrokerServices* broker_services = NULL;
- sandbox::TargetServices* target_services = NULL;
-#if defined(OS_WIN)
- if (sandbox_info) {
- target_services = sandbox_info->target_services;
- broker_services = sandbox_info->broker_services;
- }
-#endif
-
+
// Checks if the sandbox is enabled in this process and initializes it if this
// is the case. The crash handler depends on this so it has to be done before
// its initialization.
- InitializeSandbox(parsed_command_line, process_type, broker_services,
- target_services);
-
+ SandboxInitWrapper sandbox_wrapper;
+#if defined(OS_WIN)
+ sandbox_wrapper.SetServices(sandbox_info);
+#endif
+ sandbox_wrapper.InitializeSandbox(parsed_command_line, process_type);
+
#if defined(OS_WIN)
_Module.Init(NULL, instance);
#endif
@@ -333,20 +285,21 @@ int ChromeMain(int argc, const char** argv) {
startup_timer.Stop(); // End of Startup Time Measurement.
+ MainFunctionParams main_params(parsed_command_line, sandbox_wrapper);
+
// TODO(port): turn on these main() functions as they've been de-winified.
int rv = -1;
if (process_type == switches::kRendererProcess) {
#if defined(OS_WIN)
- rv = RendererMain(parsed_command_line, target_services);
+ rv = RendererMain(main_params);
#endif
} else if (process_type == switches::kPluginProcess) {
#if defined(OS_WIN)
- rv = PluginMain(parsed_command_line, target_services);
+ rv = PluginMain(main_params);
#endif
} else if (process_type.empty()) {
- PreBrowserMain();
- rv = BrowserMain(parsed_command_line, broker_services);
- PostBrowserMain();
+ ScopedOleInitializer ole_initializer;
+ rv = BrowserMain(main_params);
} else {
NOTREACHED() << "Unknown process type";
}
diff --git a/chrome/app/scoped_ole_initializer.h b/chrome/app/scoped_ole_initializer.h
new file mode 100644
index 0000000..85e47a5
--- /dev/null
+++ b/chrome/app/scoped_ole_initializer.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_APP_SCOPED_OLE_INITIALIZER_H_
+#define CHROME_APP_SCOPED_OLE_INITIALIZER_H_
+
+// Wraps OLE initialization in a cross-platform class meant to be used on the
+// stack so init/uninit is done with scoping. This class is ok for use by
+// non-windows platforms; it just doesn't do anything.
+
+#if defined(OS_WIN)
+
+class ScopedOleInitializer {
+ public:
+ ScopedOleInitializer() {
+ int ole_result = OleInitialize(NULL);
+ DCHECK(ole_result == S_OK);
+ }
+ ~ScopedOleInitializer() {
+ OleUninitialize();
+ }
+};
+
+#else
+
+class ScopedOleInitializer {
+ public:
+ // Empty, this class does nothing on non-win32 systems. Empty ctor is
+ // necessary to avoid "unused variable" warning on gcc.
+ ScopedOleInitializer() { }
+};
+
+#endif
+
+#endif // CHROME_APP_SCOPED_OLE_INITIALIZER_H_
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index cae10ad..25cff75 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -5,7 +5,11 @@
#include "build/build_config.h"
#include "base/command_line.h"
+#include "chrome/common/main_function_params.h"
+
+#if defined(OS_WIN)
#include "sandbox/src/sandbox.h"
+#endif
// TODO(port): several win-only methods have been pulled out of this, but
// BrowserMain() as a whole needs to be broken apart so that it's usable by
@@ -141,8 +145,11 @@ StringPiece NetResourceProvider(int key) {
} // namespace
// Main routine for running as the Browser process.
-int BrowserMain(CommandLine &parsed_command_line,
- sandbox::BrokerServices* broker_services) {
+int BrowserMain(const MainFunctionParams& parameters) {
+ CommandLine& parsed_command_line = parameters.command_line_;
+ sandbox::BrokerServices* broker_services =
+ parameters.sandbox_info_.BrokerServices();
+
// WARNING: If we get a WM_ENDSESSION objects created on the stack here
// are NOT deleted. If you need something to run during WM_ENDSESSION add it
// to browser_shutdown::Shutdown or BrowserProcess::EndSession.
@@ -503,8 +510,7 @@ int StartPlatformMessageLoop();
// TODO(port): merge this with above. Just a stub for now, not meant as a place
// to duplicate code.
// Main routine for running as the Browser process.
-int BrowserMain(CommandLine &parsed_command_line,
- sandbox::BrokerServices* broker_services) {
+int BrowserMain(const MainFunctionParams& parameters) {
return StartPlatformMessageLoop();
}
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj
index 7a6d167..b8325b8 100644
--- a/chrome/chrome.xcodeproj/project.pbxproj
+++ b/chrome/chrome.xcodeproj/project.pbxproj
@@ -219,6 +219,7 @@
E43A77130F16614E00ABD5D1 /* provisional_load_details.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF8E70E9D4839009A6919 /* provisional_load_details.cc */; };
E43A77170F16616E00ABD5D1 /* download_resource_handler.cc in Sources */ = {isa = PBXBuildFile; fileRef = E43A77160F16616E00ABD5D1 /* download_resource_handler.cc */; };
E43A771C0F1661AF00ABD5D1 /* chrome_url_data_manager.cc in Sources */ = {isa = PBXBuildFile; fileRef = E43A771A0F1661AF00ABD5D1 /* chrome_url_data_manager.cc */; };
+ E43A78750F17A95400ABD5D1 /* sandbox_init_wrapper.cc in Sources */ = {isa = PBXBuildFile; fileRef = E43A78730F17A95400ABD5D1 /* sandbox_init_wrapper.cc */; };
E45060F20EE87D41003BE099 /* chrome_exe_main.mm in Sources */ = {isa = PBXBuildFile; fileRef = E45060F10EE87D41003BE099 /* chrome_exe_main.mm */; };
E45062680EE890C2003BE099 /* libbase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFDC70E9D525B009A6919 /* libbase.a */; };
E45062A70EE89146003BE099 /* libicui18n.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFE6D0E9D52DC009A6919 /* libicui18n.a */; };
@@ -1601,6 +1602,10 @@
E43A77160F16616E00ABD5D1 /* download_resource_handler.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = download_resource_handler.cc; path = renderer_host/download_resource_handler.cc; sourceTree = "<group>"; };
E43A771A0F1661AF00ABD5D1 /* chrome_url_data_manager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = chrome_url_data_manager.cc; path = dom_ui/chrome_url_data_manager.cc; sourceTree = "<group>"; };
E43A771B0F1661AF00ABD5D1 /* chrome_url_data_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = chrome_url_data_manager.h; path = dom_ui/chrome_url_data_manager.h; sourceTree = "<group>"; };
+ E43A78240F17985E00ABD5D1 /* scoped_ole_initializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scoped_ole_initializer.h; sourceTree = "<group>"; };
+ E43A78480F179E7E00ABD5D1 /* main_function_params.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = main_function_params.h; sourceTree = "<group>"; };
+ E43A78730F17A95400ABD5D1 /* sandbox_init_wrapper.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sandbox_init_wrapper.cc; sourceTree = "<group>"; };
+ E43A78740F17A95400ABD5D1 /* sandbox_init_wrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sandbox_init_wrapper.h; sourceTree = "<group>"; };
E45060E40EE87B86003BE099 /* Chromium.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Chromium.app; sourceTree = BUILT_PRODUCTS_DIR; };
E45060E60EE87B86003BE099 /* app-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "app-Info.plist"; sourceTree = "<group>"; };
E45060F10EE87D41003BE099 /* chrome_exe_main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = chrome_exe_main.mm; sourceTree = "<group>"; };
@@ -2558,6 +2563,7 @@
B562C8420ED49C830077A23F /* mach_ipc_mac.mm */,
B54BD8FA0ED622C00093FD54 /* mach_message_source_mac.cc */,
B54BD8FB0ED622C00093FD54 /* mach_message_source_mac.h */,
+ E43A78480F179E7E00ABD5D1 /* main_function_params.h */,
4D7BFBD10E9D4C9F009A6919 /* message_router.cc */,
4D7BFBD20E9D4C9F009A6919 /* message_router.h */,
4D7BFBD30E9D4C9F009A6919 /* mru_cache.h */,
@@ -2602,6 +2608,8 @@
4D7BFBF60E9D4C9F009A6919 /* resource_dispatcher.cc */,
4D7BFBF70E9D4C9F009A6919 /* resource_dispatcher.h */,
4D7BFBF80E9D4C9F009A6919 /* resource_dispatcher_unittest.cc */,
+ E43A78730F17A95400ABD5D1 /* sandbox_init_wrapper.cc */,
+ E43A78740F17A95400ABD5D1 /* sandbox_init_wrapper.h */,
4D7BFBF90E9D4C9F009A6919 /* scoped_vector.h */,
4D7BFBFA0E9D4C9F009A6919 /* security_filter_peer.cc */,
4D7BFBFB0E9D4C9F009A6919 /* security_filter_peer.h */,
@@ -2791,6 +2799,7 @@
E45060F10EE87D41003BE099 /* chrome_exe_main.mm */,
E450610A0EE87FB6003BE099 /* nibs */,
E45062D40EE89659003BE099 /* resources */,
+ E43A78240F17985E00ABD5D1 /* scoped_ole_initializer.h */,
);
path = app;
sourceTree = "<group>";
@@ -3680,6 +3689,7 @@
B562E2F80F05843C00FB1A4F /* property_bag.cc in Sources */,
B5E98B140F0574A8000A37D6 /* render_messages.cc in Sources */,
E45076A90F153619003BE099 /* resource_dispatcher.cc in Sources */,
+ E43A78750F17A95400ABD5D1 /* sandbox_init_wrapper.cc in Sources */,
4D7BFC7F0E9D4D2E009A6919 /* slide_animation.cc in Sources */,
4D7BFC840E9D4D32009A6919 /* sqlite_compiled_statement.cc in Sources */,
4D7BFC8B0E9D4D35009A6919 /* sqlite_utils.cc in Sources */,
diff --git a/chrome/common/common.scons b/chrome/common/common.scons
index c491b80..05f6975 100644
--- a/chrome/common/common.scons
+++ b/chrome/common/common.scons
@@ -71,6 +71,7 @@ input_files.extend([
'property_bag.cc',
'render_messages.cc',
'resource_dispatcher.cc',
+ 'sandbox_init_wrapper.cc',
'slide_animation.cc',
'sqlite_compiled_statement.cc',
'sqlite_utils.cc',
diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj
index 159348f..b77f596 100644
--- a/chrome/common/common.vcproj
+++ b/chrome/common/common.vcproj
@@ -622,6 +622,14 @@
>
</File>
<File
+ RelativePath=".\sandbox_init_wrapper.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\sandbox_init_wrapper.h"
+ >
+ </File>
+ <File
RelativePath=".\scoped_vector.h"
>
</File>
diff --git a/chrome/common/main_function_params.h b/chrome/common/main_function_params.h
new file mode 100644
index 0000000..b8156ae
--- /dev/null
+++ b/chrome/common/main_function_params.h
@@ -0,0 +1,24 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Wrapper to the parameter list for the "main" entry points (browser, renderer,
+// plugin) to shield the call sites from the differences between platforms
+// (e.g., POSIX doesn't need to pass any sandbox information).
+
+#ifndef CHROME_COMMON_MAIN_FUNCTINON_PARAMS_H_
+#define CHROME_COMMON_MAIN_FUNCTINON_PARAMS_H_
+
+#include "base/command_line.h"
+#include "chrome/common/sandbox_init_wrapper.h"
+
+// TODO(pinkerton): |cl| should be const, but can't be due to bug 6144.
+
+struct MainFunctionParams {
+ MainFunctionParams(CommandLine& cl, const SandboxInitWrapper& sb)
+ : command_line_(cl), sandbox_info_(sb) { }
+ CommandLine& command_line_;
+ const SandboxInitWrapper& sandbox_info_;
+};
+
+#endif // CHROME_COMMON_MAIN_FUNCTINON_PARAMS_H_
diff --git a/chrome/common/sandbox_init_wrapper.cc b/chrome/common/sandbox_init_wrapper.cc
new file mode 100644
index 0000000..f72c2df
--- /dev/null
+++ b/chrome/common/sandbox_init_wrapper.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/sandbox_init_wrapper.h"
+
+#include "base/command_line.h"
+#include "chrome/common/chrome_switches.h"
+
+#if defined(OS_MACOSX)
+extern "C" {
+#include <sandbox.h>
+}
+#endif
+
+#if defined(OS_WIN)
+
+void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) {
+ if (info) {
+ broker_services_ = info->broker_services;
+ target_services_ = info->target_services;
+ }
+}
+
+#endif
+
+void SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line,
+ const std::wstring& process_type) {
+#if defined(OS_WIN)
+ if (!target_services_)
+ return;
+#endif
+ if (!command_line.HasSwitch(switches::kNoSandbox)) {
+ if ((process_type == switches::kRendererProcess) ||
+ (process_type == switches::kPluginProcess &&
+ command_line.HasSwitch(switches::kSafePlugins))) {
+#if defined(OS_WIN)
+ target_services_->Init();
+#elif defined(OS_MACOSX)
+ // TODO(pinkerton): note, this leaks |error_buff|. What do we want to
+ // do with the error? Pass it back to main?
+ char* error_buff;
+ int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED,
+ &error_buff);
+ if (error)
+ exit(-1);
+#endif
+ }
+ }
+}
diff --git a/chrome/common/sandbox_init_wrapper.h b/chrome/common/sandbox_init_wrapper.h
new file mode 100644
index 0000000..27cfacd
--- /dev/null
+++ b/chrome/common/sandbox_init_wrapper.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_SANDBOX_INIT_WRAPPER_H_
+#define CHROME_COMMON_SANDBOX_INIT_WRAPPER_H_
+
+// Wraps the sandbox initialization and platform variables to consolodate
+// the code and reduce the number of platform ifdefs elsewhere. The POSIX
+// version of this wrapper is basically empty.
+
+#include "build/build_config.h"
+
+#include <string>
+
+#include "base/basictypes.h"
+#if defined(OS_WIN)
+#include "sandbox/src/sandbox.h"
+#endif
+
+class CommandLine;
+
+#if defined(OS_WIN)
+
+class SandboxInitWrapper {
+ public:
+ SandboxInitWrapper() : broker_services_(), target_services_() { }
+ // SetServices() needs to be called before InitializeSandbox() on Win32 with
+ // the info received from the chrome exe main.
+ void SetServices(sandbox::SandboxInterfaceInfo* sandbox_info);
+ sandbox::BrokerServices* BrokerServices() const { return broker_services_; }
+ sandbox::TargetServices* TargetServices() const { return target_services_; }
+
+ // Initialize the sandbox for renderer and plug-in processes, depending on
+ // the command line flags. The browser process is not sandboxed.
+ void InitializeSandbox(const CommandLine& parsed_command_line,
+ const std::wstring& process_type);
+ private:
+ sandbox::BrokerServices* broker_services_;
+ sandbox::TargetServices* target_services_;
+
+ DISALLOW_COPY_AND_ASSIGN(SandboxInitWrapper);
+};
+
+#elif defined(OS_POSIX)
+
+class SandboxInitWrapper {
+ public:
+ SandboxInitWrapper() { }
+
+ // Initialize the sandbox for renderer and plug-in processes, depending on
+ // the command line flags. The browser process is not sandboxed.
+ void InitializeSandbox(const CommandLine& parsed_command_line,
+ const std::wstring& process_type);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SandboxInitWrapper);
+};
+
+#endif
+
+#endif // CHROME_COMMON_SANDBOX_INIT_WRAPPER_H_
diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc
index 94f50bc..ac9fd90 100644
--- a/chrome/plugin/plugin_main.cc
+++ b/chrome/plugin/plugin_main.cc
@@ -8,14 +8,18 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h"
+#include "chrome/common/main_function_params.h"
#include "chrome/common/win_util.h"
#include "chrome/plugin/plugin_process.h"
#include "chrome/test/injection_test_dll.h"
#include "sandbox/src/sandbox.h"
// mainline routine for running as the plugin process
-int PluginMain(CommandLine &parsed_command_line,
- sandbox::TargetServices* target_services) {
+int PluginMain(const MainFunctionParams& parameters) {
+ CommandLine& parsed_command_line = parameters.command_line_;
+ sandbox::TargetServices* target_services =
+ parameters.sandbox_info_.TargetServices();
+
// The main thread of the plugin services IO.
MessageLoopForIO main_message_loop;
std::wstring app_name = chrome::kBrowserAppName;
diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc
index 5d633f6..476e4f7 100644
--- a/chrome/renderer/renderer_main.cc
+++ b/chrome/renderer/renderer_main.cc
@@ -13,6 +13,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/l10n_util.h"
#include "chrome/common/logging_chrome.h"
+#include "chrome/common/main_function_params.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/renderer/render_process.h"
#include "chrome/test/injection_test_dll.h"
@@ -44,8 +45,11 @@ static void HandleRendererErrorTestParameters(const CommandLine& command_line) {
}
// mainline routine for running as the Rendererer process
-int RendererMain(CommandLine &parsed_command_line,
- sandbox::TargetServices* target_services) {
+int RendererMain(const MainFunctionParams& parameters) {
+ CommandLine& parsed_command_line = parameters.command_line_;
+ sandbox::TargetServices* target_services =
+ parameters.sandbox_info_.TargetServices();
+
StatsScope<StatsCounterTimer>
startup_timer(chrome::Counters::renderer_main());
diff --git a/sandbox/src/sandbox.h b/sandbox/src/sandbox.h
index e709afb..25c61d1 100644
--- a/sandbox/src/sandbox.h
+++ b/sandbox/src/sandbox.h
@@ -19,13 +19,7 @@
#ifndef SANDBOX_SRC_SANDBOX_H__
#define SANDBOX_SRC_SANDBOX_H__
-#include "build/build_config.h"
-
-#if defined(OS_WIN)
#include <windows.h>
-#elif defined(OS_POSIX)
-typedef struct PROCESS_INFORMATION;
-#endif
#include "base/basictypes.h"
#include "sandbox/src/sandbox_policy.h"