| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/service_process/service_process_control.h" | 5 #include "chrome/browser/service_process/service_process_control.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 void ProcessControlLaunched() { | 90 void ProcessControlLaunched() { |
| 91 base::ProcessId service_pid; | 91 base::ProcessId service_pid; |
| 92 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); | 92 EXPECT_TRUE(GetServiceProcessData(NULL, &service_pid)); |
| 93 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); | 93 EXPECT_NE(static_cast<base::ProcessId>(0), service_pid); |
| 94 #if defined(OS_WIN) | 94 #if defined(OS_WIN) |
| 95 service_process_ = | 95 service_process_ = |
| 96 base::Process::OpenWithAccess(service_pid, | 96 base::Process::OpenWithAccess(service_pid, |
| 97 SYNCHRONIZE | PROCESS_QUERY_INFORMATION); | 97 SYNCHRONIZE | PROCESS_QUERY_INFORMATION); |
| 98 #else |
| 99 service_process_ = base::Process::Open(service_pid); |
| 100 #endif |
| 98 EXPECT_TRUE(service_process_.IsValid()); | 101 EXPECT_TRUE(service_process_.IsValid()); |
| 99 #else | |
| 100 base::ProcessHandle service_process_handle; | |
| 101 EXPECT_TRUE(base::OpenProcessHandle(service_pid, &service_process_handle)); | |
| 102 service_process_ = base::Process(service_process_handle); | |
| 103 #endif | |
| 104 // Quit the current message. Post a QuitTask instead of just calling Quit() | 102 // Quit the current message. Post a QuitTask instead of just calling Quit() |
| 105 // because this can get invoked in the context of a Launch() call and we | 103 // because this can get invoked in the context of a Launch() call and we |
| 106 // may not be in Run() yet. | 104 // may not be in Run() yet. |
| 107 base::MessageLoop::current()->PostTask(FROM_HERE, | 105 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 108 base::MessageLoop::QuitClosure()); | 106 base::MessageLoop::QuitClosure()); |
| 109 } | 107 } |
| 110 | 108 |
| 111 void ProcessControlLaunchFailed() { | 109 void ProcessControlLaunchFailed() { |
| 112 ADD_FAILURE(); | 110 ADD_FAILURE(); |
| 113 // Quit the current message. | 111 // Quit the current message. |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // Callback should not be called during GetHistograms call. | 281 // Callback should not be called during GetHistograms call. |
| 284 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); | 282 EXPECT_CALL(*this, MockHistogramsCallback()).Times(0); |
| 285 // Wait for real callback by providing large timeout value. | 283 // Wait for real callback by providing large timeout value. |
| 286 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( | 284 EXPECT_TRUE(ServiceProcessControl::GetInstance()->GetHistograms( |
| 287 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, | 285 base::Bind(&ServiceProcessControlBrowserTest::HistogramsCallback, |
| 288 base::Unretained(this)), | 286 base::Unretained(this)), |
| 289 base::TimeDelta::FromHours(1))); | 287 base::TimeDelta::FromHours(1))); |
| 290 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); | 288 EXPECT_CALL(*this, MockHistogramsCallback()).Times(1); |
| 291 content::RunMessageLoop(); | 289 content::RunMessageLoop(); |
| 292 } | 290 } |
| OLD | NEW |