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