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

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

Issue 19511002: Change google_api::RequestSender to take an AuthService instead of a Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/contacts/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_CONTACTS_GDATA_CONTACTS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_GDATA_CONTACTS_SERVICE_H_
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_GDATA_CONTACTS_SERVICE_H_ 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_GDATA_CONTACTS_SERVICE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 class Profile; 19 class Profile;
20 20
21 namespace base { 21 namespace base {
22 class Value; 22 class Value;
23 } // namespace base 23 } // namespace base
24 24
25 namespace google_apis { 25 namespace google_apis {
26 class AuthService; 26 class AuthServiceInterface;
27 class RequestSender; 27 class RequestSender;
28 } // namespace google_apis 28 } // namespace google_apis
29 29
30 namespace net { 30 namespace net {
31 class URLRequestContextGetter; 31 class URLRequestContextGetter;
32 } // namespace net 32 } // namespace net
33 33
34 namespace contacts { 34 namespace contacts {
35 35
36 class Contact; 36 class Contact;
37 37
38 // Interface for fetching a user's Google contacts via the Contacts API 38 // Interface for fetching a user's Google contacts via the Contacts API
39 // (described at https://developers.google.com/google-apps/contacts/v3/). 39 // (described at https://developers.google.com/google-apps/contacts/v3/).
40 class GDataContactsServiceInterface { 40 class GDataContactsServiceInterface {
41 public: 41 public:
42 typedef base::Callback<void(scoped_ptr<ScopedVector<contacts::Contact> >)> 42 typedef base::Callback<void(scoped_ptr<ScopedVector<contacts::Contact> >)>
43 SuccessCallback; 43 SuccessCallback;
44 typedef base::Closure FailureCallback; 44 typedef base::Closure FailureCallback;
45 45
46 virtual ~GDataContactsServiceInterface() {} 46 virtual ~GDataContactsServiceInterface() {}
47 47
48 virtual void Initialize() = 0;
49
50 // Downloads all contacts changed at or after |min_update_time| and invokes 48 // Downloads all contacts changed at or after |min_update_time| and invokes
51 // the appropriate callback asynchronously on the UI thread when complete. If 49 // the appropriate callback asynchronously on the UI thread when complete. If
52 // min_update_time.is_null() is true, all contacts will be returned. 50 // min_update_time.is_null() is true, all contacts will be returned.
53 virtual void DownloadContacts(SuccessCallback success_callback, 51 virtual void DownloadContacts(SuccessCallback success_callback,
54 FailureCallback failure_callback, 52 FailureCallback failure_callback,
55 const base::Time& min_update_time) = 0; 53 const base::Time& min_update_time) = 0;
56 54
57 protected: 55 protected:
58 GDataContactsServiceInterface() {} 56 GDataContactsServiceInterface() {}
59 57
60 private: 58 private:
61 DISALLOW_COPY_AND_ASSIGN(GDataContactsServiceInterface); 59 DISALLOW_COPY_AND_ASSIGN(GDataContactsServiceInterface);
62 }; 60 };
63 61
64 class GDataContactsService : public GDataContactsServiceInterface { 62 class GDataContactsService : public GDataContactsServiceInterface {
65 public: 63 public:
66 typedef base::Callback<std::string(const std::string&)> 64 typedef base::Callback<std::string(const std::string&)>
67 RewritePhotoUrlCallback; 65 RewritePhotoUrlCallback;
68 66
69 GDataContactsService( 67 GDataContactsService(
70 net::URLRequestContextGetter* url_request_context_getter, 68 net::URLRequestContextGetter* url_request_context_getter,
71 Profile* profile); 69 google_apis::AuthServiceInterface* auth_service);
72 virtual ~GDataContactsService(); 70 virtual ~GDataContactsService();
73 71
74 google_apis::AuthService* auth_service_for_testing();
75
76 const std::string& cached_my_contacts_group_id_for_testing() const { 72 const std::string& cached_my_contacts_group_id_for_testing() const {
77 return cached_my_contacts_group_id_; 73 return cached_my_contacts_group_id_;
78 } 74 }
79 void clear_cached_my_contacts_group_id_for_testing() { 75 void clear_cached_my_contacts_group_id_for_testing() {
80 cached_my_contacts_group_id_.clear(); 76 cached_my_contacts_group_id_.clear();
81 } 77 }
82 78
83 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) {
84 max_photo_downloads_per_second_ = max_downloads; 80 max_photo_downloads_per_second_ = max_downloads;
85 } 81 }
86 void set_photo_download_timer_interval_for_testing(base::TimeDelta interval) { 82 void set_photo_download_timer_interval_for_testing(base::TimeDelta interval) {
87 photo_download_timer_interval_ = interval; 83 photo_download_timer_interval_ = interval;
88 } 84 }
89 void set_groups_feed_url_for_testing(const GURL& url) { 85 void set_groups_feed_url_for_testing(const GURL& url) {
90 groups_feed_url_for_testing_ = url; 86 groups_feed_url_for_testing_ = url;
91 } 87 }
92 void set_contacts_feed_url_for_testing(const GURL& url) { 88 void set_contacts_feed_url_for_testing(const GURL& url) {
93 contacts_feed_url_for_testing_ = url; 89 contacts_feed_url_for_testing_ = url;
94 } 90 }
95 void set_rewrite_photo_url_callback_for_testing(RewritePhotoUrlCallback cb) { 91 void set_rewrite_photo_url_callback_for_testing(RewritePhotoUrlCallback cb) {
96 rewrite_photo_url_callback_for_testing_ = cb; 92 rewrite_photo_url_callback_for_testing_ = cb;
97 } 93 }
98 94
99 // Overridden from GDataContactsServiceInterface: 95 // Overridden from GDataContactsServiceInterface:
100 virtual void Initialize() OVERRIDE;
101 virtual void DownloadContacts(SuccessCallback success_callback, 96 virtual void DownloadContacts(SuccessCallback success_callback,
102 FailureCallback failure_callback, 97 FailureCallback failure_callback,
103 const base::Time& min_update_time) OVERRIDE; 98 const base::Time& min_update_time) OVERRIDE;
104 99
105 private: 100 private:
106 class DownloadContactsRequest; 101 class DownloadContactsRequest;
107 102
108 // 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
109 // unsuccessfully). 104 // unsuccessfully).
110 void OnRequestComplete(DownloadContactsRequest* request); 105 void OnRequestComplete(DownloadContactsRequest* request);
(...skipping 24 matching lines...) Expand all
135 // This is needed for tests that serve static feed data from a host/port 130 // This is needed for tests that serve static feed data from a host/port
136 // that's only known at runtime. 131 // that's only known at runtime.
137 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_; 132 RewritePhotoUrlCallback rewrite_photo_url_callback_for_testing_;
138 133
139 DISALLOW_COPY_AND_ASSIGN(GDataContactsService); 134 DISALLOW_COPY_AND_ASSIGN(GDataContactsService);
140 }; 135 };
141 136
142 } // namespace contacts 137 } // namespace contacts
143 138
144 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_GDATA_CONTACTS_SERVICE_H_ 139 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_GDATA_CONTACTS_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/contacts/gdata_contacts_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698