Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/google_apis/gdata_wapi_service.cc

Issue 12207075: Split InitiateUpload method into two. (Closed) Base URL: http://git.chromium.org/chromium/src.git@b148632_extract_initiate_upload_operation_base
Patch Set: Rebase Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_wapi_service.h" 5 #include "chrome/browser/google_apis/gdata_wapi_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 runner_->StartOperationWithRetry( 402 runner_->StartOperationWithRetry(
403 new RemoveResourceFromDirectoryOperation(operation_registry(), 403 new RemoveResourceFromDirectoryOperation(operation_registry(),
404 url_request_context_getter_, 404 url_request_context_getter_,
405 url_generator_, 405 url_generator_,
406 callback, 406 callback,
407 parent_resource_id, 407 parent_resource_id,
408 resource_id)); 408 resource_id));
409 } 409 }
410 410
411 void GDataWapiService::InitiateUpload( 411 void GDataWapiService::InitiateUploadNewFile(
412 const InitiateUploadParams& params, 412 const FilePath& drive_file_path,
413 const std::string& content_type,
414 int64 content_length,
415 const GURL& parent_upload_url,
416 const std::string& title,
413 const InitiateUploadCallback& callback) { 417 const InitiateUploadCallback& callback) {
414 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
415 DCHECK(!callback.is_null()); 419 DCHECK(!callback.is_null());
416 420
417 if (params.upload_location.is_empty()) { 421 if (parent_upload_url.is_empty()) {
418 callback.Run(HTTP_BAD_REQUEST, GURL()); 422 callback.Run(HTTP_BAD_REQUEST, GURL());
419 return; 423 return;
420 } 424 }
421 425
422 // TODO(hidehiko): Remove this if-statement by splitting the InitiateUpload 426 runner_->StartOperationWithRetry(
423 // method into two InitiateUploadNewFile and InitiateUploadExistingFile. 427 new InitiateUploadNewFileOperation(operation_registry(),
424 if (params.upload_mode == UPLOAD_NEW_FILE) { 428 url_request_context_getter_,
425 runner_->StartOperationWithRetry( 429 callback,
426 new InitiateUploadNewFileOperation( 430 drive_file_path,
427 operation_registry(), 431 content_type,
428 url_request_context_getter_, 432 content_length,
429 callback, 433 parent_upload_url,
430 params.drive_file_path, 434 title));
431 params.content_type, 435 }
432 params.content_length, 436
433 params.upload_location, // Here, upload_location has parent's URL. 437 void GDataWapiService::InitiateUploadExistingFile(
434 params.title)); 438 const FilePath& drive_file_path,
435 } else { 439 const std::string& content_type,
436 DCHECK_EQ(params.upload_mode, UPLOAD_EXISTING_FILE); 440 int64 content_length,
437 runner_->StartOperationWithRetry( 441 const GURL& upload_url,
438 new InitiateUploadExistingFileOperation( 442 const std::string& etag,
439 operation_registry(), 443 const InitiateUploadCallback& callback) {
440 url_request_context_getter_, 444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
441 callback, 445 DCHECK(!callback.is_null());
442 params.drive_file_path, 446
443 params.content_type, 447 if (upload_url.is_empty()) {
444 params.content_length, 448 callback.Run(HTTP_BAD_REQUEST, GURL());
445 params.upload_location, // Here, upload_location has file's URL. 449 return;
446 params.etag));
447 } 450 }
451
452 runner_->StartOperationWithRetry(
453 new InitiateUploadExistingFileOperation(operation_registry(),
454 url_request_context_getter_,
455 callback,
456 drive_file_path,
457 content_type,
458 content_length,
459 upload_url,
460 etag));
448 } 461 }
449 462
450 void GDataWapiService::ResumeUpload(const ResumeUploadParams& params, 463 void GDataWapiService::ResumeUpload(const ResumeUploadParams& params,
451 const UploadRangeCallback& callback) { 464 const UploadRangeCallback& callback) {
452 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
453 DCHECK(!callback.is_null()); 466 DCHECK(!callback.is_null());
454 467
455 runner_->StartOperationWithRetry( 468 runner_->StartOperationWithRetry(
456 new ResumeUploadOperation(operation_registry(), 469 new ResumeUploadOperation(operation_registry(),
457 url_request_context_getter_, 470 url_request_context_getter_,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 539 }
527 540
528 void GDataWapiService::OnProgressUpdate( 541 void GDataWapiService::OnProgressUpdate(
529 const OperationProgressStatusList& list) { 542 const OperationProgressStatusList& list) {
530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
531 FOR_EACH_OBSERVER( 544 FOR_EACH_OBSERVER(
532 DriveServiceObserver, observers_, OnProgressUpdate(list)); 545 DriveServiceObserver, observers_, OnProgressUpdate(list));
533 } 546 }
534 547
535 } // namespace google_apis 548 } // namespace google_apis
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_service.h ('k') | chrome/browser/google_apis/mock_drive_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698