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_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/google_apis/base_operations.h" | 10 #include "chrome/browser/google_apis/base_requests.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 class URLRequestContextGetter; | 13 class URLRequestContextGetter; |
14 } // namespace net | 14 } // namespace net |
15 | 15 |
16 namespace google_apis { | 16 namespace google_apis { |
17 | 17 |
18 //========================== GetContactGroupsOperation ========================= | 18 //========================== GetContactGroupsOperation ========================= |
19 | 19 |
20 // This class fetches a JSON feed containing a user's contact groups. | 20 // This class fetches a JSON feed containing a user's contact groups. |
21 class GetContactGroupsOperation : public GetDataOperation { | 21 class GetContactGroupsOperation : public GetDataRequest { |
22 public: | 22 public: |
23 GetContactGroupsOperation( | 23 GetContactGroupsOperation( |
24 OperationRunner* runner, | 24 OperationRunner* runner, |
25 net::URLRequestContextGetter* url_request_context_getter, | 25 net::URLRequestContextGetter* url_request_context_getter, |
26 const GetDataCallback& callback); | 26 const GetDataCallback& callback); |
27 virtual ~GetContactGroupsOperation(); | 27 virtual ~GetContactGroupsOperation(); |
28 | 28 |
29 void set_feed_url_for_testing(const GURL& url) { | 29 void set_feed_url_for_testing(const GURL& url) { |
30 feed_url_for_testing_ = url; | 30 feed_url_for_testing_ = url; |
31 } | 31 } |
32 | 32 |
33 protected: | 33 protected: |
34 // Overridden from GetDataOperation. | 34 // Overridden from GetDataRequest. |
35 virtual GURL GetURL() const OVERRIDE; | 35 virtual GURL GetURL() const OVERRIDE; |
36 | 36 |
37 private: | 37 private: |
38 // If non-empty, URL of the feed to fetch. | 38 // If non-empty, URL of the feed to fetch. |
39 GURL feed_url_for_testing_; | 39 GURL feed_url_for_testing_; |
40 | 40 |
41 DISALLOW_COPY_AND_ASSIGN(GetContactGroupsOperation); | 41 DISALLOW_COPY_AND_ASSIGN(GetContactGroupsOperation); |
42 }; | 42 }; |
43 | 43 |
44 //============================ GetContactsOperation ============================ | 44 //============================ GetContactsOperation ============================ |
45 | 45 |
46 // This class fetches a JSON feed containing a user's contacts. | 46 // This class fetches a JSON feed containing a user's contacts. |
47 class GetContactsOperation : public GetDataOperation { | 47 class GetContactsOperation : public GetDataRequest { |
48 public: | 48 public: |
49 GetContactsOperation( | 49 GetContactsOperation( |
50 OperationRunner* runner, | 50 OperationRunner* runner, |
51 net::URLRequestContextGetter* url_request_context_getter, | 51 net::URLRequestContextGetter* url_request_context_getter, |
52 const std::string& group_id, | 52 const std::string& group_id, |
53 const base::Time& min_update_time, | 53 const base::Time& min_update_time, |
54 const GetDataCallback& callback); | 54 const GetDataCallback& callback); |
55 virtual ~GetContactsOperation(); | 55 virtual ~GetContactsOperation(); |
56 | 56 |
57 void set_feed_url_for_testing(const GURL& url) { | 57 void set_feed_url_for_testing(const GURL& url) { |
58 feed_url_for_testing_ = url; | 58 feed_url_for_testing_ = url; |
59 } | 59 } |
60 | 60 |
61 protected: | 61 protected: |
62 // Overridden from GetDataOperation. | 62 // Overridden from GetDataRequest. |
63 virtual GURL GetURL() const OVERRIDE; | 63 virtual GURL GetURL() const OVERRIDE; |
64 | 64 |
65 private: | 65 private: |
66 // If non-empty, URL of the feed to fetch. | 66 // If non-empty, URL of the feed to fetch. |
67 GURL feed_url_for_testing_; | 67 GURL feed_url_for_testing_; |
68 | 68 |
69 // If non-empty, contains the ID of the group whose contacts should be | 69 // If non-empty, contains the ID of the group whose contacts should be |
70 // returned. Group IDs generally look like this: | 70 // returned. Group IDs generally look like this: |
71 // http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6 | 71 // http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6 |
72 std::string group_id_; | 72 std::string group_id_; |
73 | 73 |
74 // If is_null() is false, contains a minimum last-updated time that will be | 74 // If is_null() is false, contains a minimum last-updated time that will be |
75 // used to filter contacts. | 75 // used to filter contacts. |
76 base::Time min_update_time_; | 76 base::Time min_update_time_; |
77 | 77 |
78 DISALLOW_COPY_AND_ASSIGN(GetContactsOperation); | 78 DISALLOW_COPY_AND_ASSIGN(GetContactsOperation); |
79 }; | 79 }; |
80 | 80 |
81 //========================== GetContactPhotoOperation ========================== | 81 //========================== GetContactPhotoOperation ========================== |
82 | 82 |
83 // This class fetches a contact's photo. | 83 // This class fetches a contact's photo. |
84 class GetContactPhotoOperation : public UrlFetchOperationBase { | 84 class GetContactPhotoOperation : public UrlFetchRequestBase { |
85 public: | 85 public: |
86 GetContactPhotoOperation( | 86 GetContactPhotoOperation( |
87 OperationRunner* runner, | 87 OperationRunner* runner, |
88 net::URLRequestContextGetter* url_request_context_getter, | 88 net::URLRequestContextGetter* url_request_context_getter, |
89 const GURL& photo_url, | 89 const GURL& photo_url, |
90 const GetContentCallback& callback); | 90 const GetContentCallback& callback); |
91 virtual ~GetContactPhotoOperation(); | 91 virtual ~GetContactPhotoOperation(); |
92 | 92 |
93 protected: | 93 protected: |
94 // Overridden from UrlFetchOperationBase. | 94 // Overridden from UrlFetchRequestBase. |
95 virtual GURL GetURL() const OVERRIDE; | 95 virtual GURL GetURL() const OVERRIDE; |
96 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | 96 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
97 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; | 97 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; |
98 | 98 |
99 private: | 99 private: |
100 // Location of the photo to fetch. | 100 // Location of the photo to fetch. |
101 GURL photo_url_; | 101 GURL photo_url_; |
102 | 102 |
103 // Callback to which the photo data is passed. | 103 // Callback to which the photo data is passed. |
104 GetContentCallback callback_; | 104 GetContentCallback callback_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); | 106 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); |
107 }; | 107 }; |
108 | 108 |
109 } // namespace google_apis | 109 } // namespace google_apis |
110 | 110 |
111 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_ | 111 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_ |
OLD | NEW |