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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_contacts_service.h

Issue 10834220: contacts: Only download contacts from "My Contacts" group. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge and apply review feedback 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_contacts_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 class GDataContactsService : public GDataContactsServiceInterface { 61 class GDataContactsService : public GDataContactsServiceInterface {
62 public: 62 public:
63 typedef base::Callback<std::string(const std::string&)> 63 typedef base::Callback<std::string(const std::string&)>
64 RewritePhotoUrlCallback; 64 RewritePhotoUrlCallback;
65 65
66 explicit GDataContactsService(Profile* profile); 66 explicit GDataContactsService(Profile* profile);
67 virtual ~GDataContactsService(); 67 virtual ~GDataContactsService();
68 68
69 GDataAuthService* auth_service_for_testing(); 69 GDataAuthService* auth_service_for_testing();
70 70
71 const std::string& cached_my_contacts_group_id_for_testing() const {
72 return cached_my_contacts_group_id_;
73 }
74
71 void set_max_photo_downloads_per_second_for_testing(int max_downloads) { 75 void set_max_photo_downloads_per_second_for_testing(int max_downloads) {
72 max_photo_downloads_per_second_ = max_downloads; 76 max_photo_downloads_per_second_ = max_downloads;
73 } 77 }
74 void set_photo_download_timer_interval_for_testing(base::TimeDelta interval) { 78 void set_photo_download_timer_interval_for_testing(base::TimeDelta interval) {
75 photo_download_timer_interval_ = interval; 79 photo_download_timer_interval_ = interval;
76 } 80 }
77 void set_feed_url_for_testing(const GURL& url) { 81 void set_groups_feed_url_for_testing(const GURL& url) {
78 feed_url_for_testing_ = url; 82 groups_feed_url_for_testing_ = url;
83 }
84 void set_contacts_feed_url_for_testing(const GURL& url) {
85 contacts_feed_url_for_testing_ = url;
79 } 86 }
80 void set_rewrite_photo_url_callback_for_testing(RewritePhotoUrlCallback cb) { 87 void set_rewrite_photo_url_callback_for_testing(RewritePhotoUrlCallback cb) {
81 rewrite_photo_url_callback_for_testing_ = cb; 88 rewrite_photo_url_callback_for_testing_ = cb;
82 } 89 }
83 90
84 // Overridden from GDataContactsServiceInterface: 91 // Overridden from GDataContactsServiceInterface:
85 virtual void Initialize() OVERRIDE; 92 virtual void Initialize() OVERRIDE;
86 virtual void DownloadContacts(SuccessCallback success_callback, 93 virtual void DownloadContacts(SuccessCallback success_callback,
87 FailureCallback failure_callback, 94 FailureCallback failure_callback,
88 const base::Time& min_update_time) OVERRIDE; 95 const base::Time& min_update_time) OVERRIDE;
89 96
90 private: 97 private:
91 class DownloadContactsRequest; 98 class DownloadContactsRequest;
92 99
93 // Invoked by a download request once it's finished (either successfully or 100 // Invoked by a download request once it's finished (either successfully or
94 // unsuccessfully). 101 // unsuccessfully).
95 void OnRequestComplete(DownloadContactsRequest* request); 102 void OnRequestComplete(DownloadContactsRequest* request);
96 103
97 Profile* profile_; // not owned 104 Profile* profile_; // not owned
98 105
99 scoped_ptr<GDataOperationRunner> runner_; 106 scoped_ptr<GDataOperationRunner> runner_;
100 107
108 // Group ID for the "My Contacts" system contacts group.
109 // Cached after a DownloadContactsRequest has completed.
110 std::string cached_my_contacts_group_id_;
111
101 // In-progress download requests. Pointers are owned by this class. 112 // In-progress download requests. Pointers are owned by this class.
102 std::set<DownloadContactsRequest*> requests_; 113 std::set<DownloadContactsRequest*> requests_;
103 114
104 // Maximum number of photos we'll try to download per second (per 115 // Maximum number of photos we'll try to download per second (per
105 // DownloadContacts() request). 116 // DownloadContacts() request).
106 int max_photo_downloads_per_second_; 117 int max_photo_downloads_per_second_;
107 118
108 // Amount of time that we'll wait between waves of photo download requests. 119 // Amount of time that we'll wait between waves of photo download requests.
109 // This is usually one second (see |max_photo_downloads_per_second_|) but can 120 // This is usually one second (see |max_photo_downloads_per_second_|) but can
110 // be set to a lower value for tests to make them complete more quickly. 121 // be set to a lower value for tests to make them complete more quickly.
111 base::TimeDelta photo_download_timer_interval_; 122 base::TimeDelta photo_download_timer_interval_;
112 123
113 // If non-empty, URL that will be used to fetch the feed. URLs contained 124 // If non-empty, URLs that will be used to fetch feeds.
114 // within the feed will also be modified to use the host and port from this 125 GURL groups_feed_url_for_testing_;
115 // member. 126 GURL contacts_feed_url_for_testing_;
116 GURL feed_url_for_testing_;
117 127
118 // Callback that's invoked to rewrite photo URLs for tests. 128 // Callback that's invoked to rewrite photo URLs for tests.
119 // This is needed for tests that serve static feed data from a host/port 129 // This is needed for tests that serve static feed data from a host/port
120 // that's only known at runtime. 130 // that's only known at runtime.
121 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_; 131 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_;
122 132
123 DISALLOW_COPY_AND_ASSIGN(GDataContactsService); 133 DISALLOW_COPY_AND_ASSIGN(GDataContactsService);
124 }; 134 };
125 135
126 } // namespace gdata 136 } // namespace gdata
127 137
128 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ 138 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_contacts_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698