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