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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_
6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_
10 #include "chrome/browser/google_apis/base_operations.h"
13 class URLRequestContextGetter
;
16 namespace google_apis
{
18 //========================== GetContactGroupsOperation =========================
20 // This class fetches a JSON feed containing a user's contact groups.
21 class GetContactGroupsOperation
: public GetDataOperation
{
23 GetContactGroupsOperation(
24 OperationRegistry
* registry
,
25 net::URLRequestContextGetter
* url_request_context_getter
,
26 const GetDataCallback
& callback
);
27 virtual ~GetContactGroupsOperation();
29 void set_feed_url_for_testing(const GURL
& url
) {
30 feed_url_for_testing_
= url
;
34 // Overridden from GetDataOperation.
35 virtual GURL
GetURL() const OVERRIDE
;
38 // If non-empty, URL of the feed to fetch.
39 GURL feed_url_for_testing_
;
41 DISALLOW_COPY_AND_ASSIGN(GetContactGroupsOperation
);
44 //============================ GetContactsOperation ============================
46 // This class fetches a JSON feed containing a user's contacts.
47 class GetContactsOperation
: public GetDataOperation
{
50 OperationRegistry
* registry
,
51 net::URLRequestContextGetter
* url_request_context_getter
,
52 const std::string
& group_id
,
53 const base::Time
& min_update_time
,
54 const GetDataCallback
& callback
);
55 virtual ~GetContactsOperation();
57 void set_feed_url_for_testing(const GURL
& url
) {
58 feed_url_for_testing_
= url
;
62 // Overridden from GetDataOperation.
63 virtual GURL
GetURL() const OVERRIDE
;
66 // If non-empty, URL of the feed to fetch.
67 GURL feed_url_for_testing_
;
69 // If non-empty, contains the ID of the group whose contacts should be
70 // returned. Group IDs generally look like this:
71 // http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6
72 std::string group_id_
;
74 // If is_null() is false, contains a minimum last-updated time that will be
75 // used to filter contacts.
76 base::Time min_update_time_
;
78 DISALLOW_COPY_AND_ASSIGN(GetContactsOperation
);
81 //========================== GetContactPhotoOperation ==========================
83 // This class fetches a contact's photo.
84 class GetContactPhotoOperation
: public UrlFetchOperationBase
{
86 GetContactPhotoOperation(
87 OperationRegistry
* registry
,
88 net::URLRequestContextGetter
* url_request_context_getter
,
89 const GURL
& photo_url
,
90 const GetContentCallback
& callback
);
91 virtual ~GetContactPhotoOperation();
94 // Overridden from UrlFetchOperationBase.
95 virtual GURL
GetURL() const OVERRIDE
;
96 virtual void ProcessURLFetchResults(const net::URLFetcher
* source
) OVERRIDE
;
97 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code
) OVERRIDE
;
100 // Location of the photo to fetch.
103 // Callback to which the photo data is passed.
104 GetContentCallback callback_
;
106 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation
);
109 } // namespace google_apis
111 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_CONTACTS_OPERATIONS_H_