| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 11 #include "base/thread.h" | 11 #include "base/thread.h" |
| 12 #include "base/thread_restrictions.h" | |
| 13 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
| 15 #include "chrome/browser/io_thread.h" | 14 #include "chrome/browser/io_thread.h" |
| 16 #include "chrome/browser/upgrade_detector.h" | 15 #include "chrome/browser/upgrade_detector.h" |
| 17 #include "chrome/common/child_process_host.h" | 16 #include "chrome/common/child_process_host.h" |
| 18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
| 20 #include "chrome/common/service_messages.h" | 19 #include "chrome/common/service_messages.h" |
| 21 #include "chrome/common/service_process_util.h" | 20 #include "chrome/common/service_process_util.h" |
| 22 | 21 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 void DoRun(Task* task) { | 48 void DoRun(Task* task) { |
| 50 base::LaunchApp(*cmd_line_.get(), false, true, NULL); | 49 base::LaunchApp(*cmd_line_.get(), false, true, NULL); |
| 51 BrowserThread::PostTask( | 50 BrowserThread::PostTask( |
| 52 BrowserThread::IO, FROM_HERE, | 51 BrowserThread::IO, FROM_HERE, |
| 53 NewRunnableMethod(this, &Launcher::DoDetectLaunched, task)); | 52 NewRunnableMethod(this, &Launcher::DoDetectLaunched, task)); |
| 54 } | 53 } |
| 55 | 54 |
| 56 void DoDetectLaunched(Task* task) { | 55 void DoDetectLaunched(Task* task) { |
| 57 const uint32 kMaxLaunchDetectRetries = 10; | 56 const uint32 kMaxLaunchDetectRetries = 10; |
| 58 | 57 |
| 59 { | 58 launched_ = CheckServiceProcessReady(); |
| 60 // We should not be doing blocking disk IO from this thread! | |
| 61 // Temporarily allowed until we fix | |
| 62 // http://code.google.com/p/chromium/issues/detail?id=60207 | |
| 63 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 64 launched_ = CheckServiceProcessReady(); | |
| 65 } | |
| 66 | |
| 67 if (launched_ || (retry_count_ >= kMaxLaunchDetectRetries)) { | 59 if (launched_ || (retry_count_ >= kMaxLaunchDetectRetries)) { |
| 68 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 60 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 69 NewRunnableMethod(this, &Launcher::Notify, task)); | 61 NewRunnableMethod(this, &Launcher::Notify, task)); |
| 70 return; | 62 return; |
| 71 } | 63 } |
| 72 retry_count_++; | 64 retry_count_++; |
| 73 // If the service process is not launched yet then check again in 2 seconds. | 65 // If the service process is not launched yet then check again in 2 seconds. |
| 74 const int kDetectLaunchRetry = 2000; | 66 const int kDetectLaunchRetry = 2000; |
| 75 MessageLoop::current()->PostDelayedTask( | 67 MessageLoop::current()->PostDelayedTask( |
| 76 FROM_HERE, | 68 FROM_HERE, |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } | 297 } |
| 306 | 298 |
| 307 bool ServiceProcessControl::GetCloudPrintProxyStatus( | 299 bool ServiceProcessControl::GetCloudPrintProxyStatus( |
| 308 Callback2<bool, std::string>::Type* cloud_print_status_callback) { | 300 Callback2<bool, std::string>::Type* cloud_print_status_callback) { |
| 309 DCHECK(cloud_print_status_callback); | 301 DCHECK(cloud_print_status_callback); |
| 310 cloud_print_status_callback_.reset(cloud_print_status_callback); | 302 cloud_print_status_callback_.reset(cloud_print_status_callback); |
| 311 return Send(new ServiceMsg_IsCloudPrintProxyEnabled); | 303 return Send(new ServiceMsg_IsCloudPrintProxyEnabled); |
| 312 } | 304 } |
| 313 | 305 |
| 314 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); | 306 DISABLE_RUNNABLE_METHOD_REFCOUNT(ServiceProcessControl); |
| OLD | NEW |