diff options
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/drive/gdata_contacts_requests.cc | 115 | ||||
-rw-r--r-- | google_apis/drive/gdata_contacts_requests.h | 102 | ||||
-rw-r--r-- | google_apis/google_apis.gyp | 2 |
3 files changed, 0 insertions, 219 deletions
diff --git a/google_apis/drive/gdata_contacts_requests.cc b/google_apis/drive/gdata_contacts_requests.cc deleted file mode 100644 index 11419af..0000000 --- a/google_apis/drive/gdata_contacts_requests.cc +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "google_apis/drive/gdata_contacts_requests.h" - -#include "google_apis/drive/time_util.h" -#include "net/base/url_util.h" -#include "url/gurl.h" - -namespace google_apis { - -namespace { - -// URL requesting all contact groups. -const char kGetContactGroupsURL[] = - "https://www.google.com/m8/feeds/groups/default/full?alt=json"; - -// URL requesting all contacts. -// TODO(derat): Per https://goo.gl/AufHP, "The feed may not contain all of the -// user's contacts, because there's a default limit on the number of results -// returned." Decide if 10000 is reasonable or not. -const char kGetContactsURL[] = - "https://www.google.com/m8/feeds/contacts/default/full" - "?alt=json&showdeleted=true&max-results=10000"; - -// Query parameter optionally appended to |kGetContactsURL| to return contacts -// from a specific group (as opposed to all contacts). -const char kGetContactsGroupParam[] = "group"; - -// Query parameter optionally appended to |kGetContactsURL| to return only -// recently-updated contacts. -const char kGetContactsUpdatedMinParam[] = "updated-min"; - -} // namespace - -//========================== GetContactGroupsRequest ========================= - -GetContactGroupsRequest::GetContactGroupsRequest( - RequestSender* runner, - const GetDataCallback& callback) - : GetDataRequest(runner, callback) { -} - -GetContactGroupsRequest::~GetContactGroupsRequest() {} - -GURL GetContactGroupsRequest::GetURL() const { - return !feed_url_for_testing_.is_empty() ? - feed_url_for_testing_ : - GURL(kGetContactGroupsURL); -} - -//============================ GetContactsRequest ============================ - -GetContactsRequest::GetContactsRequest( - RequestSender* runner, - const std::string& group_id, - const base::Time& min_update_time, - const GetDataCallback& callback) - : GetDataRequest(runner, callback), - group_id_(group_id), - min_update_time_(min_update_time) { -} - -GetContactsRequest::~GetContactsRequest() {} - -GURL GetContactsRequest::GetURL() const { - if (!feed_url_for_testing_.is_empty()) - return GURL(feed_url_for_testing_); - - GURL url(kGetContactsURL); - - if (!group_id_.empty()) { - url = net::AppendQueryParameter(url, kGetContactsGroupParam, group_id_); - } - if (!min_update_time_.is_null()) { - std::string time_rfc3339 = util::FormatTimeAsString(min_update_time_); - url = net::AppendQueryParameter( - url, kGetContactsUpdatedMinParam, time_rfc3339); - } - return url; -} - -//========================== GetContactPhotoRequest ========================== - -GetContactPhotoRequest::GetContactPhotoRequest( - RequestSender* runner, - const GURL& photo_url, - const GetContentCallback& callback) - : UrlFetchRequestBase(runner), - photo_url_(photo_url), - callback_(callback) { -} - -GetContactPhotoRequest::~GetContactPhotoRequest() {} - -GURL GetContactPhotoRequest::GetURL() const { - return photo_url_; -} - -void GetContactPhotoRequest::ProcessURLFetchResults( - const net::URLFetcher* source) { - GDataErrorCode code = GetErrorCode(); - scoped_ptr<std::string> data(new std::string(response_writer()->data())); - callback_.Run(code, data.Pass()); - OnProcessURLFetchResultsComplete(); -} - -void GetContactPhotoRequest::RunCallbackOnPrematureFailure( - GDataErrorCode code) { - scoped_ptr<std::string> data(new std::string); - callback_.Run(code, data.Pass()); -} - -} // namespace google_apis diff --git a/google_apis/drive/gdata_contacts_requests.h b/google_apis/drive/gdata_contacts_requests.h deleted file mode 100644 index 05ce693..0000000 --- a/google_apis/drive/gdata_contacts_requests.h +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef GOOGLE_APIS_DRIVE_GDATA_CONTACTS_REQUESTS_H_ -#define GOOGLE_APIS_DRIVE_GDATA_CONTACTS_REQUESTS_H_ - -#include <string> - -#include "base/time/time.h" -#include "google_apis/drive/base_requests.h" - -namespace google_apis { - -//========================== GetContactGroupsRequest ========================= - -// This class fetches a JSON feed containing a user's contact groups. -class GetContactGroupsRequest : public GetDataRequest { - public: - GetContactGroupsRequest(RequestSender* runner, - const GetDataCallback& callback); - virtual ~GetContactGroupsRequest(); - - void set_feed_url_for_testing(const GURL& url) { - feed_url_for_testing_ = url; - } - - protected: - // Overridden from GetDataRequest. - virtual GURL GetURL() const OVERRIDE; - - private: - // If non-empty, URL of the feed to fetch. - GURL feed_url_for_testing_; - - DISALLOW_COPY_AND_ASSIGN(GetContactGroupsRequest); -}; - -//============================ GetContactsRequest ============================ - -// This class fetches a JSON feed containing a user's contacts. -class GetContactsRequest : public GetDataRequest { - public: - GetContactsRequest(RequestSender* runner, - const std::string& group_id, - const base::Time& min_update_time, - const GetDataCallback& callback); - virtual ~GetContactsRequest(); - - void set_feed_url_for_testing(const GURL& url) { - feed_url_for_testing_ = url; - } - - protected: - // Overridden from GetDataRequest. - virtual GURL GetURL() const OVERRIDE; - - private: - // If non-empty, URL of the feed to fetch. - GURL feed_url_for_testing_; - - // If non-empty, contains the ID of the group whose contacts should be - // returned. Group IDs generally look like this: - // http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6 - std::string group_id_; - - // If is_null() is false, contains a minimum last-updated time that will be - // used to filter contacts. - base::Time min_update_time_; - - DISALLOW_COPY_AND_ASSIGN(GetContactsRequest); -}; - -//========================== GetContactPhotoRequest ========================== - -// This class fetches a contact's photo. -class GetContactPhotoRequest : public UrlFetchRequestBase { - public: - GetContactPhotoRequest(RequestSender* runner, - const GURL& photo_url, - const GetContentCallback& callback); - virtual ~GetContactPhotoRequest(); - - protected: - // Overridden from UrlFetchRequestBase. - virtual GURL GetURL() const OVERRIDE; - virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; - virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; - - private: - // Location of the photo to fetch. - GURL photo_url_; - - // Callback to which the photo data is passed. - GetContentCallback callback_; - - DISALLOW_COPY_AND_ASSIGN(GetContactPhotoRequest); -}; - -} // namespace google_apis - -#endif // GOOGLE_APIS_DRIVE_GDATA_CONTACTS_REQUESTS_H_ diff --git a/google_apis/google_apis.gyp b/google_apis/google_apis.gyp index 0ffe906..be4d517 100644 --- a/google_apis/google_apis.gyp +++ b/google_apis/google_apis.gyp @@ -79,8 +79,6 @@ 'drive/drive_api_url_generator.h', 'drive/drive_common_callbacks.h', 'drive/drive_entry_kinds.h', - 'drive/gdata_contacts_requests.cc', - 'drive/gdata_contacts_requests.h', 'drive/gdata_errorcode.cc', 'drive/gdata_errorcode.h', 'drive/gdata_wapi_requests.cc', |