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/chrome_to_mobile_service.h" | 5 #include "chrome/browser/chrome_to_mobile_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 base::Bind(&DeleteSnapshotFile, snapshot)); | 278 base::Bind(&DeleteSnapshotFile, snapshot)); |
279 snapshots_.erase(snapshot); | 279 snapshots_.erase(snapshot); |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 void ChromeToMobileService::LogMetric(Metric metric) { | 283 void ChromeToMobileService::LogMetric(Metric metric) { |
284 UMA_HISTOGRAM_ENUMERATION("ChromeToMobile.Service", metric, NUM_METRICS); | 284 UMA_HISTOGRAM_ENUMERATION("ChromeToMobile.Service", metric, NUM_METRICS); |
285 } | 285 } |
286 | 286 |
287 void ChromeToMobileService::OnURLFetchComplete( | 287 void ChromeToMobileService::OnURLFetchComplete( |
288 const content::URLFetcher* source) { | 288 const net::URLFetcher* source) { |
289 if (source == account_info_request_.get()) | 289 if (source == account_info_request_.get()) |
290 HandleAccountInfoResponse(); | 290 HandleAccountInfoResponse(); |
291 else if (source == search_request_.get()) | 291 else if (source == search_request_.get()) |
292 HandleSearchResponse(); | 292 HandleSearchResponse(); |
293 else | 293 else |
294 HandleSubmitResponse(source); | 294 HandleSubmitResponse(source); |
295 } | 295 } |
296 | 296 |
297 void ChromeToMobileService::Observe( | 297 void ChromeToMobileService::Observe( |
298 int type, | 298 int type, |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 LogMetric(DEVICES_AVAILABLE); | 474 LogMetric(DEVICES_AVAILABLE); |
475 | 475 |
476 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 476 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
477 if (browser && browser->command_updater()) | 477 if (browser && browser->command_updater()) |
478 browser->command_updater()->UpdateCommandEnabled( | 478 browser->command_updater()->UpdateCommandEnabled( |
479 IDC_CHROME_TO_MOBILE_PAGE, !mobiles_.empty()); | 479 IDC_CHROME_TO_MOBILE_PAGE, !mobiles_.empty()); |
480 } | 480 } |
481 } | 481 } |
482 | 482 |
483 void ChromeToMobileService::HandleSubmitResponse( | 483 void ChromeToMobileService::HandleSubmitResponse( |
484 const content::URLFetcher* source) { | 484 const net::URLFetcher* source) { |
485 // Get the observer for this response; bail if there is none or it is NULL. | 485 // Get the observer for this response; bail if there is none or it is NULL. |
486 RequestObserverMap::iterator i = request_observer_map_.find(source); | 486 RequestObserverMap::iterator i = request_observer_map_.find(source); |
487 if (i == request_observer_map_.end()) | 487 if (i == request_observer_map_.end()) |
488 return; | 488 return; |
489 base::WeakPtr<Observer> observer = i->second; | 489 base::WeakPtr<Observer> observer = i->second; |
490 request_observer_map_.erase(i); | 490 request_observer_map_.erase(i); |
491 if (!observer.get()) | 491 if (!observer.get()) |
492 return; | 492 return; |
493 | 493 |
494 // Get the success value from the CloudPrint server response data. | 494 // Get the success value from the CloudPrint server response data. |
(...skipping 15 matching lines...) Expand all Loading... |
510 | 510 |
511 // Ensure a second response is not sent after reporting failure below. | 511 // Ensure a second response is not sent after reporting failure below. |
512 request_observer_map_.erase(other); | 512 request_observer_map_.erase(other); |
513 break; | 513 break; |
514 } | 514 } |
515 } | 515 } |
516 | 516 |
517 LogMetric(success ? SEND_SUCCESS : SEND_ERROR); | 517 LogMetric(success ? SEND_SUCCESS : SEND_ERROR); |
518 observer->OnSendComplete(success); | 518 observer->OnSendComplete(success); |
519 } | 519 } |
OLD | NEW |