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