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" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // We don't need the launcher anymore. | 185 // We don't need the launcher anymore. |
186 launcher_ = NULL; | 186 launcher_ = NULL; |
187 } | 187 } |
188 | 188 |
189 bool ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { | 189 bool ServiceProcessControl::OnMessageReceived(const IPC::Message& message) { |
190 bool handled = true; | 190 bool handled = true; |
191 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) | 191 IPC_BEGIN_MESSAGE_MAP(ServiceProcessControl, message) |
192 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_Info, | 192 IPC_MESSAGE_HANDLER(ServiceHostMsg_CloudPrintProxy_Info, |
193 OnCloudPrintProxyInfo) | 193 OnCloudPrintProxyInfo) |
194 IPC_MESSAGE_HANDLER(ServiceHostMsg_Histograms, OnHistograms) | 194 IPC_MESSAGE_HANDLER(ServiceHostMsg_Histograms, OnHistograms) |
| 195 IPC_MESSAGE_HANDLER(ServiceHostMsg_Printers, OnPrinters) |
195 IPC_MESSAGE_UNHANDLED(handled = false) | 196 IPC_MESSAGE_UNHANDLED(handled = false) |
196 IPC_END_MESSAGE_MAP() | 197 IPC_END_MESSAGE_MAP() |
197 return handled; | 198 return handled; |
198 } | 199 } |
199 | 200 |
200 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { | 201 void ServiceProcessControl::OnChannelConnected(int32 peer_pid) { |
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
202 | 203 |
203 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", | 204 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", |
204 SERVICE_EVENT_CHANNEL_CONNECTED, SERVICE_EVENT_MAX); | 205 SERVICE_EVENT_CHANNEL_CONNECTED, SERVICE_EVENT_MAX); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 266 |
266 void ServiceProcessControl::RunHistogramsCallback() { | 267 void ServiceProcessControl::RunHistogramsCallback() { |
267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
268 if (!histograms_callback_.is_null()) { | 269 if (!histograms_callback_.is_null()) { |
269 histograms_callback_.Run(); | 270 histograms_callback_.Run(); |
270 histograms_callback_.Reset(); | 271 histograms_callback_.Reset(); |
271 } | 272 } |
272 histograms_timeout_callback_.Cancel(); | 273 histograms_timeout_callback_.Cancel(); |
273 } | 274 } |
274 | 275 |
| 276 void ServiceProcessControl::OnPrinters( |
| 277 const std::vector<std::string>& printers) { |
| 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 279 UMA_HISTOGRAM_ENUMERATION( |
| 280 "CloudPrint.ServiceEvents", SERVICE_PRINTERS_REPLY, SERVICE_EVENT_MAX); |
| 281 UMA_HISTOGRAM_COUNTS_10000("CloudPrint.AvailablePrinters", printers.size()); |
| 282 if (!printers_callback_.is_null()) { |
| 283 printers_callback_.Run(printers); |
| 284 printers_callback_.Reset(); |
| 285 } |
| 286 } |
| 287 |
275 bool ServiceProcessControl::GetCloudPrintProxyInfo( | 288 bool ServiceProcessControl::GetCloudPrintProxyInfo( |
276 const CloudPrintProxyInfoHandler& cloud_print_info_callback) { | 289 const CloudPrintProxyInfoCallback& cloud_print_info_callback) { |
277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
278 DCHECK(!cloud_print_info_callback.is_null()); | 291 DCHECK(!cloud_print_info_callback.is_null()); |
279 cloud_print_info_callback_.Reset(); | 292 cloud_print_info_callback_.Reset(); |
280 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", | 293 UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceEvents", |
281 SERVICE_EVENT_INFO_REQUEST, SERVICE_EVENT_MAX); | 294 SERVICE_EVENT_INFO_REQUEST, SERVICE_EVENT_MAX); |
282 if (!Send(new ServiceMsg_GetCloudPrintProxyInfo())) | 295 if (!Send(new ServiceMsg_GetCloudPrintProxyInfo())) |
283 return false; | 296 return false; |
284 cloud_print_info_callback_ = cloud_print_info_callback; | 297 cloud_print_info_callback_ = cloud_print_info_callback; |
285 return true; | 298 return true; |
286 } | 299 } |
(...skipping 22 matching lines...) Expand all Loading... |
309 base::Bind(&ServiceProcessControl::RunHistogramsCallback, | 322 base::Bind(&ServiceProcessControl::RunHistogramsCallback, |
310 base::Unretained(this))); | 323 base::Unretained(this))); |
311 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, | 324 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
312 histograms_timeout_callback_.callback(), | 325 histograms_timeout_callback_.callback(), |
313 timeout); | 326 timeout); |
314 | 327 |
315 histograms_callback_ = histograms_callback; | 328 histograms_callback_ = histograms_callback; |
316 return true; | 329 return true; |
317 } | 330 } |
318 | 331 |
| 332 bool ServiceProcessControl::GetPrinters( |
| 333 const PrintersCallback& printers_callback) { |
| 334 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 335 DCHECK(!printers_callback.is_null()); |
| 336 printers_callback_.Reset(); |
| 337 UMA_HISTOGRAM_ENUMERATION( |
| 338 "CloudPrint.ServiceEvents", SERVICE_PRINTERS_REQUEST, SERVICE_EVENT_MAX); |
| 339 if (!Send(new ServiceMsg_GetPrinters())) |
| 340 return false; |
| 341 printers_callback_ = printers_callback; |
| 342 return true; |
| 343 } |
| 344 |
319 bool ServiceProcessControl::Shutdown() { | 345 bool ServiceProcessControl::Shutdown() { |
320 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 346 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
321 bool ret = Send(new ServiceMsg_Shutdown()); | 347 bool ret = Send(new ServiceMsg_Shutdown()); |
322 channel_.reset(); | 348 channel_.reset(); |
323 return ret; | 349 return ret; |
324 } | 350 } |
325 | 351 |
326 // static | 352 // static |
327 ServiceProcessControl* ServiceProcessControl::GetInstance() { | 353 ServiceProcessControl* ServiceProcessControl::GetInstance() { |
328 return Singleton<ServiceProcessControl>::get(); | 354 return Singleton<ServiceProcessControl>::get(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 if (base::LaunchProcess(*cmd_line_, options, &process_handle_)) { | 426 if (base::LaunchProcess(*cmd_line_, options, &process_handle_)) { |
401 BrowserThread::PostTask( | 427 BrowserThread::PostTask( |
402 BrowserThread::IO, FROM_HERE, | 428 BrowserThread::IO, FROM_HERE, |
403 base::Bind(&Launcher::DoDetectLaunched, this)); | 429 base::Bind(&Launcher::DoDetectLaunched, this)); |
404 } else { | 430 } else { |
405 BrowserThread::PostTask( | 431 BrowserThread::PostTask( |
406 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); | 432 BrowserThread::UI, FROM_HERE, base::Bind(&Launcher::Notify, this)); |
407 } | 433 } |
408 } | 434 } |
409 #endif // !OS_MACOSX | 435 #endif // !OS_MACOSX |
OLD | NEW |