| 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 #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 Loading... |
| 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 void set_max_simultaneous_photo_downloads_for_testing(int max_downloads) { | 71 void set_max_photo_downloads_per_second_for_testing(int max_downloads) { |
| 72 max_simultaneous_photo_downloads_ = max_downloads; | 72 max_photo_downloads_per_second_ = max_downloads; |
| 73 } |
| 74 void set_photo_download_timer_interval_for_testing(base::TimeDelta interval) { |
| 75 photo_download_timer_interval_ = interval; |
| 73 } | 76 } |
| 74 void set_feed_url_for_testing(const GURL& url) { | 77 void set_feed_url_for_testing(const GURL& url) { |
| 75 feed_url_for_testing_ = url; | 78 feed_url_for_testing_ = url; |
| 76 } | 79 } |
| 77 void set_rewrite_photo_url_callback_for_testing(RewritePhotoUrlCallback cb) { | 80 void set_rewrite_photo_url_callback_for_testing(RewritePhotoUrlCallback cb) { |
| 78 rewrite_photo_url_callback_for_testing_ = cb; | 81 rewrite_photo_url_callback_for_testing_ = cb; |
| 79 } | 82 } |
| 80 | 83 |
| 81 // Overridden from GDataContactsServiceInterface: | 84 // Overridden from GDataContactsServiceInterface: |
| 82 virtual void Initialize() OVERRIDE; | 85 virtual void Initialize() OVERRIDE; |
| 83 virtual void DownloadContacts(SuccessCallback success_callback, | 86 virtual void DownloadContacts(SuccessCallback success_callback, |
| 84 FailureCallback failure_callback, | 87 FailureCallback failure_callback, |
| 85 const base::Time& min_update_time) OVERRIDE; | 88 const base::Time& min_update_time) OVERRIDE; |
| 86 | 89 |
| 87 private: | 90 private: |
| 88 class DownloadContactsRequest; | 91 class DownloadContactsRequest; |
| 89 | 92 |
| 90 // Invoked by a download request once it's finished (either successfully or | 93 // Invoked by a download request once it's finished (either successfully or |
| 91 // unsuccessfully). | 94 // unsuccessfully). |
| 92 void OnRequestComplete(DownloadContactsRequest* request); | 95 void OnRequestComplete(DownloadContactsRequest* request); |
| 93 | 96 |
| 94 Profile* profile_; // not owned | 97 Profile* profile_; // not owned |
| 95 | 98 |
| 96 scoped_ptr<GDataOperationRunner> runner_; | 99 scoped_ptr<GDataOperationRunner> runner_; |
| 97 | 100 |
| 98 // In-progress download requests. Pointers are owned by this class. | 101 // In-progress download requests. Pointers are owned by this class. |
| 99 std::set<DownloadContactsRequest*> requests_; | 102 std::set<DownloadContactsRequest*> requests_; |
| 100 | 103 |
| 104 // Maximum number of photos we'll try to download per second (per |
| 105 // DownloadContacts() request). |
| 106 int max_photo_downloads_per_second_; |
| 107 |
| 108 // 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 |
| 110 // be set to a lower value for tests to make them complete more quickly. |
| 111 base::TimeDelta photo_download_timer_interval_; |
| 112 |
| 101 // If non-empty, URL that will be used to fetch the feed. URLs contained | 113 // If non-empty, URL that will be used to fetch the feed. URLs contained |
| 102 // within the feed will also be modified to use the host and port from this | 114 // within the feed will also be modified to use the host and port from this |
| 103 // member. | 115 // member. |
| 104 GURL feed_url_for_testing_; | 116 GURL feed_url_for_testing_; |
| 105 | 117 |
| 106 // Maximum number of photos we'll try to download at once (per | |
| 107 // DownloadContacts() request). | |
| 108 int max_simultaneous_photo_downloads_; | |
| 109 | |
| 110 // Callback that's invoked to rewrite photo URLs for tests. | 118 // Callback that's invoked to rewrite photo URLs for tests. |
| 111 // This is needed for tests that serve static feed data from a host/port | 119 // This is needed for tests that serve static feed data from a host/port |
| 112 // that's only known at runtime. | 120 // that's only known at runtime. |
| 113 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_; | 121 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_; |
| 114 | 122 |
| 115 DISALLOW_COPY_AND_ASSIGN(GDataContactsService); | 123 DISALLOW_COPY_AND_ASSIGN(GDataContactsService); |
| 116 }; | 124 }; |
| 117 | 125 |
| 118 } // namespace gdata | 126 } // namespace gdata |
| 119 | 127 |
| 120 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ | 128 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ |
| OLD | NEW |