| 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" | |
| 16 #include "chrome/browser/google_apis/gdata_errorcode.h" | 15 #include "chrome/browser/google_apis/gdata_errorcode.h" |
| 17 #include "chrome/browser/google_apis/operation_registry.h" | 16 #include "chrome/browser/google_apis/operation_registry.h" |
| 18 #include "google_apis/gaia/oauth2_access_token_consumer.h" | 17 #include "google_apis/gaia/oauth2_access_token_consumer.h" |
| 19 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 20 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
| 21 #include "net/url_request/url_fetcher_delegate.h" | 20 #include "net/url_request/url_fetcher_delegate.h" |
| 22 | 21 |
| 23 class OAuth2AccessTokenFetcher; | 22 class OAuth2AccessTokenFetcher; |
| 24 | 23 |
| 25 namespace base { | 24 namespace base { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 254 |
| 256 // Note: This should remain the last member so it'll be destroyed and | 255 // Note: This should remain the last member so it'll be destroyed and |
| 257 // invalidate its weak pointers before any other members are destroyed. | 256 // invalidate its weak pointers before any other members are destroyed. |
| 258 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_; | 257 base::WeakPtrFactory<GetDataOperation> weak_ptr_factory_; |
| 259 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); | 258 DISALLOW_COPY_AND_ASSIGN(GetDataOperation); |
| 260 }; | 259 }; |
| 261 | 260 |
| 262 | 261 |
| 263 //=========================== InitiateUploadOperation ========================== | 262 //=========================== InitiateUploadOperation ========================== |
| 264 | 263 |
| 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 base::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 base::FilePath drive_file_path; | |
| 299 const std::string etag; | |
| 300 }; | |
| 301 | |
| 302 // Callback type for DocumentServiceInterface::InitiateUpload. | 264 // Callback type for DocumentServiceInterface::InitiateUpload. |
| 303 typedef base::Callback<void(GDataErrorCode error, | 265 typedef base::Callback<void(GDataErrorCode error, |
| 304 const GURL& upload_url)> InitiateUploadCallback; | 266 const GURL& upload_url)> InitiateUploadCallback; |
| 305 | 267 |
| 306 // This class provides base implementation for performing the operation for | 268 // This class provides base implementation for performing the operation for |
| 307 // initiating the upload of a file. | 269 // initiating the upload of a file. |
| 308 // |callback| will be called with the obtained upload URL. The URL will be | 270 // |callback| will be called with the obtained upload URL. The URL will be |
| 309 // used with operations for resuming the file uploading. | 271 // used with operations for resuming the file uploading. |
| 310 // | 272 // |
| 311 // Here's the flow of uploading: | 273 // Here's the flow of uploading: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 const DownloadActionCallback download_action_callback_; | 363 const DownloadActionCallback download_action_callback_; |
| 402 const GetContentCallback get_content_callback_; | 364 const GetContentCallback get_content_callback_; |
| 403 const GURL download_url_; | 365 const GURL download_url_; |
| 404 | 366 |
| 405 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); | 367 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); |
| 406 }; | 368 }; |
| 407 | 369 |
| 408 } // namespace google_apis | 370 } // namespace google_apis |
| 409 | 371 |
| 410 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ | 372 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ |
| OLD | NEW |