diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/chrome_exe_main_win.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 15 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_unittest.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/panels/base_panel_browser_test.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_app_browsertest.cc | 7 | ||||
-rw-r--r-- | chrome/chrome_exe.gypi | 2 | ||||
-rw-r--r-- | chrome/common/service_process_util.cc | 1 | ||||
-rw-r--r-- | chrome/nacl/DEPS | 2 | ||||
-rw-r--r-- | chrome/nacl/nacl_exe_win_64.cc | 36 | ||||
-rw-r--r-- | chrome/nacl/nacl_main.cc | 2 | ||||
-rw-r--r-- | chrome/nacl/nacl_main_platform_delegate_mac.mm | 12 | ||||
-rw-r--r-- | chrome/nacl/nacl_main_platform_delegate_win.cc | 6 | ||||
-rw-r--r-- | chrome/service/DEPS | 1 | ||||
-rw-r--r-- | chrome/service/service_main.cc | 9 | ||||
-rw-r--r-- | chrome/test/base/chrome_test_launcher.cc | 2 | ||||
-rw-r--r-- | chrome/test/base/chrome_test_suite.cc | 5 | ||||
-rw-r--r-- | chrome/test/base/in_process_browser_test.cc | 17 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.cc | 2 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.h | 7 | ||||
-rw-r--r-- | chrome/test/webdriver/commands/command.h | 6 |
20 files changed, 79 insertions, 75 deletions
diff --git a/chrome/app/chrome_exe_main_win.cc b/chrome/app/chrome_exe_main_win.cc index 93b4871..0d7ca72 100644 --- a/chrome/app/chrome_exe_main_win.cc +++ b/chrome/app/chrome_exe_main_win.cc @@ -9,7 +9,7 @@ #include "base/command_line.h" #include "chrome/app/breakpad_win.h" #include "chrome/app/client_util.h" -#include "content/app/startup_helper_win.h" +#include "content/public/app/startup_helper_win.h" #include "content/public/common/result_codes.h" #include "sandbox/src/sandbox_factory.h" diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 36e5f0f..e74b7ba 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -14,7 +14,6 @@ #include "base/debug/trace_event.h" #include "base/file_path.h" #include "base/file_util.h" -#include "base/mac/scoped_nsautorelease_pool.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" #include "base/path_service.h" @@ -175,6 +174,7 @@ #if defined(OS_MACOSX) #include <Security/Security.h> +#include "base/mac/scoped_nsautorelease_pool.h" #include "chrome/browser/mac/install_from_dmg.h" #include "chrome/browser/mac/keystone_glue.h" #endif @@ -451,7 +451,7 @@ Profile* CreateProfile(const MainFunctionParams& parameters, // --user-data-dir switch. The last flag of the same name wins. // TODO(tc): It would be nice to remove the flag we don't want, but that // sounds risky if we parse differently than CommandLineToArgvW. - CommandLine new_command_line = parameters.command_line_; + CommandLine new_command_line = parameters.command_line; new_command_line.AppendSwitchPath(switches::kUserDataDir, new_user_data_dir); base::LaunchProcess(new_command_line, base::LaunchOptions(), NULL); @@ -682,7 +682,7 @@ const char kMissingLocaleDataMessage[] = ChromeBrowserMainParts::ChromeBrowserMainParts( const MainFunctionParams& parameters) : parameters_(parameters), - parsed_command_line_(parameters.command_line_), + parsed_command_line_(parameters.command_line), result_code_(content::RESULT_CODE_NORMAL_EXIT), shutdown_watcher_(new ShutdownWatcherHelper()), record_search_engine_(false), @@ -1662,6 +1662,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { return content::RESULT_CODE_NORMAL_EXIT; } } + base::mac::ScopedNSAutoreleasePool* pool = parameters().autorelease_pool; #endif // Show the First Run UI if this is the first time Chrome has been run on @@ -1885,11 +1886,12 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { ThreadWatcherList::StartWatchingAll(parsed_command_line()); int result_code = content::RESULT_CODE_NORMAL_EXIT; - base::mac::ScopedNSAutoreleasePool* pool = parameters().autorelease_pool_; if (parameters().ui_task) { // We are in test mode. Run one task and enter the main message loop. +#if defined(OS_MACOSX) if (pool) pool->Recycle(); +#endif parameters().ui_task->Run(); delete parameters().ui_task; } else { @@ -1919,10 +1921,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { // Record now as the last successful chrome start. GoogleUpdateSettings::SetLastRunTime(); + +#if defined(OS_MACOSX) // Call Recycle() here as late as possible, before going into the loop // because Start() will add things to it while creating the main window. if (pool) pool->Recycle(); +#endif RecordPreReadExperimentTime("Startup.BrowserOpenTabs", base::TimeTicks::Now() - browser_open_start); @@ -2084,7 +2089,7 @@ void ChromeBrowserMainParts::ToolkitInitialized() { views::ViewsDelegate::views_delegate = new ChromeViewsDelegate; // TODO(beng): Move to WidgetImpl and implement on Windows too! - if (parameters().command_line_.HasSwitch(switches::kDebugViewsPaint)) + if (parameters().command_line.HasSwitch(switches::kDebugViewsPaint)) views::Widget::SetDebugPaintEnabled(true); #endif diff --git a/chrome/browser/chrome_browser_main_unittest.cc b/chrome/browser/chrome_browser_main_unittest.cc index 9bcd07f..e682c9c 100644 --- a/chrome/browser/chrome_browser_main_unittest.cc +++ b/chrome/browser/chrome_browser_main_unittest.cc @@ -12,7 +12,6 @@ #include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_pref_service.h" #include "content/common/main_function_params.h" -#include "content/common/sandbox_init_wrapper.h" #include "content/public/browser/content_browser_client.h" #include "net/socket/client_socket_pool_base.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,12 +19,8 @@ class BrowserMainTest : public testing::Test { public: BrowserMainTest() : command_line_(CommandLine::NO_PROGRAM) {} - protected: - virtual void SetUp() { - sandbox_init_wrapper_.reset(new SandboxInitWrapper()); - } - scoped_ptr<SandboxInitWrapper> sandbox_init_wrapper_; + protected: TestingPrefService pref_service_; CommandLine command_line_; }; @@ -33,8 +28,7 @@ class BrowserMainTest : public testing::Test { TEST_F(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket) { command_line_.AppendSwitchASCII(switches::kSocketReusePolicy, "0"); - scoped_ptr<MainFunctionParams> params( - new MainFunctionParams(command_line_, *sandbox_init_wrapper_, NULL)); + scoped_ptr<MainFunctionParams> params(new MainFunctionParams(command_line_)); ScopedVector<content::BrowserMainParts> bwv; content::GetContentClient()->browser()->CreateBrowserMainParts( *params, &(bwv.get())); @@ -49,8 +43,7 @@ TEST_F(BrowserMainTest, WarmConnectionFieldTrial_WarmestSocket) { } TEST_F(BrowserMainTest, WarmConnectionFieldTrial_Random) { - scoped_ptr<MainFunctionParams> params( - new MainFunctionParams(command_line_, *sandbox_init_wrapper_, NULL)); + scoped_ptr<MainFunctionParams> params(new MainFunctionParams(command_line_)); ScopedVector<content::BrowserMainParts> bwv; content::GetContentClient()->browser()->CreateBrowserMainParts( *params, &(bwv.get())); @@ -72,8 +65,7 @@ TEST_F(BrowserMainTest, WarmConnectionFieldTrial_Random) { TEST_F(BrowserMainTest, WarmConnectionFieldTrial_Invalid) { command_line_.AppendSwitchASCII(switches::kSocketReusePolicy, "100"); - scoped_ptr<MainFunctionParams> params( - new MainFunctionParams(command_line_, *sandbox_init_wrapper_, NULL)); + scoped_ptr<MainFunctionParams> params(new MainFunctionParams(command_line_)); // This test ends up launching a new process, and that doesn't initialize the // ContentClient interfaces. ScopedVector<content::BrowserMainParts> bwv; diff --git a/chrome/browser/ui/panels/base_panel_browser_test.cc b/chrome/browser/ui/panels/base_panel_browser_test.cc index 8d41f37..99e26e0 100644 --- a/chrome/browser/ui/panels/base_panel_browser_test.cc +++ b/chrome/browser/ui/panels/base_panel_browser_test.cc @@ -7,7 +7,6 @@ #include "chrome/browser/ui/browser_list.h" #include "base/command_line.h" -#include "base/mac/scoped_nsautorelease_pool.h" #include "base/message_loop.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" @@ -22,6 +21,7 @@ #include "content/public/common/url_constants.h" #if defined(OS_MACOSX) +#include "base/mac/scoped_nsautorelease_pool.h" #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" #endif @@ -225,6 +225,7 @@ void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) { Panel* BasePanelBrowserTest::CreatePanelWithParams( const CreatePanelParams& params) { +#if defined(OS_MACOSX) // Opening panels on a Mac causes NSWindowController of the Panel window // to be autoreleased. We need a pool drained after it's done so the test // can close correctly. The NSWindowController of the Panel window controls @@ -232,6 +233,7 @@ Panel* BasePanelBrowserTest::CreatePanelWithParams( // possible. In real Chrome, this is done by message pump. // On non-Mac platform, this is an empty class. base::mac::ScopedNSAutoreleasePool autorelease_pool; +#endif Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, params.name, diff --git a/chrome/browser/ui/panels/panel_app_browsertest.cc b/chrome/browser/ui/panels/panel_app_browsertest.cc index 25e17c0..0f6fdde 100644 --- a/chrome/browser/ui/panels/panel_app_browsertest.cc +++ b/chrome/browser/ui/panels/panel_app_browsertest.cc @@ -5,7 +5,6 @@ #include "base/command_line.h" #include "base/file_path.h" -#include "base/mac/scoped_nsautorelease_pool.h" #include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" @@ -19,6 +18,10 @@ #include "chrome/test/base/ui_test_utils.h" #include "testing/gtest/include/gtest/gtest.h" +#if defined(OS_MACOSX) +#include "base/mac/scoped_nsautorelease_pool.h" +#endif + class PanelAppBrowserTest : public ExtensionBrowserTest { public: virtual void SetUpCommandLine(CommandLine* command_line) { @@ -26,6 +29,7 @@ class PanelAppBrowserTest : public ExtensionBrowserTest { } void LoadAndLaunchExtension(const char* name) { +#if defined(OS_MACOSX) // Opening panels on a Mac causes NSWindowController of the Panel window // to be autoreleased. We need a pool drained after it's done so the test // can close correctly. The NSWindowController of the Panel window controls @@ -33,6 +37,7 @@ class PanelAppBrowserTest : public ExtensionBrowserTest { // possible. In real Chrome, this is done by message pump. // On non-Mac platform, this is an empty class. base::mac::ScopedNSAutoreleasePool autorelease_pool; +#endif EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name))); diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index e148e55..9fa9d59 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -512,8 +512,8 @@ '../content/app/startup_helper_win.cc', '../content/common/debug_flags.cc', # Needed for sandbox_policy.cc '../content/common/hi_res_timer_manager_win.cc', + '../content/common/sandbox_init_win.cc', '../content/common/sandbox_policy.cc', - '../content/common/sandbox_init_wrapper_win.cc', '../content/public/common/content_switches.cc', '<(SHARED_INTERMEDIATE_DIR)/chrome_version/nacl64_exe_version.rc', ], diff --git a/chrome/common/service_process_util.cc b/chrome/common/service_process_util.cc index 3f21f24..768c618 100644 --- a/chrome/common/service_process_util.cc +++ b/chrome/common/service_process_util.cc @@ -7,7 +7,6 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/logging.h" -#include "base/mac/scoped_nsautorelease_pool.h" #include "base/memory/singleton.h" #include "base/path_service.h" #include "base/process_util.h" diff --git a/chrome/nacl/DEPS b/chrome/nacl/DEPS index 93d77e9..9700f06 100644 --- a/chrome/nacl/DEPS +++ b/chrome/nacl/DEPS @@ -1,6 +1,6 @@ include_rules = [ "+chrome/app/breakpad_win.h", - "+content/app/startup_helper_win.h", + "+content/public/app/startup_helper_win.h", "+sandbox/src", "+native_client/src", ] diff --git a/chrome/nacl/nacl_exe_win_64.cc b/chrome/nacl/nacl_exe_win_64.cc index 834fc37..c347c7b 100644 --- a/chrome/nacl/nacl_exe_win_64.cc +++ b/chrome/nacl/nacl_exe_win_64.cc @@ -16,12 +16,10 @@ #include "chrome/nacl/nacl_broker_listener.h" #include "chrome/nacl/nacl_listener.h" #include "chrome/nacl/nacl_main_platform_delegate.h" -#include "content/app/startup_helper_win.h" #include "content/common/hi_res_timer_manager.h" #include "content/common/main_function_params.h" -#include "content/common/sandbox_init_wrapper.h" -#include "content/common/sandbox_policy.h" -#include "sandbox/src/sandbox.h" +#include "content/public/app/startup_helper_win.h" +#include "content/public/common/sandbox_init.h" #include "sandbox/src/sandbox_types.h" extern int NaClMain(const MainFunctionParams&); @@ -29,7 +27,7 @@ extern int NaClMain(const MainFunctionParams&); // main() routine for the NaCl broker process. // This is necessary for supporting NaCl in Chrome on Win64. int NaClBrokerMain(const MainFunctionParams& parameters) { - const CommandLine& parsed_command_line = parameters.command_line_; + const CommandLine& parsed_command_line = parameters.command_line; MessageLoopForIO main_message_loop; base::PlatformThread::SetName("CrNaClBrokerMain"); @@ -37,26 +35,6 @@ int NaClBrokerMain(const MainFunctionParams& parameters) { base::SystemMonitor system_monitor; HighResolutionTimerManager hi_res_timer_manager; - // NOTE: this code is duplicated from browser_main.cc - // IMPORTANT: This piece of code needs to run as early as possible in the - // process because it will initialize the sandbox broker, which requires the - // process to swap its window station. During this time all the UI will be - // broken. This has to run before threads and windows are created. - sandbox::BrokerServices* broker_services = - parameters.sandbox_info_.BrokerServices(); - if (broker_services) { - sandbox::InitBrokerServices(broker_services); - if (!parsed_command_line.HasSwitch(switches::kNoSandbox)) { - bool use_winsta = !parsed_command_line.HasSwitch( - switches::kDisableAltWinstation); - // Precreate the desktop and window station used by the renderers. - sandbox::TargetPolicy* policy = broker_services->CreatePolicy(); - sandbox::ResultCode result = policy->CreateAlternateDesktop(use_winsta); - CHECK(sandbox::SBOX_ERROR_FAILED_TO_SWITCH_BACK_WINSTATION != result); - policy->Release(); - } - } - NaClBrokerListener listener; listener.Listen(); @@ -85,14 +63,12 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { content::SetupCRT(command_line); // Initialize the sandbox for this process. - SandboxInitWrapper sandbox_wrapper; - sandbox_wrapper.SetServices(&sandbox_info); - bool sandbox_initialized_ok = - sandbox_wrapper.InitializeSandbox(command_line, process_type); + bool sandbox_initialized_ok = content::InitializeSandbox(&sandbox_info); // Die if the sandbox can't be enabled. CHECK(sandbox_initialized_ok) << "Error initializing sandbox for " << process_type; - MainFunctionParams main_params(command_line, sandbox_wrapper, NULL); + MainFunctionParams main_params(command_line); + main_params.sandbox_info = &sandbox_info; if (process_type == switches::kNaClLoaderProcess) return NaClMain(main_params); diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc index 4b3caae..87e37eb 100644 --- a/chrome/nacl/nacl_main.cc +++ b/chrome/nacl/nacl_main.cc @@ -30,7 +30,7 @@ static void HandleNaClTestParameters(const CommandLine& command_line) { // main() routine for the NaCl loader process. int NaClMain(const MainFunctionParams& parameters) { - const CommandLine& parsed_command_line = parameters.command_line_; + const CommandLine& parsed_command_line = parameters.command_line; // This function allows pausing execution using the --nacl-startup-dialog // flag allowing us to attach a debugger. diff --git a/chrome/nacl/nacl_main_platform_delegate_mac.mm b/chrome/nacl/nacl_main_platform_delegate_mac.mm index 006ee25..c5eb65a 100644 --- a/chrome/nacl/nacl_main_platform_delegate_mac.mm +++ b/chrome/nacl/nacl_main_platform_delegate_mac.mm @@ -11,6 +11,7 @@ #include "base/native_library.h" #include "chrome/common/chrome_switches.h" #include "content/common/sandbox_mac.h" +#include "content/public/common/sandbox_init.h" NaClMainPlatformDelegate::NaClMainPlatformDelegate( const MainFunctionParams& parameters) @@ -32,7 +33,7 @@ void NaClMainPlatformDelegate::PlatformUninitialize() { } void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { - const CommandLine& command_line = parameters_.command_line_; + const CommandLine& command_line = parameters_.command_line; DVLOG(1) << "Started NaClLdr with "; const std::vector<std::string>& argstrings = command_line.argv(); @@ -54,13 +55,8 @@ void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { } void NaClMainPlatformDelegate::EnableSandbox() { - CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); - SandboxInitWrapper sandbox_wrapper; - bool sandbox_initialized_ok = - sandbox_wrapper.InitializeSandbox(*parsed_command_line, - switches::kNaClLoaderProcess); - CHECK(sandbox_initialized_ok) << "Error initializing sandbox for " - << switches::kNaClLoaderProcess; + CHECK(content::InitializeSandbox()) << "Error initializing sandbox for " + << switches::kNaClLoaderProcess; } bool NaClMainPlatformDelegate::RunSandboxTests() { diff --git a/chrome/nacl/nacl_main_platform_delegate_win.cc b/chrome/nacl/nacl_main_platform_delegate_win.cc index 97ba3af..1ce923e 100644 --- a/chrome/nacl/nacl_main_platform_delegate_win.cc +++ b/chrome/nacl/nacl_main_platform_delegate_win.cc @@ -28,12 +28,12 @@ void NaClMainPlatformDelegate::PlatformUninitialize() { } void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { - const CommandLine& command_line = parameters_.command_line_; + const CommandLine& command_line = parameters_.command_line; DVLOG(1) << "Started NaClLdr with " << command_line.GetCommandLineString(); sandbox::TargetServices* target_services = - parameters_.sandbox_info_.TargetServices(); + parameters_.sandbox_info->target_services; if (target_services && !no_sandbox) { FilePath test_dll_name = @@ -59,7 +59,7 @@ void NaClMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { void NaClMainPlatformDelegate::EnableSandbox() { sandbox::TargetServices* target_services = - parameters_.sandbox_info_.TargetServices(); + parameters_.sandbox_info->target_services; CHECK(target_services) << "NaCl-Win EnableSandbox: No Target Services!"; // Cause advapi32 to load before the sandbox is turned on. diff --git a/chrome/service/DEPS b/chrome/service/DEPS index be16d49..3f31d56 100644 --- a/chrome/service/DEPS +++ b/chrome/service/DEPS @@ -1,4 +1,5 @@ include_rules = [ # For generated headers. "+grit", + "+sandbox/src/sandbox_types.h", ] diff --git a/chrome/service/service_main.cc b/chrome/service/service_main.cc index bd5e66f..14f1362 100644 --- a/chrome/service/service_main.cc +++ b/chrome/service/service_main.cc @@ -11,6 +11,7 @@ #if defined(OS_WIN) #include "content/common/sandbox_policy.h" +#include "sandbox/src/sandbox_types.h" #elif defined(OS_MACOSX) #include "chrome/service/chrome_service_application_mac.h" #endif // defined(OS_WIN) @@ -19,12 +20,12 @@ int ServiceProcessMain(const MainFunctionParams& parameters) { MessageLoopForUI main_message_loop; main_message_loop.set_thread_name("MainThread"); - if (parameters.command_line_.HasSwitch(switches::kWaitForDebugger)) { + if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) { base::debug::WaitForDebugger(60, true); } VLOG(1) << "Service process launched: " - << parameters.command_line_.GetCommandLineString(); + << parameters.command_line.GetCommandLineString(); #if defined(OS_MACOSX) chrome_service_application_mac::RegisterServiceCrApp(); @@ -39,14 +40,14 @@ int ServiceProcessMain(const MainFunctionParams& parameters) { #if defined(OS_WIN) sandbox::BrokerServices* broker_services = - parameters.sandbox_info_.BrokerServices(); + parameters.sandbox_info->broker_services; if (broker_services) sandbox::InitBrokerServices(broker_services); #endif // defined(OS_WIN) ServiceProcess service_process; if (service_process.Initialize(&main_message_loop, - parameters.command_line_, + parameters.command_line, state.release())) { MessageLoop::current()->Run(); } else { diff --git a/chrome/test/base/chrome_test_launcher.cc b/chrome/test/base/chrome_test_launcher.cc index 3209f7d..8e6fab4 100644 --- a/chrome/test/base/chrome_test_launcher.cc +++ b/chrome/test/base/chrome_test_launcher.cc @@ -18,7 +18,7 @@ #endif // defined(OS_MACOSX) #if defined(OS_WIN) -#include "content/app/startup_helper_win.h" +#include "content/public/app/startup_helper_win.h" #include "sandbox/src/sandbox_types.h" #endif // defined(OS_WIN) diff --git a/chrome/test/base/chrome_test_suite.cc b/chrome/test/base/chrome_test_suite.cc index 6bba2b2..fd4e26d 100644 --- a/chrome/test/base/chrome_test_suite.cc +++ b/chrome/test/base/chrome_test_suite.cc @@ -6,7 +6,6 @@ #include "base/command_line.h" #include "base/file_util.h" -#include "base/mac/scoped_nsautorelease_pool.h" #include "base/memory/ref_counted.h" #include "base/metrics/stats_table.h" #include "base/path_service.h" @@ -31,6 +30,7 @@ #if defined(OS_MACOSX) #include "base/mac/mac_util.h" +#include "base/mac/scoped_nsautorelease_pool.h" #include "content/common/chrome_application_mac.h" #endif @@ -159,9 +159,8 @@ ChromeTestSuite::~ChromeTestSuite() { void ChromeTestSuite::Initialize() { #if defined(OS_MACOSX) chrome_application_mac::RegisterCrApp(); -#endif - base::mac::ScopedNSAutoreleasePool autorelease_pool; +#endif base::TestSuite::Initialize(); diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc index 92df821..e9a0909 100644 --- a/chrome/test/base/in_process_browser_test.cc +++ b/chrome/test/base/in_process_browser_test.cc @@ -8,7 +8,6 @@ #include "base/debug/stack_trace.h" #include "base/file_path.h" #include "base/file_util.h" -#include "base/mac/scoped_nsautorelease_pool.h" #include "base/path_service.h" #include "base/string_number_conversions.h" #include "base/test/test_file_util.h" @@ -40,6 +39,8 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/audio_handler.h" +#elif defined(OS_MACOSX) +#include "base/mac/scoped_nsautorelease_pool.h" #endif // Passed as value of kTestType. @@ -255,6 +256,7 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() { signal(SIGTERM, DumpStackTraceSignalHandler); #endif // defined(OS_POSIX) +#if defined(OS_MACOSX) // On Mac, without the following autorelease pool, code which is directly // executed (as opposed to executed inside a message loop) would autorelease // objects into a higher-level pool. This pool is not recycled in-sync with @@ -263,29 +265,42 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() { // browser shutdown). To avoid this, the following pool is recycled after each // time code is directly executed. base::mac::ScopedNSAutoreleasePool pool; +#endif // Pump startup related events. MessageLoopForUI::current()->RunAllPending(); +#if defined(OS_MACOSX) pool.Recycle(); +#endif browser_ = CreateBrowser(ProfileManager::GetDefaultProfile()); +#if defined(OS_MACOSX) pool.Recycle(); +#endif // Pump any pending events that were created as a result of creating a // browser. MessageLoopForUI::current()->RunAllPending(); SetUpOnMainThread(); +#if defined(OS_MACOSX) pool.Recycle(); +#endif RunTestOnMainThread(); +#if defined(OS_MACOSX) pool.Recycle(); +#endif CleanUpOnMainThread(); +#if defined(OS_MACOSX) pool.Recycle(); +#endif QuitBrowsers(); +#if defined(OS_MACOSX) pool.Recycle(); +#endif } void InProcessBrowserTest::QuitBrowsers() { diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc index c178995..ed90fc1 100644 --- a/chrome/test/pyautolib/pyautolib.cc +++ b/chrome/test/pyautolib/pyautolib.cc @@ -26,7 +26,9 @@ PyUITestSuiteBase::PyUITestSuiteBase(int argc, char** argv) } PyUITestSuiteBase::~PyUITestSuiteBase() { +#if defined(OS_MACOSX) pool_.Recycle(); +#endif Shutdown(); } diff --git a/chrome/test/pyautolib/pyautolib.h b/chrome/test/pyautolib/pyautolib.h index 4b0958e..72c3fbe 100644 --- a/chrome/test/pyautolib/pyautolib.h +++ b/chrome/test/pyautolib/pyautolib.h @@ -10,11 +10,14 @@ #pragma once #include "base/message_loop.h" -#include "base/mac/scoped_nsautorelease_pool.h" #include "base/test/test_timeouts.h" #include "chrome/test/ui/ui_test.h" #include "chrome/test/ui/ui_test_suite.h" +#if defined(OS_MACOSX) +#include "base/mac/scoped_nsautorelease_pool.h" +#endif + // The C++ style guide forbids using default arguments but I'm taking the // liberty of allowing it in this file. The sole purpose of this (and the // .cc) is to support the python interface, and default args are allowed in @@ -33,7 +36,9 @@ class PyUITestSuiteBase : public UITestSuite { void SetCrSourceRoot(const FilePath& path); private: +#if defined(OS_MACOSX) base::mac::ScopedNSAutoreleasePool pool_; +#endif }; // The primary class that interfaces with Automation Proxy. diff --git a/chrome/test/webdriver/commands/command.h b/chrome/test/webdriver/commands/command.h index 8f735f8..dc4177f 100644 --- a/chrome/test/webdriver/commands/command.h +++ b/chrome/test/webdriver/commands/command.h @@ -11,7 +11,11 @@ #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" +#include "build/build_config.h" + +#if defined(OS_MACOX) #include "base/mac/scoped_nsautorelease_pool.h" +#endif namespace webdriver { @@ -101,12 +105,14 @@ class Command { const std::vector<std::string> path_segments_; const scoped_ptr<const DictionaryValue> parameters_; +#if defined(OS_MACOX) // An autorelease pool must exist on any thread where Objective C is used, // even implicitly. Otherwise the warning: // "Objects autoreleased with no pool in place." // is printed for every object deallocted. Since every incomming command to // chrome driver is allocated a new thread, the release pool is declared here. base::mac::ScopedNSAutoreleasePool autorelease_pool; +#endif DISALLOW_COPY_AND_ASSIGN(Command); }; |