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 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/google_apis/base_operations.h" | 11 #include "chrome/browser/google_apis/base_requests.h" |
12 #include "chrome/browser/google_apis/drive_service_interface.h" | 12 #include "chrome/browser/google_apis/drive_service_interface.h" |
13 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" | 13 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 class URLRequestContextGetter; | 16 class URLRequestContextGetter; |
17 } // namespace net | 17 } // namespace net |
18 | 18 |
19 namespace google_apis { | 19 namespace google_apis { |
20 | 20 |
21 class AccountMetadata; | 21 class AccountMetadata; |
22 class GDataWapiUrlGenerator; | 22 class GDataWapiUrlGenerator; |
23 class ResourceEntry; | 23 class ResourceEntry; |
24 | 24 |
25 //============================ GetResourceListOperation ======================== | 25 //============================ GetResourceListOperation ======================== |
26 | 26 |
27 // This class performs the operation for fetching a resource list. | 27 // This class performs the operation for fetching a resource list. |
28 class GetResourceListOperation : public GetDataOperation { | 28 class GetResourceListOperation : public GetDataRequest { |
29 public: | 29 public: |
30 // override_url: | 30 // override_url: |
31 // If empty, a hard-coded base URL of the WAPI server is used to fetch | 31 // If empty, a hard-coded base URL of the WAPI server is used to fetch |
32 // the first page of the feed. This parameter is used for fetching 2nd | 32 // the first page of the feed. This parameter is used for fetching 2nd |
33 // page and onward. | 33 // page and onward. |
34 // | 34 // |
35 // start_changestamp: | 35 // start_changestamp: |
36 // This parameter specifies the starting point of a delta feed or 0 if a | 36 // This parameter specifies the starting point of a delta feed or 0 if a |
37 // full feed is necessary. | 37 // full feed is necessary. |
38 // | 38 // |
(...skipping 11 matching lines...) Expand all Loading... |
50 net::URLRequestContextGetter* url_request_context_getter, | 50 net::URLRequestContextGetter* url_request_context_getter, |
51 const GDataWapiUrlGenerator& url_generator, | 51 const GDataWapiUrlGenerator& url_generator, |
52 const GURL& override_url, | 52 const GURL& override_url, |
53 int64 start_changestamp, | 53 int64 start_changestamp, |
54 const std::string& search_string, | 54 const std::string& search_string, |
55 const std::string& directory_resource_id, | 55 const std::string& directory_resource_id, |
56 const GetResourceListCallback& callback); | 56 const GetResourceListCallback& callback); |
57 virtual ~GetResourceListOperation(); | 57 virtual ~GetResourceListOperation(); |
58 | 58 |
59 protected: | 59 protected: |
60 // UrlFetchOperationBase overrides. | 60 // UrlFetchRequestBase overrides. |
61 virtual GURL GetURL() const OVERRIDE; | 61 virtual GURL GetURL() const OVERRIDE; |
62 | 62 |
63 private: | 63 private: |
64 const GDataWapiUrlGenerator url_generator_; | 64 const GDataWapiUrlGenerator url_generator_; |
65 const GURL override_url_; | 65 const GURL override_url_; |
66 const int64 start_changestamp_; | 66 const int64 start_changestamp_; |
67 const std::string search_string_; | 67 const std::string search_string_; |
68 const std::string directory_resource_id_; | 68 const std::string directory_resource_id_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(GetResourceListOperation); | 70 DISALLOW_COPY_AND_ASSIGN(GetResourceListOperation); |
71 }; | 71 }; |
72 | 72 |
73 //============================ SearchByTitleOperation ========================== | 73 //============================ SearchByTitleOperation ========================== |
74 | 74 |
75 // This class performs the operation for searching resources by title. | 75 // This class performs the operation for searching resources by title. |
76 class SearchByTitleOperation : public GetDataOperation { | 76 class SearchByTitleOperation : public GetDataRequest { |
77 public: | 77 public: |
78 // title: the search query. | 78 // title: the search query. |
79 // | 79 // |
80 // directory_resource_id: If given (non-empty), the search target is | 80 // directory_resource_id: If given (non-empty), the search target is |
81 // directly under the directory with the |directory_resource_id|. | 81 // directly under the directory with the |directory_resource_id|. |
82 // If empty, the search target is all the existing resources. | 82 // If empty, the search target is all the existing resources. |
83 // | 83 // |
84 // callback: | 84 // callback: |
85 // Called once the feed is fetched. Must not be null. | 85 // Called once the feed is fetched. Must not be null. |
86 SearchByTitleOperation( | 86 SearchByTitleOperation( |
87 OperationRunner* runner, | 87 OperationRunner* runner, |
88 net::URLRequestContextGetter* url_request_context_getter, | 88 net::URLRequestContextGetter* url_request_context_getter, |
89 const GDataWapiUrlGenerator& url_generator, | 89 const GDataWapiUrlGenerator& url_generator, |
90 const std::string& title, | 90 const std::string& title, |
91 const std::string& directory_resource_id, | 91 const std::string& directory_resource_id, |
92 const GetResourceListCallback& callback); | 92 const GetResourceListCallback& callback); |
93 virtual ~SearchByTitleOperation(); | 93 virtual ~SearchByTitleOperation(); |
94 | 94 |
95 protected: | 95 protected: |
96 // UrlFetchOperationBase overrides. | 96 // UrlFetchRequestBase overrides. |
97 virtual GURL GetURL() const OVERRIDE; | 97 virtual GURL GetURL() const OVERRIDE; |
98 | 98 |
99 private: | 99 private: |
100 const GDataWapiUrlGenerator url_generator_; | 100 const GDataWapiUrlGenerator url_generator_; |
101 const std::string title_; | 101 const std::string title_; |
102 const std::string directory_resource_id_; | 102 const std::string directory_resource_id_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(SearchByTitleOperation); | 104 DISALLOW_COPY_AND_ASSIGN(SearchByTitleOperation); |
105 }; | 105 }; |
106 | 106 |
107 //========================= GetResourceEntryOperation ========================== | 107 //========================= GetResourceEntryOperation ========================== |
108 | 108 |
109 // This class performs the operation for fetching a single resource entry. | 109 // This class performs the operation for fetching a single resource entry. |
110 class GetResourceEntryOperation : public GetDataOperation { | 110 class GetResourceEntryOperation : public GetDataRequest { |
111 public: | 111 public: |
112 // |callback| must not be null. | 112 // |callback| must not be null. |
113 GetResourceEntryOperation( | 113 GetResourceEntryOperation( |
114 OperationRunner* runner, | 114 OperationRunner* runner, |
115 net::URLRequestContextGetter* url_request_context_getter, | 115 net::URLRequestContextGetter* url_request_context_getter, |
116 const GDataWapiUrlGenerator& url_generator, | 116 const GDataWapiUrlGenerator& url_generator, |
117 const std::string& resource_id, | 117 const std::string& resource_id, |
118 const GetDataCallback& callback); | 118 const GetDataCallback& callback); |
119 virtual ~GetResourceEntryOperation(); | 119 virtual ~GetResourceEntryOperation(); |
120 | 120 |
121 protected: | 121 protected: |
122 // UrlFetchOperationBase overrides. | 122 // UrlFetchRequestBase overrides. |
123 virtual GURL GetURL() const OVERRIDE; | 123 virtual GURL GetURL() const OVERRIDE; |
124 | 124 |
125 private: | 125 private: |
126 const GDataWapiUrlGenerator url_generator_; | 126 const GDataWapiUrlGenerator url_generator_; |
127 // Resource id of the requested entry. | 127 // Resource id of the requested entry. |
128 const std::string resource_id_; | 128 const std::string resource_id_; |
129 | 129 |
130 DISALLOW_COPY_AND_ASSIGN(GetResourceEntryOperation); | 130 DISALLOW_COPY_AND_ASSIGN(GetResourceEntryOperation); |
131 }; | 131 }; |
132 | 132 |
133 //========================= GetAccountMetadataOperation ======================== | 133 //========================= GetAccountMetadataOperation ======================== |
134 | 134 |
135 // Callback used for GetAccountMetadata(). | 135 // Callback used for GetAccountMetadata(). |
136 typedef base::Callback<void(GDataErrorCode error, | 136 typedef base::Callback<void(GDataErrorCode error, |
137 scoped_ptr<AccountMetadata> account_metadata)> | 137 scoped_ptr<AccountMetadata> account_metadata)> |
138 GetAccountMetadataCallback; | 138 GetAccountMetadataCallback; |
139 | 139 |
140 // This class performs the operation for fetching account metadata. | 140 // This class performs the operation for fetching account metadata. |
141 class GetAccountMetadataOperation : public GetDataOperation { | 141 class GetAccountMetadataOperation : public GetDataRequest { |
142 public: | 142 public: |
143 // If |include_installed_apps| is set to true, the result should include | 143 // If |include_installed_apps| is set to true, the result should include |
144 // the list of installed third party applications. | 144 // the list of installed third party applications. |
145 // |callback| must not be null. | 145 // |callback| must not be null. |
146 GetAccountMetadataOperation( | 146 GetAccountMetadataOperation( |
147 OperationRunner* runner, | 147 OperationRunner* runner, |
148 net::URLRequestContextGetter* url_request_context_getter, | 148 net::URLRequestContextGetter* url_request_context_getter, |
149 const GDataWapiUrlGenerator& url_generator, | 149 const GDataWapiUrlGenerator& url_generator, |
150 const GetAccountMetadataCallback& callback, | 150 const GetAccountMetadataCallback& callback, |
151 bool include_installed_apps); | 151 bool include_installed_apps); |
152 virtual ~GetAccountMetadataOperation(); | 152 virtual ~GetAccountMetadataOperation(); |
153 | 153 |
154 protected: | 154 protected: |
155 // UrlFetchOperationBase overrides. | 155 // UrlFetchRequestBase overrides. |
156 virtual GURL GetURL() const OVERRIDE; | 156 virtual GURL GetURL() const OVERRIDE; |
157 | 157 |
158 private: | 158 private: |
159 const GDataWapiUrlGenerator url_generator_; | 159 const GDataWapiUrlGenerator url_generator_; |
160 const bool include_installed_apps_; | 160 const bool include_installed_apps_; |
161 | 161 |
162 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); | 162 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); |
163 }; | 163 }; |
164 | 164 |
165 //=========================== DeleteResourceOperation ========================== | 165 //=========================== DeleteResourceOperation ========================== |
166 | 166 |
167 // This class performs the operation for deleting a resource. | 167 // This class performs the operation for deleting a resource. |
168 // | 168 // |
169 // In WAPI, "gd:deleted" means that the resource was put in the trash, and | 169 // In WAPI, "gd:deleted" means that the resource was put in the trash, and |
170 // "docs:removed" means its permanently gone. Since what the class does is to | 170 // "docs:removed" means its permanently gone. Since what the class does is to |
171 // put the resource into trash, we have chosen "Delete" in the name, even though | 171 // put the resource into trash, we have chosen "Delete" in the name, even though |
172 // we are preferring the term "Remove" in drive/google_api code. | 172 // we are preferring the term "Remove" in drive/google_api code. |
173 class DeleteResourceOperation : public EntryActionOperation { | 173 class DeleteResourceOperation : public EntryActionRequest { |
174 public: | 174 public: |
175 // |callback| must not be null. | 175 // |callback| must not be null. |
176 DeleteResourceOperation( | 176 DeleteResourceOperation( |
177 OperationRunner* runner, | 177 OperationRunner* runner, |
178 net::URLRequestContextGetter* url_request_context_getter, | 178 net::URLRequestContextGetter* url_request_context_getter, |
179 const GDataWapiUrlGenerator& url_generator, | 179 const GDataWapiUrlGenerator& url_generator, |
180 const EntryActionCallback& callback, | 180 const EntryActionCallback& callback, |
181 const std::string& resource_id, | 181 const std::string& resource_id, |
182 const std::string& etag); | 182 const std::string& etag); |
183 virtual ~DeleteResourceOperation(); | 183 virtual ~DeleteResourceOperation(); |
184 | 184 |
185 protected: | 185 protected: |
186 // UrlFetchOperationBase overrides. | 186 // UrlFetchRequestBase overrides. |
187 virtual GURL GetURL() const OVERRIDE; | 187 virtual GURL GetURL() const OVERRIDE; |
188 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 188 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
189 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 189 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
190 | 190 |
191 private: | 191 private: |
192 const GDataWapiUrlGenerator url_generator_; | 192 const GDataWapiUrlGenerator url_generator_; |
193 const std::string resource_id_; | 193 const std::string resource_id_; |
194 const std::string etag_; | 194 const std::string etag_; |
195 | 195 |
196 DISALLOW_COPY_AND_ASSIGN(DeleteResourceOperation); | 196 DISALLOW_COPY_AND_ASSIGN(DeleteResourceOperation); |
197 }; | 197 }; |
198 | 198 |
199 //========================== CreateDirectoryOperation ========================== | 199 //========================== CreateDirectoryOperation ========================== |
200 | 200 |
201 // This class performs the operation for creating a directory. | 201 // This class performs the operation for creating a directory. |
202 class CreateDirectoryOperation : public GetDataOperation { | 202 class CreateDirectoryOperation : public GetDataRequest { |
203 public: | 203 public: |
204 // A new directory will be created under a directory specified by | 204 // A new directory will be created under a directory specified by |
205 // |parent_resource_id|. If this parameter is empty, a new directory will | 205 // |parent_resource_id|. If this parameter is empty, a new directory will |
206 // be created in the root directory. | 206 // be created in the root directory. |
207 // |callback| must not be null. | 207 // |callback| must not be null. |
208 CreateDirectoryOperation( | 208 CreateDirectoryOperation( |
209 OperationRunner* runner, | 209 OperationRunner* runner, |
210 net::URLRequestContextGetter* url_request_context_getter, | 210 net::URLRequestContextGetter* url_request_context_getter, |
211 const GDataWapiUrlGenerator& url_generator, | 211 const GDataWapiUrlGenerator& url_generator, |
212 const GetDataCallback& callback, | 212 const GetDataCallback& callback, |
213 const std::string& parent_resource_id, | 213 const std::string& parent_resource_id, |
214 const std::string& directory_name); | 214 const std::string& directory_name); |
215 virtual ~CreateDirectoryOperation(); | 215 virtual ~CreateDirectoryOperation(); |
216 | 216 |
217 protected: | 217 protected: |
218 // UrlFetchOperationBase overrides. | 218 // UrlFetchRequestBase overrides. |
219 virtual GURL GetURL() const OVERRIDE; | 219 virtual GURL GetURL() const OVERRIDE; |
220 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 220 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
221 virtual bool GetContentData(std::string* upload_content_type, | 221 virtual bool GetContentData(std::string* upload_content_type, |
222 std::string* upload_content) OVERRIDE; | 222 std::string* upload_content) OVERRIDE; |
223 | 223 |
224 private: | 224 private: |
225 const GDataWapiUrlGenerator url_generator_; | 225 const GDataWapiUrlGenerator url_generator_; |
226 const std::string parent_resource_id_; | 226 const std::string parent_resource_id_; |
227 const std::string directory_name_; | 227 const std::string directory_name_; |
228 | 228 |
229 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryOperation); | 229 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryOperation); |
230 }; | 230 }; |
231 | 231 |
232 //============================ CopyHostedDocumentOperation ===================== | 232 //============================ CopyHostedDocumentOperation ===================== |
233 | 233 |
234 // This class performs the operation for making a copy of a hosted document. | 234 // This class performs the operation for making a copy of a hosted document. |
235 // Note that this function cannot be used to copy regular files, as it's not | 235 // Note that this function cannot be used to copy regular files, as it's not |
236 // supported by WAPI. | 236 // supported by WAPI. |
237 class CopyHostedDocumentOperation : public GetDataOperation { | 237 class CopyHostedDocumentOperation : public GetDataRequest { |
238 public: | 238 public: |
239 // |callback| must not be null. | 239 // |callback| must not be null. |
240 CopyHostedDocumentOperation( | 240 CopyHostedDocumentOperation( |
241 OperationRunner* runner, | 241 OperationRunner* runner, |
242 net::URLRequestContextGetter* url_request_context_getter, | 242 net::URLRequestContextGetter* url_request_context_getter, |
243 const GDataWapiUrlGenerator& url_generator, | 243 const GDataWapiUrlGenerator& url_generator, |
244 const GetDataCallback& callback, | 244 const GetDataCallback& callback, |
245 const std::string& resource_id, | 245 const std::string& resource_id, |
246 const std::string& new_name); | 246 const std::string& new_name); |
247 virtual ~CopyHostedDocumentOperation(); | 247 virtual ~CopyHostedDocumentOperation(); |
248 | 248 |
249 protected: | 249 protected: |
250 // UrlFetchOperationBase overrides. | 250 // UrlFetchRequestBase overrides. |
251 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 251 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
252 virtual GURL GetURL() const OVERRIDE; | 252 virtual GURL GetURL() const OVERRIDE; |
253 virtual bool GetContentData(std::string* upload_content_type, | 253 virtual bool GetContentData(std::string* upload_content_type, |
254 std::string* upload_content) OVERRIDE; | 254 std::string* upload_content) OVERRIDE; |
255 | 255 |
256 private: | 256 private: |
257 const GDataWapiUrlGenerator url_generator_; | 257 const GDataWapiUrlGenerator url_generator_; |
258 const std::string resource_id_; | 258 const std::string resource_id_; |
259 const std::string new_name_; | 259 const std::string new_name_; |
260 | 260 |
261 DISALLOW_COPY_AND_ASSIGN(CopyHostedDocumentOperation); | 261 DISALLOW_COPY_AND_ASSIGN(CopyHostedDocumentOperation); |
262 }; | 262 }; |
263 | 263 |
264 //=========================== RenameResourceOperation ========================== | 264 //=========================== RenameResourceOperation ========================== |
265 | 265 |
266 // This class performs the operation for renaming a document/file/directory. | 266 // This class performs the operation for renaming a document/file/directory. |
267 class RenameResourceOperation : public EntryActionOperation { | 267 class RenameResourceOperation : public EntryActionRequest { |
268 public: | 268 public: |
269 // |callback| must not be null. | 269 // |callback| must not be null. |
270 RenameResourceOperation( | 270 RenameResourceOperation( |
271 OperationRunner* runner, | 271 OperationRunner* runner, |
272 net::URLRequestContextGetter* url_request_context_getter, | 272 net::URLRequestContextGetter* url_request_context_getter, |
273 const GDataWapiUrlGenerator& url_generator, | 273 const GDataWapiUrlGenerator& url_generator, |
274 const EntryActionCallback& callback, | 274 const EntryActionCallback& callback, |
275 const std::string& resource_id, | 275 const std::string& resource_id, |
276 const std::string& new_name); | 276 const std::string& new_name); |
277 virtual ~RenameResourceOperation(); | 277 virtual ~RenameResourceOperation(); |
278 | 278 |
279 protected: | 279 protected: |
280 // UrlFetchOperationBase overrides. | 280 // UrlFetchRequestBase overrides. |
281 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 281 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
282 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 282 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
283 virtual GURL GetURL() const OVERRIDE; | 283 virtual GURL GetURL() const OVERRIDE; |
284 virtual bool GetContentData(std::string* upload_content_type, | 284 virtual bool GetContentData(std::string* upload_content_type, |
285 std::string* upload_content) OVERRIDE; | 285 std::string* upload_content) OVERRIDE; |
286 | 286 |
287 private: | 287 private: |
288 const GDataWapiUrlGenerator url_generator_; | 288 const GDataWapiUrlGenerator url_generator_; |
289 const std::string resource_id_; | 289 const std::string resource_id_; |
290 const std::string new_name_; | 290 const std::string new_name_; |
291 | 291 |
292 DISALLOW_COPY_AND_ASSIGN(RenameResourceOperation); | 292 DISALLOW_COPY_AND_ASSIGN(RenameResourceOperation); |
293 }; | 293 }; |
294 | 294 |
295 //=========================== AuthorizeAppOperation ========================== | 295 //=========================== AuthorizeAppOperation ========================== |
296 | 296 |
297 // This class performs the operation for authorizing an application specified | 297 // This class performs the operation for authorizing an application specified |
298 // by |app_id| to access a document specified by |resource_id|. | 298 // by |app_id| to access a document specified by |resource_id|. |
299 class AuthorizeAppOperation : public GetDataOperation { | 299 class AuthorizeAppOperation : public GetDataRequest { |
300 public: | 300 public: |
301 // |callback| must not be null. | 301 // |callback| must not be null. |
302 AuthorizeAppOperation( | 302 AuthorizeAppOperation( |
303 OperationRunner* runner, | 303 OperationRunner* runner, |
304 net::URLRequestContextGetter* url_request_context_getter, | 304 net::URLRequestContextGetter* url_request_context_getter, |
305 const GDataWapiUrlGenerator& url_generator, | 305 const GDataWapiUrlGenerator& url_generator, |
306 const AuthorizeAppCallback& callback, | 306 const AuthorizeAppCallback& callback, |
307 const std::string& resource_id, | 307 const std::string& resource_id, |
308 const std::string& app_id); | 308 const std::string& app_id); |
309 virtual ~AuthorizeAppOperation(); | 309 virtual ~AuthorizeAppOperation(); |
310 | 310 |
311 protected: | 311 protected: |
312 // UrlFetchOperationBase overrides. | 312 // UrlFetchRequestBase overrides. |
313 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 313 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
314 virtual bool GetContentData(std::string* upload_content_type, | 314 virtual bool GetContentData(std::string* upload_content_type, |
315 std::string* upload_content) OVERRIDE; | 315 std::string* upload_content) OVERRIDE; |
316 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 316 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
317 virtual GURL GetURL() const OVERRIDE; | 317 virtual GURL GetURL() const OVERRIDE; |
318 | 318 |
319 private: | 319 private: |
320 const GDataWapiUrlGenerator url_generator_; | 320 const GDataWapiUrlGenerator url_generator_; |
321 const std::string resource_id_; | 321 const std::string resource_id_; |
322 const std::string app_id_; | 322 const std::string app_id_; |
323 | 323 |
324 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppOperation); | 324 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppOperation); |
325 }; | 325 }; |
326 | 326 |
327 //======================= AddResourceToDirectoryOperation ====================== | 327 //======================= AddResourceToDirectoryOperation ====================== |
328 | 328 |
329 // This class performs the operation for adding a document/file/directory | 329 // This class performs the operation for adding a document/file/directory |
330 // to a directory. | 330 // to a directory. |
331 class AddResourceToDirectoryOperation : public EntryActionOperation { | 331 class AddResourceToDirectoryOperation : public EntryActionRequest { |
332 public: | 332 public: |
333 // |callback| must not be null. | 333 // |callback| must not be null. |
334 AddResourceToDirectoryOperation( | 334 AddResourceToDirectoryOperation( |
335 OperationRunner* runner, | 335 OperationRunner* runner, |
336 net::URLRequestContextGetter* url_request_context_getter, | 336 net::URLRequestContextGetter* url_request_context_getter, |
337 const GDataWapiUrlGenerator& url_generator, | 337 const GDataWapiUrlGenerator& url_generator, |
338 const EntryActionCallback& callback, | 338 const EntryActionCallback& callback, |
339 const std::string& parent_resource_id, | 339 const std::string& parent_resource_id, |
340 const std::string& resource_id); | 340 const std::string& resource_id); |
341 virtual ~AddResourceToDirectoryOperation(); | 341 virtual ~AddResourceToDirectoryOperation(); |
342 | 342 |
343 protected: | 343 protected: |
344 // UrlFetchOperationBase overrides. | 344 // UrlFetchRequestBase overrides. |
345 virtual GURL GetURL() const OVERRIDE; | 345 virtual GURL GetURL() const OVERRIDE; |
346 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 346 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
347 virtual bool GetContentData(std::string* upload_content_type, | 347 virtual bool GetContentData(std::string* upload_content_type, |
348 std::string* upload_content) OVERRIDE; | 348 std::string* upload_content) OVERRIDE; |
349 | 349 |
350 private: | 350 private: |
351 const GDataWapiUrlGenerator url_generator_; | 351 const GDataWapiUrlGenerator url_generator_; |
352 const std::string parent_resource_id_; | 352 const std::string parent_resource_id_; |
353 const std::string resource_id_; | 353 const std::string resource_id_; |
354 | 354 |
355 DISALLOW_COPY_AND_ASSIGN(AddResourceToDirectoryOperation); | 355 DISALLOW_COPY_AND_ASSIGN(AddResourceToDirectoryOperation); |
356 }; | 356 }; |
357 | 357 |
358 //==================== RemoveResourceFromDirectoryOperation ==================== | 358 //==================== RemoveResourceFromDirectoryOperation ==================== |
359 | 359 |
360 // This class performs the operation for removing a document/file/directory | 360 // This class performs the operation for removing a document/file/directory |
361 // from a directory. | 361 // from a directory. |
362 class RemoveResourceFromDirectoryOperation : public EntryActionOperation { | 362 class RemoveResourceFromDirectoryOperation : public EntryActionRequest { |
363 public: | 363 public: |
364 // |callback| must not be null. | 364 // |callback| must not be null. |
365 RemoveResourceFromDirectoryOperation( | 365 RemoveResourceFromDirectoryOperation( |
366 OperationRunner* runner, | 366 OperationRunner* runner, |
367 net::URLRequestContextGetter* url_request_context_getter, | 367 net::URLRequestContextGetter* url_request_context_getter, |
368 const GDataWapiUrlGenerator& url_generator, | 368 const GDataWapiUrlGenerator& url_generator, |
369 const EntryActionCallback& callback, | 369 const EntryActionCallback& callback, |
370 const std::string& parent_resource_id, | 370 const std::string& parent_resource_id, |
371 const std::string& resource_id); | 371 const std::string& resource_id); |
372 virtual ~RemoveResourceFromDirectoryOperation(); | 372 virtual ~RemoveResourceFromDirectoryOperation(); |
373 | 373 |
374 protected: | 374 protected: |
375 // UrlFetchOperationBase overrides. | 375 // UrlFetchRequestBase overrides. |
376 virtual GURL GetURL() const OVERRIDE; | 376 virtual GURL GetURL() const OVERRIDE; |
377 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 377 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
378 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 378 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
379 | 379 |
380 private: | 380 private: |
381 const GDataWapiUrlGenerator url_generator_; | 381 const GDataWapiUrlGenerator url_generator_; |
382 const std::string resource_id_; | 382 const std::string resource_id_; |
383 const std::string parent_resource_id_; | 383 const std::string parent_resource_id_; |
384 | 384 |
385 DISALLOW_COPY_AND_ASSIGN(RemoveResourceFromDirectoryOperation); | 385 DISALLOW_COPY_AND_ASSIGN(RemoveResourceFromDirectoryOperation); |
386 }; | 386 }; |
387 | 387 |
388 //======================= InitiateUploadNewFileOperation ======================= | 388 //======================= InitiateUploadNewFileOperation ======================= |
389 | 389 |
390 // This class performs the operation for initiating the upload of a new file. | 390 // This class performs the operation for initiating the upload of a new file. |
391 class InitiateUploadNewFileOperation : public InitiateUploadOperationBase { | 391 class InitiateUploadNewFileOperation : public InitiateUploadRequestBase { |
392 public: | 392 public: |
393 // |title| should be set. | 393 // |title| should be set. |
394 // |parent_upload_url| should be the upload_url() of the parent directory. | 394 // |parent_upload_url| should be the upload_url() of the parent directory. |
395 // (resumable-create-media URL) | 395 // (resumable-create-media URL) |
396 // See also the comments of InitiateUploadOperationBase for more details | 396 // See also the comments of InitiateUploadRequestBase for more details |
397 // about the other parameters. | 397 // about the other parameters. |
398 InitiateUploadNewFileOperation( | 398 InitiateUploadNewFileOperation( |
399 OperationRunner* runner, | 399 OperationRunner* runner, |
400 net::URLRequestContextGetter* url_request_context_getter, | 400 net::URLRequestContextGetter* url_request_context_getter, |
401 const GDataWapiUrlGenerator& url_generator, | 401 const GDataWapiUrlGenerator& url_generator, |
402 const InitiateUploadCallback& callback, | 402 const InitiateUploadCallback& callback, |
403 const base::FilePath& drive_file_path, | 403 const base::FilePath& drive_file_path, |
404 const std::string& content_type, | 404 const std::string& content_type, |
405 int64 content_length, | 405 int64 content_length, |
406 const std::string& parent_resource_id, | 406 const std::string& parent_resource_id, |
407 const std::string& title); | 407 const std::string& title); |
408 virtual ~InitiateUploadNewFileOperation(); | 408 virtual ~InitiateUploadNewFileOperation(); |
409 | 409 |
410 protected: | 410 protected: |
411 // UrlFetchOperationBase overrides. | 411 // UrlFetchRequestBase overrides. |
412 virtual GURL GetURL() const OVERRIDE; | 412 virtual GURL GetURL() const OVERRIDE; |
413 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 413 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
414 virtual bool GetContentData(std::string* upload_content_type, | 414 virtual bool GetContentData(std::string* upload_content_type, |
415 std::string* upload_content) OVERRIDE; | 415 std::string* upload_content) OVERRIDE; |
416 | 416 |
417 private: | 417 private: |
418 const GDataWapiUrlGenerator url_generator_; | 418 const GDataWapiUrlGenerator url_generator_; |
419 const std::string parent_resource_id_; | 419 const std::string parent_resource_id_; |
420 const std::string title_; | 420 const std::string title_; |
421 | 421 |
422 DISALLOW_COPY_AND_ASSIGN(InitiateUploadNewFileOperation); | 422 DISALLOW_COPY_AND_ASSIGN(InitiateUploadNewFileOperation); |
423 }; | 423 }; |
424 | 424 |
425 //==================== InitiateUploadExistingFileOperation ===================== | 425 //==================== InitiateUploadExistingFileOperation ===================== |
426 | 426 |
427 // This class performs the operation for initiating the upload of an existing | 427 // This class performs the operation for initiating the upload of an existing |
428 // file. | 428 // file. |
429 class InitiateUploadExistingFileOperation | 429 class InitiateUploadExistingFileOperation |
430 : public InitiateUploadOperationBase { | 430 : public InitiateUploadRequestBase { |
431 public: | 431 public: |
432 // |upload_url| should be the upload_url() of the file | 432 // |upload_url| should be the upload_url() of the file |
433 // (resumable-create-media URL) | 433 // (resumable-create-media URL) |
434 // |etag| should be set if it is available to detect the upload confliction. | 434 // |etag| should be set if it is available to detect the upload confliction. |
435 // See also the comments of InitiateUploadOperationBase for more details | 435 // See also the comments of InitiateUploadRequestBase for more details |
436 // about the other parameters. | 436 // about the other parameters. |
437 InitiateUploadExistingFileOperation( | 437 InitiateUploadExistingFileOperation( |
438 OperationRunner* runner, | 438 OperationRunner* runner, |
439 net::URLRequestContextGetter* url_request_context_getter, | 439 net::URLRequestContextGetter* url_request_context_getter, |
440 const GDataWapiUrlGenerator& url_generator, | 440 const GDataWapiUrlGenerator& url_generator, |
441 const InitiateUploadCallback& callback, | 441 const InitiateUploadCallback& callback, |
442 const base::FilePath& drive_file_path, | 442 const base::FilePath& drive_file_path, |
443 const std::string& content_type, | 443 const std::string& content_type, |
444 int64 content_length, | 444 int64 content_length, |
445 const std::string& resource_id, | 445 const std::string& resource_id, |
446 const std::string& etag); | 446 const std::string& etag); |
447 virtual ~InitiateUploadExistingFileOperation(); | 447 virtual ~InitiateUploadExistingFileOperation(); |
448 | 448 |
449 protected: | 449 protected: |
450 // UrlFetchOperationBase overrides. | 450 // UrlFetchRequestBase overrides. |
451 virtual GURL GetURL() const OVERRIDE; | 451 virtual GURL GetURL() const OVERRIDE; |
452 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 452 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
453 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 453 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
454 virtual bool GetContentData(std::string* upload_content_type, | 454 virtual bool GetContentData(std::string* upload_content_type, |
455 std::string* upload_content) OVERRIDE; | 455 std::string* upload_content) OVERRIDE; |
456 | 456 |
457 private: | 457 private: |
458 const GDataWapiUrlGenerator url_generator_; | 458 const GDataWapiUrlGenerator url_generator_; |
459 const std::string resource_id_; | 459 const std::string resource_id_; |
460 const std::string etag_; | 460 const std::string etag_; |
461 | 461 |
462 DISALLOW_COPY_AND_ASSIGN(InitiateUploadExistingFileOperation); | 462 DISALLOW_COPY_AND_ASSIGN(InitiateUploadExistingFileOperation); |
463 }; | 463 }; |
464 | 464 |
465 //============================ ResumeUploadOperation =========================== | 465 //============================ ResumeUploadOperation =========================== |
466 | 466 |
467 // Performs the operation for resuming the upload of a file. | 467 // Performs the operation for resuming the upload of a file. |
468 class ResumeUploadOperation : public ResumeUploadOperationBase { | 468 class ResumeUploadOperation : public ResumeUploadRequestBase { |
469 public: | 469 public: |
470 // See also ResumeUploadOperationBase's comment for parameters meaining. | 470 // See also ResumeUploadRequestBase's comment for parameters meaining. |
471 // |callback| must not be null. | 471 // |callback| must not be null. |
472 ResumeUploadOperation( | 472 ResumeUploadOperation( |
473 OperationRunner* runner, | 473 OperationRunner* runner, |
474 net::URLRequestContextGetter* url_request_context_getter, | 474 net::URLRequestContextGetter* url_request_context_getter, |
475 const UploadRangeCallback& callback, | 475 const UploadRangeCallback& callback, |
476 const ProgressCallback& progress_callback, | 476 const ProgressCallback& progress_callback, |
477 const base::FilePath& drive_file_path, | 477 const base::FilePath& drive_file_path, |
478 const GURL& upload_location, | 478 const GURL& upload_location, |
479 int64 start_position, | 479 int64 start_position, |
480 int64 end_position, | 480 int64 end_position, |
481 int64 content_length, | 481 int64 content_length, |
482 const std::string& content_type, | 482 const std::string& content_type, |
483 const base::FilePath& local_file_path); | 483 const base::FilePath& local_file_path); |
484 virtual ~ResumeUploadOperation(); | 484 virtual ~ResumeUploadOperation(); |
485 | 485 |
486 protected: | 486 protected: |
487 // UploadRangeOperationBase overrides. | 487 // UploadRangeRequestBase overrides. |
488 virtual void OnRangeOperationComplete( | 488 virtual void OnRangeRequestComplete( |
489 const UploadRangeResponse& response, | 489 const UploadRangeResponse& response, |
490 scoped_ptr<base::Value> value) OVERRIDE; | 490 scoped_ptr<base::Value> value) OVERRIDE; |
491 // content::UrlFetcherDelegate overrides. | 491 // content::UrlFetcherDelegate overrides. |
492 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, | 492 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, |
493 int64 current, int64 total) OVERRIDE; | 493 int64 current, int64 total) OVERRIDE; |
494 | 494 |
495 private: | 495 private: |
496 const UploadRangeCallback callback_; | 496 const UploadRangeCallback callback_; |
497 const ProgressCallback progress_callback_; | 497 const ProgressCallback progress_callback_; |
498 | 498 |
499 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); | 499 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); |
500 }; | 500 }; |
501 | 501 |
502 //========================== GetUploadStatusOperation ========================== | 502 //========================== GetUploadStatusOperation ========================== |
503 | 503 |
504 // Performs the operation to request the current upload status of a file. | 504 // Performs the operation to request the current upload status of a file. |
505 class GetUploadStatusOperation : public GetUploadStatusOperationBase { | 505 class GetUploadStatusOperation : public GetUploadStatusRequestBase { |
506 public: | 506 public: |
507 // See also GetUploadStatusOperationBase's comment for parameters meaning. | 507 // See also GetUploadStatusRequestBase's comment for parameters meaning. |
508 // |callback| must not be null. | 508 // |callback| must not be null. |
509 GetUploadStatusOperation( | 509 GetUploadStatusOperation( |
510 OperationRunner* runner, | 510 OperationRunner* runner, |
511 net::URLRequestContextGetter* url_request_context_getter, | 511 net::URLRequestContextGetter* url_request_context_getter, |
512 const UploadRangeCallback& callback, | 512 const UploadRangeCallback& callback, |
513 const base::FilePath& drive_file_path, | 513 const base::FilePath& drive_file_path, |
514 const GURL& upload_url, | 514 const GURL& upload_url, |
515 int64 content_length); | 515 int64 content_length); |
516 virtual ~GetUploadStatusOperation(); | 516 virtual ~GetUploadStatusOperation(); |
517 | 517 |
518 protected: | 518 protected: |
519 // UploadRangeOperationBase overrides. | 519 // UploadRangeRequestBase overrides. |
520 virtual void OnRangeOperationComplete( | 520 virtual void OnRangeRequestComplete( |
521 const UploadRangeResponse& response, | 521 const UploadRangeResponse& response, |
522 scoped_ptr<base::Value> value) OVERRIDE; | 522 scoped_ptr<base::Value> value) OVERRIDE; |
523 | 523 |
524 private: | 524 private: |
525 const UploadRangeCallback callback_; | 525 const UploadRangeCallback callback_; |
526 | 526 |
527 DISALLOW_COPY_AND_ASSIGN(GetUploadStatusOperation); | 527 DISALLOW_COPY_AND_ASSIGN(GetUploadStatusOperation); |
528 }; | 528 }; |
529 | 529 |
530 } // namespace google_apis | 530 } // namespace google_apis |
531 | 531 |
532 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 532 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
OLD | NEW |