Chromium Code Reviews| 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..42e6f46207b6b561fd9360a994e07151a1f2cfe3 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); |
| + LOG(INFO) << "ChromeToMobile auth failed: " << error.ToString(); |
|
sky
2012/09/24 14:00:25
Use VLOG
msw
2012/09/24 17:23:20
Done.
|
| + |
| 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); |
| + LOG_IF(INFO, !success) << "ChromeToMobile search failed (" << |
|
sky
2012/09/24 14:00:25
VLOG
msw
2012/09/24 17:23:20
Done.
|
| + source->GetResponseCode() << "): " << data; |
| + |
| UpdateCommandState(); |
| } |