| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
| 8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
| 9 #include "chrome/browser/service/service_process_control.h" | 9 #include "chrome/browser/service/service_process_control.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 base::ProcessId service_pid; | 73 base::ProcessId service_pid; |
| 74 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 74 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
| 75 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 75 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
| 76 EXPECT_TRUE(base::OpenProcessHandleWithAccess( | 76 EXPECT_TRUE(base::OpenProcessHandleWithAccess( |
| 77 service_pid, | 77 service_pid, |
| 78 base::kProcessAccessWaitForTermination, | 78 base::kProcessAccessWaitForTermination, |
| 79 &service_process_handle_)); | 79 &service_process_handle_)); |
| 80 // Quit the current message. Post a QuitTask instead of just calling Quit() | 80 // Quit the current message. Post a QuitTask instead of just calling Quit() |
| 81 // because this can get invoked in the context of a Launch() call and we | 81 // because this can get invoked in the context of a Launch() call and we |
| 82 // may not be in Run() yet. | 82 // may not be in Run() yet. |
| 83 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 83 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ProcessControlLaunchFailed() { | 86 void ProcessControlLaunchFailed() { |
| 87 ADD_FAILURE(); | 87 ADD_FAILURE(); |
| 88 // Quit the current message. | 88 // Quit the current message. |
| 89 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 89 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 private: | 92 private: |
| 93 base::ProcessHandle service_process_handle_; | 93 base::ProcessHandle service_process_handle_; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 // They way that the IPC is implemented only works on windows. This has to | 96 // They way that the IPC is implemented only works on windows. This has to |
| 97 // change when we implement a different scheme for IPC. | 97 // change when we implement a different scheme for IPC. |
| 98 // Times out flakily, http://crbug.com/70076. | 98 // Times out flakily, http://crbug.com/70076. |
| 99 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, | 99 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 123 EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); | 123 EXPECT_TRUE(ServiceProcessControl::GetInstance()->IsConnected()); |
| 124 SendRequestAndWait(); | 124 SendRequestAndWait(); |
| 125 | 125 |
| 126 // And then shutdown the service process. | 126 // And then shutdown the service process. |
| 127 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); | 127 EXPECT_TRUE(ServiceProcessControl::GetInstance()->Shutdown()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 static void DecrementUntilZero(int* count) { | 130 static void DecrementUntilZero(int* count) { |
| 131 (*count)--; | 131 (*count)--; |
| 132 if (!(*count)) | 132 if (!(*count)) |
| 133 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 133 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 // Invoke multiple Launch calls in succession and ensure that all the tasks | 136 // Invoke multiple Launch calls in succession and ensure that all the tasks |
| 137 // get invoked. | 137 // get invoked. |
| 138 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, | 138 IN_PROC_BROWSER_TEST_F(ServiceProcessControlBrowserTest, |
| 139 MultipleLaunchTasks) { | 139 MultipleLaunchTasks) { |
| 140 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); | 140 ServiceProcessControl* process = ServiceProcessControl::GetInstance(); |
| 141 int launch_count = 5; | 141 int launch_count = 5; |
| 142 for (int i = 0; i < launch_count; i++) { | 142 for (int i = 0; i < launch_count; i++) { |
| 143 // Launch the process asynchronously. | 143 // Launch the process asynchronously. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); | 198 EXPECT_FALSE(GetServiceProcessData(NULL, &service_pid)); |
| 199 // Launch the service process. | 199 // Launch the service process. |
| 200 LaunchServiceProcessControl(); | 200 LaunchServiceProcessControl(); |
| 201 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 201 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
| 202 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 202 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
| 203 // Disconnect from service process. | 203 // Disconnect from service process. |
| 204 ServiceProcessControl::GetInstance()->Disconnect(); | 204 ServiceProcessControl::GetInstance()->Disconnect(); |
| 205 } | 205 } |
| 206 | 206 |
| 207 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControlBrowserTest); | 207 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControlBrowserTest); |
| OLD | NEW |