| 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/location.h" |
| 12 #include "base/metrics/histogram_base.h" | 12 #include "base/metrics/histogram_base.h" |
| 13 #include "base/metrics/histogram_delta_serialization.h" | 13 #include "base/metrics/histogram_delta_serialization.h" |
| 14 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
| 15 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
| 16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 18 #include "base/thread_task_runner_handle.h" | 18 #include "base/thread_task_runner_handle.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "base/threading/thread_restrictions.h" | 20 #include "base/threading/thread_restrictions.h" |
| 21 #include "build/build_config.h" |
| 21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/upgrade_detector.h" | 24 #include "chrome/browser/upgrade_detector.h" |
| 24 #include "chrome/common/service_messages.h" | 25 #include "chrome/common/service_messages.h" |
| 25 #include "chrome/common/service_process_util.h" | 26 #include "chrome/common/service_process_util.h" |
| 26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 28 | 29 |
| 29 using content::BrowserThread; | 30 using content::BrowserThread; |
| 30 | 31 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) | 153 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) |
| 153 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_Info, | 154 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_Info, |
| 154 OnCloudPrintProxyInfo) | 155 OnCloudPrintProxyInfo) |
| 155 IPC_MESSAGE_HANDLER(ServiceHostMsg_Histograms, OnHistograms) | 156 IPC_MESSAGE_HANDLER(ServiceHostMsg_Histograms, OnHistograms) |
| 156 IPC_MESSAGE_HANDLER(ServiceHostMsg_Printers, OnPrinters) | 157 IPC_MESSAGE_HANDLER(ServiceHostMsg_Printers, OnPrinters) |
| 157 IPC_MESSAGE_UNHANDLED(handled = false) | 158 IPC_MESSAGE_UNHANDLED(handled = false) |
| 158 IPC_END_MESSAGE_MAP() | 159 IPC_END_MESSAGE_MAP() |
| 159 return handled; | 160 return handled; |
| 160 } | 161 } |
| 161 | 162 |
| 162 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { | 163 void ServiceProcessControl::OnChannelConnected(int32_t peer_pid) { |
| 163 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 164 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 164 | 165 |
| 165 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", | 166 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", |
| 166 SERVICE_EVENT_CHANNEL_CONNECTED, SERVICE_EVENT_MAX); | 167 SERVICE_EVENT_CHANNEL_CONNECTED, SERVICE_EVENT_MAX); |
| 167 | 168 |
| 168 // We just established a channel with the service process. Notify it if an | 169 // We just established a channel with the service process. Notify it if an |
| 169 // upgrade is available. | 170 // upgrade is available. |
| 170 if (UpgradeDetector::GetInstance()->notify_upgrade()) { | 171 if (UpgradeDetector::GetInstance()->notify_upgrade()) { |
| 171 Send(new ServiceMsg_UpdateAvailable); | 172 Send(new ServiceMsg_UpdateAvailable); |
| 172 } else { | 173 } else { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 void ServiceProcessControl::Launcher::Notify() { | 345 void ServiceProcessControl::Launcher::Notify() { |
| 345 DCHECK(!notify_task_.is_null()); | 346 DCHECK(!notify_task_.is_null()); |
| 346 notify_task_.Run(); | 347 notify_task_.Run(); |
| 347 notify_task_.Reset(); | 348 notify_task_.Reset(); |
| 348 } | 349 } |
| 349 | 350 |
| 350 #if !defined(OS_MACOSX) | 351 #if !defined(OS_MACOSX) |
| 351 void ServiceProcessControl::Launcher::DoDetectLaunched() { | 352 void ServiceProcessControl::Launcher::DoDetectLaunched() { |
| 352 DCHECK(!notify_task_.is_null()); | 353 DCHECK(!notify_task_.is_null()); |
| 353 | 354 |
| 354 const uint32 kMaxLaunchDetectRetries = 10; | 355 const uint32_t kMaxLaunchDetectRetries = 10; |
| 355 launched_ = CheckServiceProcessReady(); | 356 launched_ = CheckServiceProcessReady(); |
| 356 | 357 |
| 357 int exit_code = 0; | 358 int exit_code = 0; |
| 358 if (launched_ || (retry_count_ >= kMaxLaunchDetectRetries) || | 359 if (launched_ || (retry_count_ >= kMaxLaunchDetectRetries) || |
| 359 process_.WaitForExitWithTimeout(base::TimeDelta(), &exit_code)) { | 360 process_.WaitForExitWithTimeout(base::TimeDelta(), &exit_code)) { |
| 360 process_.Close(); | 361 process_.Close(); |
| 361 BrowserThread::PostTask( | 362 BrowserThread::PostTask( |
| 362 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 363 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
| 363 return; | 364 return; |
| 364 } | 365 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 382 if (process_.IsValid()) { | 383 if (process_.IsValid()) { |
| 383 BrowserThread::PostTask( | 384 BrowserThread::PostTask( |
| 384 BrowserThread::IO, FROM_HERE, | 385 BrowserThread::IO, FROM_HERE, |
| 385 base::Bind(&Launcher::DoDetectLaunched, this)); | 386 base::Bind(&Launcher::DoDetectLaunched, this)); |
| 386 } else { | 387 } else { |
| 387 BrowserThread::PostTask( | 388 BrowserThread::PostTask( |
| 388 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 389 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
| 389 } | 390 } |
| 390 } | 391 } |
| 391 #endif // !OS_MACOSX | 392 #endif // !OS_MACOSX |
| OLD | NEW |