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/metrics/histogram_base.h" | 11 #include "base/metrics/histogram_base.h" |
12 #include "base/metrics/histogram_delta_serialization.h" | 12 #include "base/metrics/histogram_delta_serialization.h" |
13 #include "base/process/kill.h" | 13 #include "base/process/kill.h" |
14 #include "base/process/launch.h" | 14 #include "base/process/launch.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/upgrade_detector.h" | 20 #include "chrome/browser/upgrade_detector.h" |
21 #include "chrome/common/service_messages.h" | 21 #include "chrome/common/service_messages.h" |
22 #include "chrome/common/service_process_util.h" | 22 #include "chrome/common/service_process_util.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 | 25 |
26 using content::BrowserThread; | 26 using content::BrowserThread; |
27 | 27 |
28 namespace { | |
29 | |
30 void AllocDebugTest() { | |
31 // TODO(vitalybuka): Remove after few Canary builds. | |
32 // See http://crbug.com/406227 | |
33 void* buffer = malloc(20 * 1024 * 1024); | |
tapted
2014/08/28 01:07:27
nit: Maybe guard these lines in #if defined(OS_MAC
Vitaly Buka (NO REVIEWS)
2014/08/28 03:24:51
Done.
| |
34 CHECK(buffer); | |
35 free(buffer); | |
36 } | |
37 | |
38 } // namespace | |
39 | |
28 // ServiceProcessControl implementation. | 40 // ServiceProcessControl implementation. |
29 ServiceProcessControl::ServiceProcessControl() { | 41 ServiceProcessControl::ServiceProcessControl() { |
30 } | 42 } |
31 | 43 |
32 ServiceProcessControl::~ServiceProcessControl() { | 44 ServiceProcessControl::~ServiceProcessControl() { |
33 } | 45 } |
34 | 46 |
35 void ServiceProcessControl::ConnectInternal() { | 47 void ServiceProcessControl::ConnectInternal() { |
36 // If the channel has already been established then we run the task | 48 // If the channel has already been established then we run the task |
37 // and return. | 49 // and return. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 const std::vector<std::string>& pickled_histograms) { | 228 const std::vector<std::string>& pickled_histograms) { |
217 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", | 229 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", |
218 SERVICE_EVENT_HISTOGRAMS_REPLY, SERVICE_EVENT_MAX); | 230 SERVICE_EVENT_HISTOGRAMS_REPLY, SERVICE_EVENT_MAX); |
219 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
220 base::HistogramDeltaSerialization::DeserializeAndAddSamples( | 232 base::HistogramDeltaSerialization::DeserializeAndAddSamples( |
221 pickled_histograms); | 233 pickled_histograms); |
222 RunHistogramsCallback(); | 234 RunHistogramsCallback(); |
223 } | 235 } |
224 | 236 |
225 void ServiceProcessControl::RunHistogramsCallback() { | 237 void ServiceProcessControl::RunHistogramsCallback() { |
238 AllocDebugTest(); | |
226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 239 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
227 if (!histograms_callback_.is_null()) { | 240 if (!histograms_callback_.is_null()) { |
228 histograms_callback_.Run(); | 241 histograms_callback_.Run(); |
229 histograms_callback_.Reset(); | 242 histograms_callback_.Reset(); |
230 } | 243 } |
231 histograms_timeout_callback_.Cancel(); | 244 histograms_timeout_callback_.Cancel(); |
232 } | 245 } |
233 | 246 |
234 void ServiceProcessControl::OnPrinters( | 247 void ServiceProcessControl::OnPrinters( |
235 const std::vector<std::string>& printers) { | 248 const std::vector<std::string>& printers) { |
(...skipping 16 matching lines...) Expand all Loading... | |
252 SERVICE_EVENT_INFO_REQUEST, SERVICE_EVENT_MAX); | 265 SERVICE_EVENT_INFO_REQUEST, SERVICE_EVENT_MAX); |
253 if (!Send(new ServiceMsg_GetCloudPrintProxyInfo())) | 266 if (!Send(new ServiceMsg_GetCloudPrintProxyInfo())) |
254 return false; | 267 return false; |
255 cloud_print_info_callback_ = cloud_print_info_callback; | 268 cloud_print_info_callback_ = cloud_print_info_callback; |
256 return true; | 269 return true; |
257 } | 270 } |
258 | 271 |
259 bool ServiceProcessControl::GetHistograms( | 272 bool ServiceProcessControl::GetHistograms( |
260 const base::Closure& histograms_callback, | 273 const base::Closure& histograms_callback, |
261 const base::TimeDelta& timeout) { | 274 const base::TimeDelta& timeout) { |
275 AllocDebugTest(); | |
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
263 DCHECK(!histograms_callback.is_null()); | 277 DCHECK(!histograms_callback.is_null()); |
264 histograms_callback_.Reset(); | 278 histograms_callback_.Reset(); |
265 | 279 |
266 // If the service process is already running then connect to it. | 280 // If the service process is already running then connect to it. |
267 if (!CheckServiceProcessReady()) | 281 if (!CheckServiceProcessReady()) |
268 return false; | 282 return false; |
269 ConnectInternal(); | 283 ConnectInternal(); |
270 | 284 |
271 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", | 285 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 if (base::LaunchProcess(*cmd_line_, options, &process_handle_)) { | 399 if (base::LaunchProcess(*cmd_line_, options, &process_handle_)) { |
386 BrowserThread::PostTask( | 400 BrowserThread::PostTask( |
387 BrowserThread::IO, FROM_HERE, | 401 BrowserThread::IO, FROM_HERE, |
388 base::Bind(&Launcher::DoDetectLaunched, this)); | 402 base::Bind(&Launcher::DoDetectLaunched, this)); |
389 } else { | 403 } else { |
390 BrowserThread::PostTask( | 404 BrowserThread::PostTask( |
391 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 405 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
392 } | 406 } |
393 } | 407 } |
394 #endif // !OS_MACOSX | 408 #endif // !OS_MACOSX |
OLD | NEW |