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 // This file provides base classes used to implement operations for Google APIs. | 5 // This file provides base classes used to implement operations for Google APIs. |
6 | 6 |
7 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ | 7 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ |
8 #define CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ | 8 #define CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "chrome/browser/google_apis/drive_upload_mode.h" | 15 #include "chrome/browser/google_apis/drive_upload_mode.h" |
hashimoto
2013/02/08 11:34:02
nit: no need to include this anymore.
hidehiko
2013/02/08 12:01:50
Done.
| |
16 #include "chrome/browser/google_apis/gdata_errorcode.h" | 16 #include "chrome/browser/google_apis/gdata_errorcode.h" |
17 #include "chrome/browser/google_apis/operation_registry.h" | 17 #include "chrome/browser/google_apis/operation_registry.h" |
18 #include "google_apis/gaia/oauth2_access_token_consumer.h" | 18 #include "google_apis/gaia/oauth2_access_token_consumer.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" |
21 #include "net/url_request/url_fetcher_delegate.h" | 21 #include "net/url_request/url_fetcher_delegate.h" |
22 | 22 |
23 class OAuth2AccessTokenFetcher; | 23 class OAuth2AccessTokenFetcher; |
24 | 24 |
25 namespace base { | 25 namespace base { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 | 255 |
256 // Note: This should remain the last member so it'll be destroyed and | 256 // Note: This should remain the last member so it'll be destroyed and |
257 // invalidate its weak pointers before any other members are destroyed. | 257 // invalidate its weak pointers before any other members are destroyed. |
258 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_; | 258 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_; |
259 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); | 259 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); |
260 }; | 260 }; |
261 | 261 |
262 | 262 |
263 //=========================== InitiateUploadOperation ========================== | 263 //=========================== InitiateUploadOperation ========================== |
264 | 264 |
265 // Struct for passing params needed for DriveServiceInterface::InitiateUpload() | |
266 // calls. | |
267 // | |
268 // When uploading a new file (UPLOAD_NEW_FILE): | |
269 // - |title| should be set. | |
270 // - |upload_location| should be the upload_url() of the parent directory. | |
271 // (resumable-create-media URL) | |
272 // - |etag| is ignored. | |
273 // | |
274 // When updating an existing file (UPLOAD_EXISTING_FILE): | |
275 // - |title| should be empty | |
276 // - |upload_location| should be the upload_url() of the existing file. | |
277 // (resumable-edit-media URL) | |
278 // - If |etag| should be empty or should match the etag() of the destination | |
279 // file. | |
280 // TODO(hidehiko): Get rid of this struct by splitting the method | |
281 // InitiateUpload into two methods, InitiateUploadNewFile and | |
282 // InitiateUploadExistingFile. | |
283 struct InitiateUploadParams { | |
284 InitiateUploadParams(UploadMode upload_mode, | |
285 const std::string& title, | |
286 const std::string& content_type, | |
287 int64 content_length, | |
288 const GURL& upload_location, | |
289 const FilePath& drive_file_path, | |
290 const std::string& etag); | |
291 ~InitiateUploadParams(); | |
292 | |
293 const UploadMode upload_mode; | |
294 const std::string title; | |
295 const std::string content_type; | |
296 const int64 content_length; | |
297 const GURL upload_location; | |
298 const FilePath drive_file_path; | |
299 const std::string etag; | |
300 }; | |
301 | |
302 // Callback type for DocumentServiceInterface::InitiateUpload. | 265 // Callback type for DocumentServiceInterface::InitiateUpload. |
303 typedef base::Callback<void(GDataErrorCode error, | 266 typedef base::Callback<void(GDataErrorCode error, |
304 const GURL& upload_url)> InitiateUploadCallback; | 267 const GURL& upload_url)> InitiateUploadCallback; |
305 | 268 |
306 // This class provides base implementation for performing the operation for | 269 // This class provides base implementation for performing the operation for |
307 // initiating the upload of a file. | 270 // initiating the upload of a file. |
308 // |callback| will be called with the obtained upload URL. The URL will be | 271 // |callback| will be called with the obtained upload URL. The URL will be |
309 // used with operations for resuming the file uploading. | 272 // used with operations for resuming the file uploading. |
310 // | 273 // |
311 // Here's the flow of uploading: | 274 // Here's the flow of uploading: |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 const DownloadActionCallback download_action_callback_; | 363 const DownloadActionCallback download_action_callback_; |
401 const GetContentCallback get_content_callback_; | 364 const GetContentCallback get_content_callback_; |
402 const GURL download_url_; | 365 const GURL download_url_; |
403 | 366 |
404 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); | 367 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); |
405 }; | 368 }; |
406 | 369 |
407 } // namespace google_apis | 370 } // namespace google_apis |
408 | 371 |
409 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ | 372 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ |
OLD | NEW |