| 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 #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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 ResumeUploadResponse::~ResumeUploadResponse() { | 60 ResumeUploadResponse::~ResumeUploadResponse() { |
| 61 } | 61 } |
| 62 | 62 |
| 63 InitiateUploadParams::InitiateUploadParams( | 63 InitiateUploadParams::InitiateUploadParams( |
| 64 UploadMode upload_mode, | 64 UploadMode upload_mode, |
| 65 const std::string& title, | 65 const std::string& title, |
| 66 const std::string& content_type, | 66 const std::string& content_type, |
| 67 int64 content_length, | 67 int64 content_length, |
| 68 const GURL& upload_location, | 68 const GURL& upload_location, |
| 69 const FilePath& virtual_path) | 69 const FilePath& drive_file_path) |
| 70 : upload_mode(upload_mode), | 70 : upload_mode(upload_mode), |
| 71 title(title), | 71 title(title), |
| 72 content_type(content_type), | 72 content_type(content_type), |
| 73 content_length(content_length), | 73 content_length(content_length), |
| 74 upload_location(upload_location), | 74 upload_location(upload_location), |
| 75 virtual_path(virtual_path) { | 75 drive_file_path(drive_file_path) { |
| 76 } | 76 } |
| 77 | 77 |
| 78 InitiateUploadParams::~InitiateUploadParams() { | 78 InitiateUploadParams::~InitiateUploadParams() { |
| 79 } | 79 } |
| 80 | 80 |
| 81 ResumeUploadParams::ResumeUploadParams( | 81 ResumeUploadParams::ResumeUploadParams( |
| 82 UploadMode upload_mode, | 82 UploadMode upload_mode, |
| 83 int64 start_range, | 83 int64 start_range, |
| 84 int64 end_range, | 84 int64 end_range, |
| 85 int64 content_length, | 85 int64 content_length, |
| 86 const std::string& content_type, | 86 const std::string& content_type, |
| 87 scoped_refptr<net::IOBuffer> buf, | 87 scoped_refptr<net::IOBuffer> buf, |
| 88 const GURL& upload_location, | 88 const GURL& upload_location, |
| 89 const FilePath& virtual_path) : upload_mode(upload_mode), | 89 const FilePath& drive_file_path) : upload_mode(upload_mode), |
| 90 start_range(start_range), | 90 start_range(start_range), |
| 91 end_range(end_range), | 91 end_range(end_range), |
| 92 content_length(content_length), | 92 content_length(content_length), |
| 93 content_type(content_type), | 93 content_type(content_type), |
| 94 buf(buf), | 94 buf(buf), |
| 95 upload_location(upload_location), | 95 upload_location(upload_location), |
| 96 virtual_path(virtual_path) { | 96 drive_file_path(drive_file_path) { |
| 97 } | 97 } |
| 98 | 98 |
| 99 ResumeUploadParams::~ResumeUploadParams() { | 99 ResumeUploadParams::~ResumeUploadParams() { |
| 100 } | 100 } |
| 101 | 101 |
| 102 //============================ GetDocumentsOperation =========================== | 102 //============================ GetDocumentsOperation =========================== |
| 103 | 103 |
| 104 GetDocumentsOperation::GetDocumentsOperation( | 104 GetDocumentsOperation::GetDocumentsOperation( |
| 105 OperationRegistry* registry, | 105 OperationRegistry* registry, |
| 106 const GDataWapiUrlGenerator& url_generator, | 106 const GDataWapiUrlGenerator& url_generator, |
| 107 const GURL& url, | 107 const GURL& override_url, |
| 108 int start_changestamp, | 108 int start_changestamp, |
| 109 const std::string& search_string, | 109 const std::string& search_string, |
| 110 bool shared_with_me, | 110 bool shared_with_me, |
| 111 const std::string& directory_resource_id, | 111 const std::string& directory_resource_id, |
| 112 const GetDataCallback& callback) | 112 const GetDataCallback& callback) |
| 113 : GetDataOperation(registry, callback), | 113 : GetDataOperation(registry, callback), |
| 114 url_generator_(url_generator), | 114 url_generator_(url_generator), |
| 115 override_url_(url), | 115 override_url_(override_url), |
| 116 start_changestamp_(start_changestamp), | 116 start_changestamp_(start_changestamp), |
| 117 search_string_(search_string), | 117 search_string_(search_string), |
| 118 shared_with_me_(shared_with_me), | 118 shared_with_me_(shared_with_me), |
| 119 directory_resource_id_(directory_resource_id) { | 119 directory_resource_id_(directory_resource_id) { |
| 120 } | 120 } |
| 121 | 121 |
| 122 GetDocumentsOperation::~GetDocumentsOperation() {} | 122 GetDocumentsOperation::~GetDocumentsOperation() {} |
| 123 | 123 |
| 124 GURL GetDocumentsOperation::GetURL() const { | 124 GURL GetDocumentsOperation::GetURL() const { |
| 125 return url_generator_.GenerateDocumentListUrl(override_url_, | 125 return url_generator_.GenerateDocumentListUrl(override_url_, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 GURL GetAccountMetadataOperation::GetURL() const { | 162 GURL GetAccountMetadataOperation::GetURL() const { |
| 163 return url_generator_.GenerateAccountMetadataUrl(); | 163 return url_generator_.GenerateAccountMetadataUrl(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 //============================ DownloadFileOperation =========================== | 166 //============================ DownloadFileOperation =========================== |
| 167 | 167 |
| 168 DownloadFileOperation::DownloadFileOperation( | 168 DownloadFileOperation::DownloadFileOperation( |
| 169 OperationRegistry* registry, | 169 OperationRegistry* registry, |
| 170 const DownloadActionCallback& download_action_callback, | 170 const DownloadActionCallback& download_action_callback, |
| 171 const GetContentCallback& get_content_callback, | 171 const GetContentCallback& get_content_callback, |
| 172 const GURL& document_url, | 172 const GURL& content_url, |
| 173 const FilePath& virtual_path, | 173 const FilePath& drive_file_path, |
| 174 const FilePath& output_file_path) | 174 const FilePath& output_file_path) |
| 175 : UrlFetchOperationBase(registry, | 175 : UrlFetchOperationBase(registry, |
| 176 OPERATION_DOWNLOAD, | 176 OPERATION_DOWNLOAD, |
| 177 virtual_path), | 177 drive_file_path), |
| 178 download_action_callback_(download_action_callback), | 178 download_action_callback_(download_action_callback), |
| 179 get_content_callback_(get_content_callback), | 179 get_content_callback_(get_content_callback), |
| 180 document_url_(document_url) { | 180 content_url_(content_url) { |
| 181 // Make sure we download the content into a temp file. | 181 // Make sure we download the content into a temp file. |
| 182 if (output_file_path.empty()) | 182 if (output_file_path.empty()) |
| 183 save_temp_file_ = true; | 183 save_temp_file_ = true; |
| 184 else | 184 else |
| 185 output_file_path_ = output_file_path; | 185 output_file_path_ = output_file_path; |
| 186 } | 186 } |
| 187 | 187 |
| 188 DownloadFileOperation::~DownloadFileOperation() {} | 188 DownloadFileOperation::~DownloadFileOperation() {} |
| 189 | 189 |
| 190 // Overridden from UrlFetchOperationBase. | 190 // Overridden from UrlFetchOperationBase. |
| 191 GURL DownloadFileOperation::GetURL() const { | 191 GURL DownloadFileOperation::GetURL() const { |
| 192 return document_url_; | 192 return content_url_; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void DownloadFileOperation::OnURLFetchDownloadProgress(const URLFetcher* source, | 195 void DownloadFileOperation::OnURLFetchDownloadProgress(const URLFetcher* source, |
| 196 int64 current, | 196 int64 current, |
| 197 int64 total) { | 197 int64 total) { |
| 198 NotifyProgress(current, total); | 198 NotifyProgress(current, total); |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool DownloadFileOperation::ShouldSendDownloadData() { | 201 bool DownloadFileOperation::ShouldSendDownloadData() { |
| 202 return !get_content_callback_.is_null(); | 202 return !get_content_callback_.is_null(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 228 void DownloadFileOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { | 228 void DownloadFileOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { |
| 229 if (!download_action_callback_.is_null()) | 229 if (!download_action_callback_.is_null()) |
| 230 download_action_callback_.Run(code, FilePath()); | 230 download_action_callback_.Run(code, FilePath()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 //=========================== DeleteDocumentOperation ========================== | 233 //=========================== DeleteDocumentOperation ========================== |
| 234 | 234 |
| 235 DeleteDocumentOperation::DeleteDocumentOperation( | 235 DeleteDocumentOperation::DeleteDocumentOperation( |
| 236 OperationRegistry* registry, | 236 OperationRegistry* registry, |
| 237 const EntryActionCallback& callback, | 237 const EntryActionCallback& callback, |
| 238 const GURL& document_url) | 238 const GURL& edit_url) |
| 239 : EntryActionOperation(registry, callback), | 239 : EntryActionOperation(registry, callback), |
| 240 document_url_(document_url) { | 240 edit_url_(edit_url) { |
| 241 } | 241 } |
| 242 | 242 |
| 243 DeleteDocumentOperation::~DeleteDocumentOperation() {} | 243 DeleteDocumentOperation::~DeleteDocumentOperation() {} |
| 244 | 244 |
| 245 GURL DeleteDocumentOperation::GetURL() const { | 245 GURL DeleteDocumentOperation::GetURL() const { |
| 246 return GDataWapiUrlGenerator::AddStandardUrlParams(document_url_); | 246 return GDataWapiUrlGenerator::AddStandardUrlParams(edit_url_); |
| 247 } | 247 } |
| 248 | 248 |
| 249 URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { | 249 URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { |
| 250 return URLFetcher::DELETE_REQUEST; | 250 return URLFetcher::DELETE_REQUEST; |
| 251 } | 251 } |
| 252 | 252 |
| 253 std::vector<std::string> | 253 std::vector<std::string> |
| 254 DeleteDocumentOperation::GetExtraRequestHeaders() const { | 254 DeleteDocumentOperation::GetExtraRequestHeaders() const { |
| 255 std::vector<std::string> headers; | 255 std::vector<std::string> headers; |
| 256 headers.push_back(kIfMatchAllHeader); | 256 headers.push_back(kIfMatchAllHeader); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 DVLOG(1) << "CopyDocumentOperation data: " << *upload_content_type << ", [" | 351 DVLOG(1) << "CopyDocumentOperation data: " << *upload_content_type << ", [" |
| 352 << *upload_content << "]"; | 352 << *upload_content << "]"; |
| 353 return true; | 353 return true; |
| 354 } | 354 } |
| 355 | 355 |
| 356 //=========================== RenameResourceOperation ========================== | 356 //=========================== RenameResourceOperation ========================== |
| 357 | 357 |
| 358 RenameResourceOperation::RenameResourceOperation( | 358 RenameResourceOperation::RenameResourceOperation( |
| 359 OperationRegistry* registry, | 359 OperationRegistry* registry, |
| 360 const EntryActionCallback& callback, | 360 const EntryActionCallback& callback, |
| 361 const GURL& document_url, | 361 const GURL& edit_url, |
| 362 const FilePath::StringType& new_name) | 362 const FilePath::StringType& new_name) |
| 363 : EntryActionOperation(registry, callback), | 363 : EntryActionOperation(registry, callback), |
| 364 document_url_(document_url), | 364 edit_url_(edit_url), |
| 365 new_name_(new_name) { | 365 new_name_(new_name) { |
| 366 } | 366 } |
| 367 | 367 |
| 368 RenameResourceOperation::~RenameResourceOperation() {} | 368 RenameResourceOperation::~RenameResourceOperation() {} |
| 369 | 369 |
| 370 URLFetcher::RequestType RenameResourceOperation::GetRequestType() const { | 370 URLFetcher::RequestType RenameResourceOperation::GetRequestType() const { |
| 371 return URLFetcher::PUT; | 371 return URLFetcher::PUT; |
| 372 } | 372 } |
| 373 | 373 |
| 374 std::vector<std::string> | 374 std::vector<std::string> |
| 375 RenameResourceOperation::GetExtraRequestHeaders() const { | 375 RenameResourceOperation::GetExtraRequestHeaders() const { |
| 376 std::vector<std::string> headers; | 376 std::vector<std::string> headers; |
| 377 headers.push_back(kIfMatchAllHeader); | 377 headers.push_back(kIfMatchAllHeader); |
| 378 return headers; | 378 return headers; |
| 379 } | 379 } |
| 380 | 380 |
| 381 GURL RenameResourceOperation::GetURL() const { | 381 GURL RenameResourceOperation::GetURL() const { |
| 382 return GDataWapiUrlGenerator::AddStandardUrlParams(document_url_); | 382 return GDataWapiUrlGenerator::AddStandardUrlParams(edit_url_); |
| 383 } | 383 } |
| 384 | 384 |
| 385 bool RenameResourceOperation::GetContentData(std::string* upload_content_type, | 385 bool RenameResourceOperation::GetContentData(std::string* upload_content_type, |
| 386 std::string* upload_content) { | 386 std::string* upload_content) { |
| 387 upload_content_type->assign("application/atom+xml"); | 387 upload_content_type->assign("application/atom+xml"); |
| 388 XmlWriter xml_writer; | 388 XmlWriter xml_writer; |
| 389 xml_writer.StartWriting(); | 389 xml_writer.StartWriting(); |
| 390 xml_writer.StartElement("entry"); | 390 xml_writer.StartElement("entry"); |
| 391 xml_writer.AddAttribute("xmlns", "http://www.w3.org/2005/Atom"); | 391 xml_writer.AddAttribute("xmlns", "http://www.w3.org/2005/Atom"); |
| 392 | 392 |
| 393 xml_writer.WriteElement("title", FilePath(new_name_).AsUTF8Unsafe()); | 393 xml_writer.WriteElement("title", FilePath(new_name_).AsUTF8Unsafe()); |
| 394 | 394 |
| 395 xml_writer.EndElement(); // Ends "entry" element. | 395 xml_writer.EndElement(); // Ends "entry" element. |
| 396 xml_writer.StopWriting(); | 396 xml_writer.StopWriting(); |
| 397 upload_content->assign(xml_writer.GetWrittenString()); | 397 upload_content->assign(xml_writer.GetWrittenString()); |
| 398 DVLOG(1) << "RenameResourceOperation data: " << *upload_content_type << ", [" | 398 DVLOG(1) << "RenameResourceOperation data: " << *upload_content_type << ", [" |
| 399 << *upload_content << "]"; | 399 << *upload_content << "]"; |
| 400 return true; | 400 return true; |
| 401 } | 401 } |
| 402 | 402 |
| 403 //=========================== AuthorizeAppOperation ========================== | 403 //=========================== AuthorizeAppOperation ========================== |
| 404 | 404 |
| 405 AuthorizeAppOperation::AuthorizeAppOperation( | 405 AuthorizeAppOperation::AuthorizeAppOperation( |
| 406 OperationRegistry* registry, | 406 OperationRegistry* registry, |
| 407 const GetDataCallback& callback, | 407 const GetDataCallback& callback, |
| 408 const GURL& document_url, | 408 const GURL& edit_url, |
| 409 const std::string& app_id) | 409 const std::string& app_id) |
| 410 : GetDataOperation(registry, callback), | 410 : GetDataOperation(registry, callback), |
| 411 app_id_(app_id), | 411 app_id_(app_id), |
| 412 document_url_(document_url) { | 412 edit_url_(edit_url) { |
| 413 } | 413 } |
| 414 | 414 |
| 415 AuthorizeAppOperation::~AuthorizeAppOperation() {} | 415 AuthorizeAppOperation::~AuthorizeAppOperation() {} |
| 416 | 416 |
| 417 URLFetcher::RequestType AuthorizeAppOperation::GetRequestType() const { | 417 URLFetcher::RequestType AuthorizeAppOperation::GetRequestType() const { |
| 418 return URLFetcher::PUT; | 418 return URLFetcher::PUT; |
| 419 } | 419 } |
| 420 | 420 |
| 421 std::vector<std::string> | 421 std::vector<std::string> |
| 422 AuthorizeAppOperation::GetExtraRequestHeaders() const { | 422 AuthorizeAppOperation::GetExtraRequestHeaders() const { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 link_list->Append(link); | 488 link_list->Append(link); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 | 491 |
| 492 RunCallback(fetch_error_code, link_list.PassAs<base::Value>()); | 492 RunCallback(fetch_error_code, link_list.PassAs<base::Value>()); |
| 493 const bool success = true; | 493 const bool success = true; |
| 494 OnProcessURLFetchResultsComplete(success); | 494 OnProcessURLFetchResultsComplete(success); |
| 495 } | 495 } |
| 496 | 496 |
| 497 GURL AuthorizeAppOperation::GetURL() const { | 497 GURL AuthorizeAppOperation::GetURL() const { |
| 498 return document_url_; | 498 return edit_url_; |
| 499 } | 499 } |
| 500 | 500 |
| 501 //======================= AddResourceToDirectoryOperation ====================== | 501 //======================= AddResourceToDirectoryOperation ====================== |
| 502 | 502 |
| 503 AddResourceToDirectoryOperation::AddResourceToDirectoryOperation( | 503 AddResourceToDirectoryOperation::AddResourceToDirectoryOperation( |
| 504 OperationRegistry* registry, | 504 OperationRegistry* registry, |
| 505 const GDataWapiUrlGenerator& url_generator, | 505 const GDataWapiUrlGenerator& url_generator, |
| 506 const EntryActionCallback& callback, | 506 const EntryActionCallback& callback, |
| 507 const GURL& parent_content_url, | 507 const GURL& parent_content_url, |
| 508 const GURL& document_url) | 508 const GURL& edit_url) |
| 509 : EntryActionOperation(registry, callback), | 509 : EntryActionOperation(registry, callback), |
| 510 url_generator_(url_generator), | 510 url_generator_(url_generator), |
| 511 parent_content_url_(parent_content_url), | 511 parent_content_url_(parent_content_url), |
| 512 document_url_(document_url) { | 512 edit_url_(edit_url) { |
| 513 } | 513 } |
| 514 | 514 |
| 515 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} | 515 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} |
| 516 | 516 |
| 517 GURL AddResourceToDirectoryOperation::GetURL() const { | 517 GURL AddResourceToDirectoryOperation::GetURL() const { |
| 518 if (!parent_content_url_.is_empty()) | 518 if (!parent_content_url_.is_empty()) |
| 519 return GDataWapiUrlGenerator::AddStandardUrlParams(parent_content_url_); | 519 return GDataWapiUrlGenerator::AddStandardUrlParams(parent_content_url_); |
| 520 | 520 |
| 521 return url_generator_.GenerateDocumentListRootUrl(); | 521 return url_generator_.GenerateDocumentListRootUrl(); |
| 522 } | 522 } |
| 523 | 523 |
| 524 URLFetcher::RequestType | 524 URLFetcher::RequestType |
| 525 AddResourceToDirectoryOperation::GetRequestType() const { | 525 AddResourceToDirectoryOperation::GetRequestType() const { |
| 526 return URLFetcher::POST; | 526 return URLFetcher::POST; |
| 527 } | 527 } |
| 528 | 528 |
| 529 bool AddResourceToDirectoryOperation::GetContentData( | 529 bool AddResourceToDirectoryOperation::GetContentData( |
| 530 std::string* upload_content_type, std::string* upload_content) { | 530 std::string* upload_content_type, std::string* upload_content) { |
| 531 upload_content_type->assign("application/atom+xml"); | 531 upload_content_type->assign("application/atom+xml"); |
| 532 XmlWriter xml_writer; | 532 XmlWriter xml_writer; |
| 533 xml_writer.StartWriting(); | 533 xml_writer.StartWriting(); |
| 534 xml_writer.StartElement("entry"); | 534 xml_writer.StartElement("entry"); |
| 535 xml_writer.AddAttribute("xmlns", "http://www.w3.org/2005/Atom"); | 535 xml_writer.AddAttribute("xmlns", "http://www.w3.org/2005/Atom"); |
| 536 | 536 |
| 537 xml_writer.WriteElement("id", document_url_.spec()); | 537 xml_writer.WriteElement("id", edit_url_.spec()); |
| 538 | 538 |
| 539 xml_writer.EndElement(); // Ends "entry" element. | 539 xml_writer.EndElement(); // Ends "entry" element. |
| 540 xml_writer.StopWriting(); | 540 xml_writer.StopWriting(); |
| 541 upload_content->assign(xml_writer.GetWrittenString()); | 541 upload_content->assign(xml_writer.GetWrittenString()); |
| 542 DVLOG(1) << "AddResourceToDirectoryOperation data: " << *upload_content_type | 542 DVLOG(1) << "AddResourceToDirectoryOperation data: " << *upload_content_type |
| 543 << ", [" << *upload_content << "]"; | 543 << ", [" << *upload_content << "]"; |
| 544 return true; | 544 return true; |
| 545 } | 545 } |
| 546 | 546 |
| 547 //==================== RemoveResourceFromDirectoryOperation ==================== | 547 //==================== RemoveResourceFromDirectoryOperation ==================== |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 } | 580 } |
| 581 | 581 |
| 582 //=========================== InitiateUploadOperation ========================== | 582 //=========================== InitiateUploadOperation ========================== |
| 583 | 583 |
| 584 InitiateUploadOperation::InitiateUploadOperation( | 584 InitiateUploadOperation::InitiateUploadOperation( |
| 585 OperationRegistry* registry, | 585 OperationRegistry* registry, |
| 586 const InitiateUploadCallback& callback, | 586 const InitiateUploadCallback& callback, |
| 587 const InitiateUploadParams& params) | 587 const InitiateUploadParams& params) |
| 588 : UrlFetchOperationBase(registry, | 588 : UrlFetchOperationBase(registry, |
| 589 OPERATION_UPLOAD, | 589 OPERATION_UPLOAD, |
| 590 params.virtual_path), | 590 params.drive_file_path), |
| 591 callback_(callback), | 591 callback_(callback), |
| 592 params_(params), | 592 params_(params), |
| 593 initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter( | 593 initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter( |
| 594 params.upload_location, | 594 params.upload_location, |
| 595 kUploadParamConvertKey, | 595 kUploadParamConvertKey, |
| 596 kUploadParamConvertValue)) { | 596 kUploadParamConvertValue)) { |
| 597 } | 597 } |
| 598 | 598 |
| 599 InitiateUploadOperation::~InitiateUploadOperation() {} | 599 InitiateUploadOperation::~InitiateUploadOperation() {} |
| 600 | 600 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 } | 685 } |
| 686 | 686 |
| 687 //============================ ResumeUploadOperation =========================== | 687 //============================ ResumeUploadOperation =========================== |
| 688 | 688 |
| 689 ResumeUploadOperation::ResumeUploadOperation( | 689 ResumeUploadOperation::ResumeUploadOperation( |
| 690 OperationRegistry* registry, | 690 OperationRegistry* registry, |
| 691 const ResumeUploadCallback& callback, | 691 const ResumeUploadCallback& callback, |
| 692 const ResumeUploadParams& params) | 692 const ResumeUploadParams& params) |
| 693 : UrlFetchOperationBase(registry, | 693 : UrlFetchOperationBase(registry, |
| 694 OPERATION_UPLOAD, | 694 OPERATION_UPLOAD, |
| 695 params.virtual_path), | 695 params.drive_file_path), |
| 696 callback_(callback), | 696 callback_(callback), |
| 697 params_(params), | 697 params_(params), |
| 698 last_chunk_completed_(false) { | 698 last_chunk_completed_(false) { |
| 699 } | 699 } |
| 700 | 700 |
| 701 ResumeUploadOperation::~ResumeUploadOperation() {} | 701 ResumeUploadOperation::~ResumeUploadOperation() {} |
| 702 | 702 |
| 703 GURL ResumeUploadOperation::GetURL() const { | 703 GURL ResumeUploadOperation::GetURL() const { |
| 704 return params_.upload_location; | 704 return params_.upload_location; |
| 705 } | 705 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 717 hdrs->EnumerateHeader(NULL, kUploadResponseRange, &range_received); | 717 hdrs->EnumerateHeader(NULL, kUploadResponseRange, &range_received); |
| 718 if (!range_received.empty()) { // Parse the range header. | 718 if (!range_received.empty()) { // Parse the range header. |
| 719 std::vector<net::HttpByteRange> ranges; | 719 std::vector<net::HttpByteRange> ranges; |
| 720 if (net::HttpUtil::ParseRangeHeader(range_received, &ranges) && | 720 if (net::HttpUtil::ParseRangeHeader(range_received, &ranges) && |
| 721 !ranges.empty() ) { | 721 !ranges.empty() ) { |
| 722 // We only care about the first start-end pair in the range. | 722 // We only care about the first start-end pair in the range. |
| 723 start_range_received = ranges[0].first_byte_position(); | 723 start_range_received = ranges[0].first_byte_position(); |
| 724 end_range_received = ranges[0].last_byte_position(); | 724 end_range_received = ranges[0].last_byte_position(); |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 DVLOG(1) << "Got response for [" << params_.virtual_path.value() | 727 DVLOG(1) << "Got response for [" << params_.drive_file_path.value() |
| 728 << "]: code=" << code | 728 << "]: code=" << code |
| 729 << ", range_hdr=[" << range_received | 729 << ", range_hdr=[" << range_received |
| 730 << "], range_parsed=" << start_range_received | 730 << "], range_parsed=" << start_range_received |
| 731 << "," << end_range_received; | 731 << "," << end_range_received; |
| 732 } else { | 732 } else { |
| 733 // There might be explanation of unexpected error code in response. | 733 // There might be explanation of unexpected error code in response. |
| 734 std::string response_content; | 734 std::string response_content; |
| 735 source->GetResponseAsString(&response_content); | 735 source->GetResponseAsString(&response_content); |
| 736 DVLOG(1) << "Got response for [" << params_.virtual_path.value() | 736 DVLOG(1) << "Got response for [" << params_.drive_file_path.value() |
| 737 << "]: code=" << code | 737 << "]: code=" << code |
| 738 << ", content=[\n" << response_content << "\n]"; | 738 << ", content=[\n" << response_content << "\n]"; |
| 739 | 739 |
| 740 // Parse entry XML. | 740 // Parse entry XML. |
| 741 XmlReader xml_reader; | 741 XmlReader xml_reader; |
| 742 if (xml_reader.Load(response_content)) { | 742 if (xml_reader.Load(response_content)) { |
| 743 while (xml_reader.Read()) { | 743 while (xml_reader.Read()) { |
| 744 if (xml_reader.NodeName() == DocumentEntry::GetEntryNodeName()) { | 744 if (xml_reader.NodeName() == DocumentEntry::GetEntryNodeName()) { |
| 745 entry = DocumentEntry::CreateFromXml(&xml_reader); | 745 entry = DocumentEntry::CreateFromXml(&xml_reader); |
| 746 break; | 746 break; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 return true; | 825 return true; |
| 826 } | 826 } |
| 827 | 827 |
| 828 void ResumeUploadOperation::OnURLFetchUploadProgress( | 828 void ResumeUploadOperation::OnURLFetchUploadProgress( |
| 829 const URLFetcher* source, int64 current, int64 total) { | 829 const URLFetcher* source, int64 current, int64 total) { |
| 830 // Adjust the progress values according to the range currently uploaded. | 830 // Adjust the progress values according to the range currently uploaded. |
| 831 NotifyProgress(params_.start_range + current, params_.content_length); | 831 NotifyProgress(params_.start_range + current, params_.content_length); |
| 832 } | 832 } |
| 833 | 833 |
| 834 } // namespace google_apis | 834 } // namespace google_apis |
| OLD | NEW |