| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace base { | 23 namespace base { |
| 24 class Value; | 24 class Value; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace contacts { | 27 namespace contacts { |
| 28 class Contact; | 28 class Contact; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace gdata { | 31 namespace gdata { |
| 32 | 32 |
| 33 class GDataAuthService; | 33 class AuthService; |
| 34 class GDataOperationRunner; | 34 class OperationRunner; |
| 35 | 35 |
| 36 // Interface for fetching a user's Google contacts via the Contacts API | 36 // Interface for fetching a user's Google contacts via the Contacts API |
| 37 // (described at https://developers.google.com/google-apps/contacts/v3/). | 37 // (described at https://developers.google.com/google-apps/contacts/v3/). |
| 38 class GDataContactsServiceInterface { | 38 class GDataContactsServiceInterface { |
| 39 public: | 39 public: |
| 40 typedef base::Callback<void(scoped_ptr<ScopedVector<contacts::Contact> >)> | 40 typedef base::Callback<void(scoped_ptr<ScopedVector<contacts::Contact> >)> |
| 41 SuccessCallback; | 41 SuccessCallback; |
| 42 typedef base::Closure FailureCallback; | 42 typedef base::Closure FailureCallback; |
| 43 | 43 |
| 44 virtual ~GDataContactsServiceInterface() {} | 44 virtual ~GDataContactsServiceInterface() {} |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class GDataContactsService : public GDataContactsServiceInterface { | 62 class GDataContactsService : public GDataContactsServiceInterface { |
| 63 public: | 63 public: |
| 64 typedef base::Callback<std::string(const std::string&)> | 64 typedef base::Callback<std::string(const std::string&)> |
| 65 RewritePhotoUrlCallback; | 65 RewritePhotoUrlCallback; |
| 66 | 66 |
| 67 explicit GDataContactsService(Profile* profile); | 67 explicit GDataContactsService(Profile* profile); |
| 68 virtual ~GDataContactsService(); | 68 virtual ~GDataContactsService(); |
| 69 | 69 |
| 70 GDataAuthService* auth_service_for_testing(); | 70 AuthService* auth_service_for_testing(); |
| 71 | 71 |
| 72 const std::string& cached_my_contacts_group_id_for_testing() const { | 72 const std::string& cached_my_contacts_group_id_for_testing() const { |
| 73 return cached_my_contacts_group_id_; | 73 return cached_my_contacts_group_id_; |
| 74 } | 74 } |
| 75 void clear_cached_my_contacts_group_id_for_testing() { | 75 void clear_cached_my_contacts_group_id_for_testing() { |
| 76 cached_my_contacts_group_id_.clear(); | 76 cached_my_contacts_group_id_.clear(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void set_max_photo_downloads_per_second_for_testing(int max_downloads) { | 79 void set_max_photo_downloads_per_second_for_testing(int max_downloads) { |
| 80 max_photo_downloads_per_second_ = max_downloads; | 80 max_photo_downloads_per_second_ = max_downloads; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 100 | 100 |
| 101 private: | 101 private: |
| 102 class DownloadContactsRequest; | 102 class DownloadContactsRequest; |
| 103 | 103 |
| 104 // Invoked by a download request once it's finished (either successfully or | 104 // Invoked by a download request once it's finished (either successfully or |
| 105 // unsuccessfully). | 105 // unsuccessfully). |
| 106 void OnRequestComplete(DownloadContactsRequest* request); | 106 void OnRequestComplete(DownloadContactsRequest* request); |
| 107 | 107 |
| 108 Profile* profile_; // not owned | 108 Profile* profile_; // not owned |
| 109 | 109 |
| 110 scoped_ptr<GDataOperationRunner> runner_; | 110 scoped_ptr<OperationRunner> runner_; |
| 111 | 111 |
| 112 // Group ID for the "My Contacts" system contacts group. | 112 // Group ID for the "My Contacts" system contacts group. |
| 113 // Cached after a DownloadContactsRequest has completed. | 113 // Cached after a DownloadContactsRequest has completed. |
| 114 std::string cached_my_contacts_group_id_; | 114 std::string cached_my_contacts_group_id_; |
| 115 | 115 |
| 116 // In-progress download requests. Pointers are owned by this class. | 116 // In-progress download requests. Pointers are owned by this class. |
| 117 std::set<DownloadContactsRequest*> requests_; | 117 std::set<DownloadContactsRequest*> requests_; |
| 118 | 118 |
| 119 // Maximum number of photos we'll try to download per second (per | 119 // Maximum number of photos we'll try to download per second (per |
| 120 // DownloadContacts() request). | 120 // DownloadContacts() request). |
| (...skipping 12 matching lines...) Expand all Loading... |
| 133 // This is needed for tests that serve static feed data from a host/port | 133 // This is needed for tests that serve static feed data from a host/port |
| 134 // that's only known at runtime. | 134 // that's only known at runtime. |
| 135 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_; | 135 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_; |
| 136 | 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(GDataContactsService); | 137 DISALLOW_COPY_AND_ASSIGN(GDataContactsService); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 } // namespace gdata | 140 } // namespace gdata |
| 141 | 141 |
| 142 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ | 142 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ |
| OLD | NEW |