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

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

Issue 12039005: drive: Deal with the root directory in the same way as others in MoveOperation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
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_operations.h" 5 #include "chrome/browser/google_apis/gdata_wapi_operations.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 10 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 : EntryActionOperation(registry, url_request_context_getter, callback), 482 : EntryActionOperation(registry, url_request_context_getter, callback),
483 url_generator_(url_generator), 483 url_generator_(url_generator),
484 parent_content_url_(parent_content_url), 484 parent_content_url_(parent_content_url),
485 edit_url_(edit_url) { 485 edit_url_(edit_url) {
486 DCHECK(!callback.is_null()); 486 DCHECK(!callback.is_null());
487 } 487 }
488 488
489 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} 489 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {}
490 490
491 GURL AddResourceToDirectoryOperation::GetURL() const { 491 GURL AddResourceToDirectoryOperation::GetURL() const {
492 if (!parent_content_url_.is_empty()) 492 GURL parent = parent_content_url_.is_empty() ?
493 return GDataWapiUrlGenerator::AddStandardUrlParams(parent_content_url_); 493 url_generator_.GenerateRootContentUrl() : parent_content_url_;
494 494 return GDataWapiUrlGenerator::AddStandardUrlParams(parent);
495 return url_generator_.GenerateResourceListRootUrl();
satorux1 2013/01/22 06:51:50 Is GenerateResourceListRootUrl() still used somewh
kinaba 2013/01/22 07:09:10 CreateDirectory and CopyHostedDocument still uses
496 } 495 }
497 496
498 URLFetcher::RequestType 497 URLFetcher::RequestType
499 AddResourceToDirectoryOperation::GetRequestType() const { 498 AddResourceToDirectoryOperation::GetRequestType() const {
500 return URLFetcher::POST; 499 return URLFetcher::POST;
501 } 500 }
502 501
503 bool AddResourceToDirectoryOperation::GetContentData( 502 bool AddResourceToDirectoryOperation::GetContentData(
504 std::string* upload_content_type, std::string* upload_content) { 503 std::string* upload_content_type, std::string* upload_content) {
505 upload_content_type->assign("application/atom+xml"); 504 upload_content_type->assign("application/atom+xml");
(...skipping 10 matching lines...) Expand all
516 DVLOG(1) << "AddResourceToDirectoryOperation data: " << *upload_content_type 515 DVLOG(1) << "AddResourceToDirectoryOperation data: " << *upload_content_type
517 << ", [" << *upload_content << "]"; 516 << ", [" << *upload_content << "]";
518 return true; 517 return true;
519 } 518 }
520 519
521 //==================== RemoveResourceFromDirectoryOperation ==================== 520 //==================== RemoveResourceFromDirectoryOperation ====================
522 521
523 RemoveResourceFromDirectoryOperation::RemoveResourceFromDirectoryOperation( 522 RemoveResourceFromDirectoryOperation::RemoveResourceFromDirectoryOperation(
524 OperationRegistry* registry, 523 OperationRegistry* registry,
525 net::URLRequestContextGetter* url_request_context_getter, 524 net::URLRequestContextGetter* url_request_context_getter,
525 const GDataWapiUrlGenerator& url_generator,
526 const EntryActionCallback& callback, 526 const EntryActionCallback& callback,
527 const GURL& parent_content_url, 527 const GURL& parent_content_url,
528 const std::string& document_resource_id) 528 const std::string& document_resource_id)
529 : EntryActionOperation(registry, url_request_context_getter, callback), 529 : EntryActionOperation(registry, url_request_context_getter, callback),
530 url_generator_(url_generator),
530 resource_id_(document_resource_id), 531 resource_id_(document_resource_id),
531 parent_content_url_(parent_content_url) { 532 parent_content_url_(parent_content_url) {
532 DCHECK(!callback.is_null()); 533 DCHECK(!callback.is_null());
533 } 534 }
534 535
535 RemoveResourceFromDirectoryOperation::~RemoveResourceFromDirectoryOperation() { 536 RemoveResourceFromDirectoryOperation::~RemoveResourceFromDirectoryOperation() {
536 } 537 }
537 538
538 GURL RemoveResourceFromDirectoryOperation::GetURL() const { 539 GURL RemoveResourceFromDirectoryOperation::GetURL() const {
540 GURL parent = parent_content_url_.is_empty() ?
541 url_generator_.GenerateRootContentUrl() : parent_content_url_;
542
539 std::string escaped_resource_id = net::EscapePath(resource_id_); 543 std::string escaped_resource_id = net::EscapePath(resource_id_);
540 GURL edit_url(base::StringPrintf("%s/%s", 544 GURL edit_url(base::StringPrintf("%s/%s",
541 parent_content_url_.spec().c_str(), 545 parent.spec().c_str(),
542 escaped_resource_id.c_str())); 546 escaped_resource_id.c_str()));
543 return GDataWapiUrlGenerator::AddStandardUrlParams(edit_url); 547 return GDataWapiUrlGenerator::AddStandardUrlParams(edit_url);
544 } 548 }
545 549
546 URLFetcher::RequestType 550 URLFetcher::RequestType
547 RemoveResourceFromDirectoryOperation::GetRequestType() const { 551 RemoveResourceFromDirectoryOperation::GetRequestType() const {
548 return URLFetcher::DELETE_REQUEST; 552 return URLFetcher::DELETE_REQUEST;
549 } 553 }
550 554
551 std::vector<std::string> 555 std::vector<std::string>
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 return true; 825 return true;
822 } 826 }
823 827
824 void ResumeUploadOperation::OnURLFetchUploadProgress( 828 void ResumeUploadOperation::OnURLFetchUploadProgress(
825 const URLFetcher* source, int64 current, int64 total) { 829 const URLFetcher* source, int64 current, int64 total) {
826 // Adjust the progress values according to the range currently uploaded. 830 // Adjust the progress values according to the range currently uploaded.
827 NotifyProgress(params_.start_position + current, params_.content_length); 831 NotifyProgress(params_.start_position + current, params_.content_length);
828 } 832 }
829 833
830 } // namespace google_apis 834 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698