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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/location.h" |
11 #include "base/metrics/histogram_base.h" | 12 #include "base/metrics/histogram_base.h" |
12 #include "base/metrics/histogram_delta_serialization.h" | 13 #include "base/metrics/histogram_delta_serialization.h" |
13 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
14 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
| 16 #include "base/single_thread_task_runner.h" |
15 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/thread_task_runner_handle.h" |
16 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
17 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
18 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/upgrade_detector.h" | 23 #include "chrome/browser/upgrade_detector.h" |
21 #include "chrome/common/service_messages.h" | 24 #include "chrome/common/service_messages.h" |
22 #include "chrome/common/service_process_util.h" | 25 #include "chrome/common/service_process_util.h" |
23 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
25 | 28 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 process_.WaitForExitWithTimeout(base::TimeDelta(), &exit_code)) { | 359 process_.WaitForExitWithTimeout(base::TimeDelta(), &exit_code)) { |
357 process_.Close(); | 360 process_.Close(); |
358 BrowserThread::PostTask( | 361 BrowserThread::PostTask( |
359 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 362 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
360 return; | 363 return; |
361 } | 364 } |
362 retry_count_++; | 365 retry_count_++; |
363 | 366 |
364 // If the service process is not launched yet then check again in 2 seconds. | 367 // If the service process is not launched yet then check again in 2 seconds. |
365 const base::TimeDelta kDetectLaunchRetry = base::TimeDelta::FromSeconds(2); | 368 const base::TimeDelta kDetectLaunchRetry = base::TimeDelta::FromSeconds(2); |
366 base::MessageLoop::current()->PostDelayedTask( | 369 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
367 FROM_HERE, base::Bind(&Launcher::DoDetectLaunched, this), | 370 FROM_HERE, base::Bind(&Launcher::DoDetectLaunched, this), |
368 kDetectLaunchRetry); | 371 kDetectLaunchRetry); |
369 } | 372 } |
370 | 373 |
371 void ServiceProcessControl::Launcher::DoRun() { | 374 void ServiceProcessControl::Launcher::DoRun() { |
372 DCHECK(!notify_task_.is_null()); | 375 DCHECK(!notify_task_.is_null()); |
373 | 376 |
374 base::LaunchOptions options; | 377 base::LaunchOptions options; |
375 #if defined(OS_WIN) | 378 #if defined(OS_WIN) |
376 options.start_hidden = true; | 379 options.start_hidden = true; |
377 #endif | 380 #endif |
378 process_ = base::LaunchProcess(*cmd_line_, options); | 381 process_ = base::LaunchProcess(*cmd_line_, options); |
379 if (process_.IsValid()) { | 382 if (process_.IsValid()) { |
380 BrowserThread::PostTask( | 383 BrowserThread::PostTask( |
381 BrowserThread::IO, FROM_HERE, | 384 BrowserThread::IO, FROM_HERE, |
382 base::Bind(&Launcher::DoDetectLaunched, this)); | 385 base::Bind(&Launcher::DoDetectLaunched, this)); |
383 } else { | 386 } else { |
384 BrowserThread::PostTask( | 387 BrowserThread::PostTask( |
385 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 388 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
386 } | 389 } |
387 } | 390 } |
388 #endif // !OS_MACOSX | 391 #endif // !OS_MACOSX |
OLD | NEW |