Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2544)

Unified Diff: chrome/browser/chromeos/gdata/gdata_contacts_service.cc

Issue 10829398: contacts: Give up after repeated transient photo errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add comment Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_contacts_service.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_contacts_service.cc b/chrome/browser/chromeos/gdata/gdata_contacts_service.cc
index a7db23f4ed1ebb11fda9c0236debd7dcffdfc915..79915aed016a87edc7ab7000be164a565d01da19 100644
--- a/chrome/browser/chromeos/gdata/gdata_contacts_service.cc
+++ b/chrome/browser/chromeos/gdata/gdata_contacts_service.cc
@@ -34,6 +34,10 @@ namespace {
// At values above 10, Google starts returning 503 errors.
const int kMaxPhotoDownloadsPerSecond = 10;
+// Give up after seeing more than this many transient errors while trying to
+// download a photo for a single contact.
+const int kMaxTransientPhotoDownloadErrorsPerContact = 2;
+
// Hardcoded system group ID for the "My Contacts" group, per
// https://developers.google.com/google-apps/contacts/v3/#contact_group_entry.
const char kMyContactsSystemGroupId[] = "Contacts";
@@ -661,10 +665,13 @@ class GDataContactsService::DownloadContactsRequest {
if (error == HTTP_INTERNAL_SERVER_ERROR ||
error == HTTP_SERVICE_UNAVAILABLE) {
- LOG(WARNING) << "Got error " << error << " while downloading photo "
- << "for " << contact->provider_id() << "; retrying";
- contacts_needing_photo_downloads_.push_back(contact);
- return;
+ int num_errors = ++transient_photo_download_errors_per_contact_[contact];
+ if (num_errors <= kMaxTransientPhotoDownloadErrorsPerContact) {
+ LOG(WARNING) << "Got error " << error << " while downloading photo "
+ << "for " << contact->provider_id() << "; retrying";
+ contacts_needing_photo_downloads_.push_back(contact);
+ return;
+ }
}
if (error == HTTP_NOT_FOUND) {
@@ -717,6 +724,12 @@ class GDataContactsService::DownloadContactsRequest {
// Number of in-progress photo downloads.
int num_in_progress_photo_downloads_;
+ // Map from a contact to the number of transient errors that we've encountered
+ // while trying to download its photo. Contacts for which no errors have been
+ // encountered aren't represented in the map.
+ std::map<contacts::Contact*, int>
satorux1 2012/08/17 21:55:21 I'm slightly concerned about using a key as a poin
Daniel Erat 2012/08/17 22:05:03 I'll change this if you really want me to, but non
+ transient_photo_download_errors_per_contact_;
+
// Did we encounter a fatal error while downloading a photo?
bool photo_download_failed_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698