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 #include "chrome/browser/google_apis/gdata_contacts_operations.h" | 5 #include "chrome/browser/google_apis/gdata_contacts_operations.h" |
6 | 6 |
7 #include "chrome/browser/google_apis/time_util.h" | 7 #include "chrome/browser/google_apis/time_util.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "net/base/url_util.h" | 9 #include "net/base/url_util.h" |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 const char kGetContactsUpdatedMinParam[] = "updated-min"; | 33 const char kGetContactsUpdatedMinParam[] = "updated-min"; |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 //========================== GetContactGroupsOperation ========================= | 37 //========================== GetContactGroupsOperation ========================= |
38 | 38 |
39 GetContactGroupsOperation::GetContactGroupsOperation( | 39 GetContactGroupsOperation::GetContactGroupsOperation( |
40 OperationRunner* runner, | 40 OperationRunner* runner, |
41 net::URLRequestContextGetter* url_request_context_getter, | 41 net::URLRequestContextGetter* url_request_context_getter, |
42 const GetDataCallback& callback) | 42 const GetDataCallback& callback) |
43 : GetDataOperation(runner, url_request_context_getter, callback) { | 43 : GetDataRequest(runner, url_request_context_getter, callback) { |
44 } | 44 } |
45 | 45 |
46 GetContactGroupsOperation::~GetContactGroupsOperation() {} | 46 GetContactGroupsOperation::~GetContactGroupsOperation() {} |
47 | 47 |
48 GURL GetContactGroupsOperation::GetURL() const { | 48 GURL GetContactGroupsOperation::GetURL() const { |
49 return !feed_url_for_testing_.is_empty() ? | 49 return !feed_url_for_testing_.is_empty() ? |
50 feed_url_for_testing_ : | 50 feed_url_for_testing_ : |
51 GURL(kGetContactGroupsURL); | 51 GURL(kGetContactGroupsURL); |
52 } | 52 } |
53 | 53 |
54 //============================ GetContactsOperation ============================ | 54 //============================ GetContactsOperation ============================ |
55 | 55 |
56 GetContactsOperation::GetContactsOperation( | 56 GetContactsOperation::GetContactsOperation( |
57 OperationRunner* runner, | 57 OperationRunner* runner, |
58 net::URLRequestContextGetter* url_request_context_getter, | 58 net::URLRequestContextGetter* url_request_context_getter, |
59 const std::string& group_id, | 59 const std::string& group_id, |
60 const base::Time& min_update_time, | 60 const base::Time& min_update_time, |
61 const GetDataCallback& callback) | 61 const GetDataCallback& callback) |
62 : GetDataOperation(runner, url_request_context_getter, callback), | 62 : GetDataRequest(runner, url_request_context_getter, callback), |
63 group_id_(group_id), | 63 group_id_(group_id), |
64 min_update_time_(min_update_time) { | 64 min_update_time_(min_update_time) { |
65 } | 65 } |
66 | 66 |
67 GetContactsOperation::~GetContactsOperation() {} | 67 GetContactsOperation::~GetContactsOperation() {} |
68 | 68 |
69 GURL GetContactsOperation::GetURL() const { | 69 GURL GetContactsOperation::GetURL() const { |
70 if (!feed_url_for_testing_.is_empty()) | 70 if (!feed_url_for_testing_.is_empty()) |
71 return GURL(feed_url_for_testing_); | 71 return GURL(feed_url_for_testing_); |
72 | 72 |
(...skipping 10 matching lines...) Expand all Loading... |
83 return url; | 83 return url; |
84 } | 84 } |
85 | 85 |
86 //========================== GetContactPhotoOperation ========================== | 86 //========================== GetContactPhotoOperation ========================== |
87 | 87 |
88 GetContactPhotoOperation::GetContactPhotoOperation( | 88 GetContactPhotoOperation::GetContactPhotoOperation( |
89 OperationRunner* runner, | 89 OperationRunner* runner, |
90 net::URLRequestContextGetter* url_request_context_getter, | 90 net::URLRequestContextGetter* url_request_context_getter, |
91 const GURL& photo_url, | 91 const GURL& photo_url, |
92 const GetContentCallback& callback) | 92 const GetContentCallback& callback) |
93 : UrlFetchOperationBase(runner, url_request_context_getter), | 93 : UrlFetchRequestBase(runner, url_request_context_getter), |
94 photo_url_(photo_url), | 94 photo_url_(photo_url), |
95 callback_(callback) { | 95 callback_(callback) { |
96 } | 96 } |
97 | 97 |
98 GetContactPhotoOperation::~GetContactPhotoOperation() {} | 98 GetContactPhotoOperation::~GetContactPhotoOperation() {} |
99 | 99 |
100 GURL GetContactPhotoOperation::GetURL() const { | 100 GURL GetContactPhotoOperation::GetURL() const { |
101 return photo_url_; | 101 return photo_url_; |
102 } | 102 } |
103 | 103 |
104 void GetContactPhotoOperation::ProcessURLFetchResults( | 104 void GetContactPhotoOperation::ProcessURLFetchResults( |
105 const net::URLFetcher* source) { | 105 const net::URLFetcher* source) { |
106 GDataErrorCode code = GetErrorCode(source); | 106 GDataErrorCode code = GetErrorCode(source); |
107 scoped_ptr<std::string> data(new std::string); | 107 scoped_ptr<std::string> data(new std::string); |
108 source->GetResponseAsString(data.get()); | 108 source->GetResponseAsString(data.get()); |
109 callback_.Run(code, data.Pass()); | 109 callback_.Run(code, data.Pass()); |
110 OnProcessURLFetchResultsComplete(code == HTTP_SUCCESS); | 110 OnProcessURLFetchResultsComplete(code == HTTP_SUCCESS); |
111 } | 111 } |
112 | 112 |
113 void GetContactPhotoOperation::RunCallbackOnPrematureFailure( | 113 void GetContactPhotoOperation::RunCallbackOnPrematureFailure( |
114 GDataErrorCode code) { | 114 GDataErrorCode code) { |
115 scoped_ptr<std::string> data(new std::string); | 115 scoped_ptr<std::string> data(new std::string); |
116 callback_.Run(code, data.Pass()); | 116 callback_.Run(code, data.Pass()); |
117 } | 117 } |
118 | 118 |
119 } // namespace google_apis | 119 } // namespace google_apis |
OLD | NEW |