| 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/service_process_control.h" | 5 #include "chrome/browser/service/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/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 const uint32 kMaxLaunchDetectRetries = 10; | 293 const uint32 kMaxLaunchDetectRetries = 10; |
| 294 launched_ = CheckServiceProcessReady(); | 294 launched_ = CheckServiceProcessReady(); |
| 295 if (launched_ || (retry_count_ >= kMaxLaunchDetectRetries)) { | 295 if (launched_ || (retry_count_ >= kMaxLaunchDetectRetries)) { |
| 296 BrowserThread::PostTask( | 296 BrowserThread::PostTask( |
| 297 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 297 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
| 298 return; | 298 return; |
| 299 } | 299 } |
| 300 retry_count_++; | 300 retry_count_++; |
| 301 | 301 |
| 302 // If the service process is not launched yet then check again in 2 seconds. | 302 // If the service process is not launched yet then check again in 2 seconds. |
| 303 const int kDetectLaunchRetry = 2000; | 303 const base::TimeDelta kDetectLaunchRetry = base::TimeDelta::FromSeconds(2); |
| 304 MessageLoop::current()->PostDelayedTask( | 304 MessageLoop::current()->PostDelayedTask( |
| 305 FROM_HERE, base::Bind(&Launcher::DoDetectLaunched, this), | 305 FROM_HERE, base::Bind(&Launcher::DoDetectLaunched, this), |
| 306 kDetectLaunchRetry); | 306 kDetectLaunchRetry); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void ServiceProcessControl::Launcher::DoRun() { | 309 void ServiceProcessControl::Launcher::DoRun() { |
| 310 DCHECK_EQ(false, notify_task_.is_null()); | 310 DCHECK_EQ(false, notify_task_.is_null()); |
| 311 | 311 |
| 312 base::LaunchOptions options; | 312 base::LaunchOptions options; |
| 313 #if defined(OS_WIN) | 313 #if defined(OS_WIN) |
| 314 options.start_hidden = true; | 314 options.start_hidden = true; |
| 315 #endif | 315 #endif |
| 316 if (base::LaunchProcess(*cmd_line_, options, NULL)) { | 316 if (base::LaunchProcess(*cmd_line_, options, NULL)) { |
| 317 BrowserThread::PostTask( | 317 BrowserThread::PostTask( |
| 318 BrowserThread::IO, FROM_HERE, | 318 BrowserThread::IO, FROM_HERE, |
| 319 base::Bind(&Launcher::DoDetectLaunched, this)); | 319 base::Bind(&Launcher::DoDetectLaunched, this)); |
| 320 } else { | 320 } else { |
| 321 BrowserThread::PostTask( | 321 BrowserThread::PostTask( |
| 322 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 322 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 #endif // !OS_MACOSX | 325 #endif // !OS_MACOSX |
| OLD | NEW |