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 | 74 |
75 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) { |
76 max_photo_downloads_per_second_ = max_downloads; | 76 max_photo_downloads_per_second_ = max_downloads; |
77 } | 77 } |
78 void set_photo_download_timer_interval_for_testing(base::TimeDelta interval) { | 78 void set_photo_download_timer_interval_for_testing(base::TimeDelta interval) { |
79 photo_download_timer_interval_ = interval; | 79 photo_download_timer_interval_ = interval; |
(...skipping 16 matching lines...) Expand all Loading... |
96 | 96 |
97 private: | 97 private: |
98 class DownloadContactsRequest; | 98 class DownloadContactsRequest; |
99 | 99 |
100 // 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 |
101 // unsuccessfully). | 101 // unsuccessfully). |
102 void OnRequestComplete(DownloadContactsRequest* request); | 102 void OnRequestComplete(DownloadContactsRequest* request); |
103 | 103 |
104 Profile* profile_; // not owned | 104 Profile* profile_; // not owned |
105 | 105 |
106 scoped_ptr<GDataOperationRunner> runner_; | 106 scoped_ptr<OperationRunner> runner_; |
107 | 107 |
108 // Group ID for the "My Contacts" system contacts group. | 108 // Group ID for the "My Contacts" system contacts group. |
109 // Cached after a DownloadContactsRequest has completed. | 109 // Cached after a DownloadContactsRequest has completed. |
110 std::string cached_my_contacts_group_id_; | 110 std::string cached_my_contacts_group_id_; |
111 | 111 |
112 // In-progress download requests. Pointers are owned by this class. | 112 // In-progress download requests. Pointers are owned by this class. |
113 std::set<DownloadContactsRequest*> requests_; | 113 std::set<DownloadContactsRequest*> requests_; |
114 | 114 |
115 // 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 |
116 // DownloadContacts() request). | 116 // DownloadContacts() request). |
(...skipping 12 matching lines...) Expand all Loading... |
129 // 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 |
130 // that's only known at runtime. | 130 // that's only known at runtime. |
131 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_; | 131 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_; |
132 | 132 |
133 DISALLOW_COPY_AND_ASSIGN(GDataContactsService); | 133 DISALLOW_COPY_AND_ASSIGN(GDataContactsService); |
134 }; | 134 }; |
135 | 135 |
136 } // namespace gdata | 136 } // namespace gdata |
137 | 137 |
138 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ | 138 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CONTACTS_SERVICE_H_ |
OLD | NEW |