diff options
author | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-09 03:17:58 +0000 |
---|---|---|
committer | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-09 03:17:58 +0000 |
commit | 7b23c9b94767948f1759e59f779ffe6a09b55c34 (patch) | |
tree | b484b34b2db6e9f35ec90aa79aadefc3c2d9f5c7 /chrome/browser/service/service_process_control_browsertest.cc | |
parent | c3c1250bec563360a1b4fd409a54c14ec14a4413 (diff) | |
download | chromium_src-7b23c9b94767948f1759e59f779ffe6a09b55c34.zip chromium_src-7b23c9b94767948f1759e59f779ffe6a09b55c34.tar.gz chromium_src-7b23c9b94767948f1759e59f779ffe6a09b55c34.tar.bz2 |
The IPC channel names and event names used by the service process now append the version string so that a browser with the same version only can talk to it.
In addition, the service process writes its version into shared memory (the name of this shared mem does not use a version) and also listens on a shutdown event. This can be used by a newer service process to shutdown an older version when it starts.
BUG=None
TEST=Unittests, with an existing service process running, let chrome autoupdate and then run the service process again. It should kill the old one.
Review URL: http://codereview.chromium.org/3603016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62066 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/service/service_process_control_browsertest.cc')
-rw-r--r-- | chrome/browser/service/service_process_control_browsertest.cc | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/chrome/browser/service/service_process_control_browsertest.cc b/chrome/browser/service/service_process_control_browsertest.cc index e48a60c..5c59e87 100644 --- a/chrome/browser/service/service_process_control_browsertest.cc +++ b/chrome/browser/service/service_process_control_browsertest.cc @@ -6,6 +6,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/service/service_process_control.h" #include "chrome/browser/service/service_process_control_manager.h" +#include "chrome/common/chrome_version_info.h" #include "chrome/common/service_process_util.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" @@ -41,20 +42,38 @@ class ServiceProcessControlBrowserTest // connections. ServiceProcessControlManager::instance()->Shutdown(); process_ = NULL; + WaitForShutdown(); + } + + void WaitForShutdown() { + // We will keep trying every second till we hit the terminate timeout. + int retries_left = TestTimeouts::wait_for_terminate_timeout_ms()/1000; MessageLoop::current()->PostDelayedTask( FROM_HERE, NewRunnableMethod(this, - &ServiceProcessControlBrowserTest::DoDetectShutdown), - TestTimeouts::wait_for_terminate_timeout_ms()); + &ServiceProcessControlBrowserTest::DoDetectShutdown, + retries_left), + 1000); ui_test_utils::RunMessageLoop(); } - - void DoDetectShutdown() { - EXPECT_FALSE(CheckServiceProcessRunning()); - // Quit the current message loop. - MessageLoop::current()->PostTask(FROM_HERE, - new MessageLoop::QuitTask()); + void DoDetectShutdown(int retries_left) { + bool service_is_running = CheckServiceProcessRunning(); + if (!retries_left) + EXPECT_FALSE(service_is_running); + if (retries_left && service_is_running) { + retries_left--; + MessageLoop::current()->PostDelayedTask( + FROM_HERE, + NewRunnableMethod(this, + &ServiceProcessControlBrowserTest::DoDetectShutdown, + retries_left), + 1000); + } else { + // Quit the current message loop. + MessageLoop::current()->PostTask(FROM_HERE, + new MessageLoop::QuitTask()); + } } void ProcessControlLaunched() { @@ -112,13 +131,23 @@ IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, LaunchTwice) { // Tests whether disconnecting from the service IPC causes the service process // to die. IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, DieOnDisconnect) { - // Launch the service process the first time. + // Launch the service process. LaunchServiceProcessControl(); // Make sure we are connected to the service process. EXPECT_TRUE(process()->is_connected()); DisconnectAndWaitForShutdown(); } +IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, ForceShutdown) { + // Launch the service process. + LaunchServiceProcessControl(); + // Make sure we are connected to the service process. + EXPECT_TRUE(process()->is_connected()); + chrome::VersionInfo version_info; + ForceServiceProcessShutdown(version_info.Version()); + WaitForShutdown(); +} + #endif DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControlBrowserTest); |