| Index: chrome/browser/chrome_to_mobile_service.cc
|
| diff --git a/chrome/browser/chrome_to_mobile_service.cc b/chrome/browser/chrome_to_mobile_service.cc
|
| index b2237e02ff42fd31cb09342a2fa12cb1507e0a50..91d6758ac058a5aea330df9c7e412a011741cbec 100644
|
| --- a/chrome/browser/chrome_to_mobile_service.cc
|
| +++ b/chrome/browser/chrome_to_mobile_service.cc
|
| @@ -394,7 +394,13 @@ void ChromeToMobileService::OnGetTokenSuccess(
|
|
|
| void ChromeToMobileService::OnGetTokenFailure(
|
| const GoogleServiceAuthError& error) {
|
| + // Log a general auth error metric for the "ChromeToMobile.Service" histogram.
|
| LogMetric(BAD_TOKEN);
|
| + // Log a more detailed metric for the "ChromeToMobile.AuthError" histogram.
|
| + UMA_HISTOGRAM_ENUMERATION("ChromeToMobile.AuthError", error.state(),
|
| + GoogleServiceAuthError::NUM_STATES);
|
| + VLOG(0) << "ChromeToMobile auth failed: " << error.ToString();
|
| +
|
| access_token_.clear();
|
| access_token_fetcher_.reset();
|
| auth_retry_timer_.Stop();
|
| @@ -594,29 +600,32 @@ void ChromeToMobileService::HandleSearchResponse(
|
|
|
| ListValue mobiles;
|
| std::string data;
|
| + bool success = false;
|
| ListValue* list = NULL;
|
| DictionaryValue* dictionary = NULL;
|
| source->GetResponseAsString(&data);
|
| scoped_ptr<Value> json(base::JSONReader::Read(data));
|
| - if (json.get() && json->GetAsDictionary(&dictionary) && dictionary &&
|
| - dictionary->GetList(cloud_print::kPrinterListValue, &list)) {
|
| - std::string type, name, id;
|
| - DictionaryValue* printer = NULL;
|
| - DictionaryValue* mobile = NULL;
|
| - for (size_t index = 0; index < list->GetSize(); ++index) {
|
| - if (list->GetDictionary(index, &printer) &&
|
| - printer->GetString("type", &type) &&
|
| - (type.compare(kTypeAndroid) == 0 || type.compare(kTypeIOS) == 0)) {
|
| - // Copy just the requisite values from the full |printer| definition.
|
| - if (printer->GetString("displayName", &name) &&
|
| - printer->GetString("id", &id)) {
|
| - mobile = new DictionaryValue();
|
| - mobile->SetString("type", type);
|
| - mobile->SetString("name", name);
|
| - mobile->SetString("id", id);
|
| - mobiles.Append(mobile);
|
| - } else {
|
| - NOTREACHED();
|
| + if (json.get() && json->GetAsDictionary(&dictionary) && dictionary) {
|
| + dictionary->GetBoolean("success", &success);
|
| + if (dictionary->GetList(cloud_print::kPrinterListValue, &list)) {
|
| + std::string type, name, id;
|
| + DictionaryValue* printer = NULL;
|
| + DictionaryValue* mobile = NULL;
|
| + for (size_t index = 0; index < list->GetSize(); ++index) {
|
| + if (list->GetDictionary(index, &printer) &&
|
| + printer->GetString("type", &type) &&
|
| + (type.compare(kTypeAndroid) == 0 || type.compare(kTypeIOS) == 0)) {
|
| + // Copy just the requisite values from the full |printer| definition.
|
| + if (printer->GetString("displayName", &name) &&
|
| + printer->GetString("id", &id)) {
|
| + mobile = new DictionaryValue();
|
| + mobile->SetString("type", type);
|
| + mobile->SetString("name", name);
|
| + mobile->SetString("id", id);
|
| + mobiles.Append(mobile);
|
| + } else {
|
| + NOTREACHED();
|
| + }
|
| }
|
| }
|
| }
|
| @@ -635,8 +644,13 @@ void ChromeToMobileService::HandleSearchResponse(
|
|
|
| // Update the cached mobile device list in profile prefs.
|
| profile_->GetPrefs()->Set(prefs::kChromeToMobileDeviceList, mobiles);
|
| +
|
| if (HasMobiles())
|
| LogMetric(DEVICES_AVAILABLE);
|
| + LogMetric(success ? SEARCH_SUCCESS : SEARCH_ERROR);
|
| + VLOG_IF(0, !success) << "ChromeToMobile search failed (" <<
|
| + source->GetResponseCode() << "): " << data;
|
| +
|
| UpdateCommandState();
|
| }
|
|
|
| @@ -662,8 +676,8 @@ void ChromeToMobileService::HandleSubmitResponse(
|
|
|
| // Log each URL and [DELAYED_]SNAPSHOT job submission response.
|
| LogMetric(success ? SEND_SUCCESS : SEND_ERROR);
|
| - LOG_IF(INFO, !success) << "ChromeToMobile send failed (" <<
|
| - source->GetResponseCode() << "): " << data;
|
| + VLOG_IF(0, !success) << "ChromeToMobile send failed (" <<
|
| + source->GetResponseCode() << "): " << data;
|
|
|
| // Get the observer for this job submission response.
|
| base::WeakPtr<Observer> observer;
|
|
|