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

Side by Side Diff: chrome/browser/google_apis/gdata_contacts_requests.cc

Issue 96413002: Move c/b/google_apis to google_apis/drive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years 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
OLDNEW
(Empty)
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 #include "chrome/browser/google_apis/gdata_contacts_requests.h"
6
7 #include "chrome/browser/google_apis/time_util.h"
8 #include "net/base/url_util.h"
9 #include "url/gurl.h"
10
11 namespace google_apis {
12
13 namespace {
14
15 // URL requesting all contact groups.
16 const char kGetContactGroupsURL[] =
17 "https://www.google.com/m8/feeds/groups/default/full?alt=json";
18
19 // URL requesting all contacts.
20 // TODO(derat): Per https://goo.gl/AufHP, "The feed may not contain all of the
21 // user's contacts, because there's a default limit on the number of results
22 // returned." Decide if 10000 is reasonable or not.
23 const char kGetContactsURL[] =
24 "https://www.google.com/m8/feeds/contacts/default/full"
25 "?alt=json&showdeleted=true&max-results=10000";
26
27 // Query parameter optionally appended to |kGetContactsURL| to return contacts
28 // from a specific group (as opposed to all contacts).
29 const char kGetContactsGroupParam[] = "group";
30
31 // Query parameter optionally appended to |kGetContactsURL| to return only
32 // recently-updated contacts.
33 const char kGetContactsUpdatedMinParam[] = "updated-min";
34
35 } // namespace
36
37 //========================== GetContactGroupsRequest =========================
38
39 GetContactGroupsRequest::GetContactGroupsRequest(
40 RequestSender* runner,
41 const GetDataCallback& callback)
42 : GetDataRequest(runner, callback) {
43 }
44
45 GetContactGroupsRequest::~GetContactGroupsRequest() {}
46
47 GURL GetContactGroupsRequest::GetURL() const {
48 return !feed_url_for_testing_.is_empty() ?
49 feed_url_for_testing_ :
50 GURL(kGetContactGroupsURL);
51 }
52
53 //============================ GetContactsRequest ============================
54
55 GetContactsRequest::GetContactsRequest(
56 RequestSender* runner,
57 const std::string& group_id,
58 const base::Time& min_update_time,
59 const GetDataCallback& callback)
60 : GetDataRequest(runner, callback),
61 group_id_(group_id),
62 min_update_time_(min_update_time) {
63 }
64
65 GetContactsRequest::~GetContactsRequest() {}
66
67 GURL GetContactsRequest::GetURL() const {
68 if (!feed_url_for_testing_.is_empty())
69 return GURL(feed_url_for_testing_);
70
71 GURL url(kGetContactsURL);
72
73 if (!group_id_.empty()) {
74 url = net::AppendQueryParameter(url, kGetContactsGroupParam, group_id_);
75 }
76 if (!min_update_time_.is_null()) {
77 std::string time_rfc3339 = util::FormatTimeAsString(min_update_time_);
78 url = net::AppendQueryParameter(
79 url, kGetContactsUpdatedMinParam, time_rfc3339);
80 }
81 return url;
82 }
83
84 //========================== GetContactPhotoRequest ==========================
85
86 GetContactPhotoRequest::GetContactPhotoRequest(
87 RequestSender* runner,
88 const GURL& photo_url,
89 const GetContentCallback& callback)
90 : UrlFetchRequestBase(runner),
91 photo_url_(photo_url),
92 callback_(callback) {
93 }
94
95 GetContactPhotoRequest::~GetContactPhotoRequest() {}
96
97 GURL GetContactPhotoRequest::GetURL() const {
98 return photo_url_;
99 }
100
101 void GetContactPhotoRequest::ProcessURLFetchResults(
102 const net::URLFetcher* source) {
103 GDataErrorCode code = GetErrorCode();
104 scoped_ptr<std::string> data(new std::string(response_writer()->data()));
105 callback_.Run(code, data.Pass());
106 OnProcessURLFetchResultsComplete();
107 }
108
109 void GetContactPhotoRequest::RunCallbackOnPrematureFailure(
110 GDataErrorCode code) {
111 scoped_ptr<std::string> data(new std::string);
112 callback_.Run(code, data.Pass());
113 }
114
115 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_contacts_requests.h ('k') | chrome/browser/google_apis/gdata_errorcode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698