| 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/chromeos/gdata/gdata_operations.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_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/chromeos/gdata/gdata_util.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 upload_location(upload_location), | 207 upload_location(upload_location), |
| 208 virtual_path(virtual_path) { | 208 virtual_path(virtual_path) { |
| 209 } | 209 } |
| 210 | 210 |
| 211 ResumeUploadParams::~ResumeUploadParams() { | 211 ResumeUploadParams::~ResumeUploadParams() { |
| 212 } | 212 } |
| 213 | 213 |
| 214 //============================ GetDocumentsOperation =========================== | 214 //============================ GetDocumentsOperation =========================== |
| 215 | 215 |
| 216 GetDocumentsOperation::GetDocumentsOperation( | 216 GetDocumentsOperation::GetDocumentsOperation( |
| 217 GDataOperationRegistry* registry, | 217 OperationRegistry* registry, |
| 218 const GURL& url, | 218 const GURL& url, |
| 219 int start_changestamp, | 219 int start_changestamp, |
| 220 const std::string& search_string, | 220 const std::string& search_string, |
| 221 const std::string& directory_resource_id, | 221 const std::string& directory_resource_id, |
| 222 const GetDataCallback& callback) | 222 const GetDataCallback& callback) |
| 223 : GetDataOperation(registry, callback), | 223 : GetDataOperation(registry, callback), |
| 224 override_url_(url), | 224 override_url_(url), |
| 225 start_changestamp_(start_changestamp), | 225 start_changestamp_(start_changestamp), |
| 226 search_string_(search_string), | 226 search_string_(search_string), |
| 227 directory_resource_id_(directory_resource_id) { | 227 directory_resource_id_(directory_resource_id) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 248 | 248 |
| 249 return AddFeedUrlParams(GURL(kGetChangesListURL), | 249 return AddFeedUrlParams(GURL(kGetChangesListURL), |
| 250 kMaxDocumentsPerFeed, | 250 kMaxDocumentsPerFeed, |
| 251 start_changestamp_, | 251 start_changestamp_, |
| 252 std::string()); | 252 std::string()); |
| 253 } | 253 } |
| 254 | 254 |
| 255 //============================ GetDocumentEntryOperation ======================= | 255 //============================ GetDocumentEntryOperation ======================= |
| 256 | 256 |
| 257 GetDocumentEntryOperation::GetDocumentEntryOperation( | 257 GetDocumentEntryOperation::GetDocumentEntryOperation( |
| 258 GDataOperationRegistry* registry, | 258 OperationRegistry* registry, |
| 259 const std::string& resource_id, | 259 const std::string& resource_id, |
| 260 const GetDataCallback& callback) | 260 const GetDataCallback& callback) |
| 261 : GetDataOperation(registry, callback), | 261 : GetDataOperation(registry, callback), |
| 262 resource_id_(resource_id) { | 262 resource_id_(resource_id) { |
| 263 } | 263 } |
| 264 | 264 |
| 265 GetDocumentEntryOperation::~GetDocumentEntryOperation() {} | 265 GetDocumentEntryOperation::~GetDocumentEntryOperation() {} |
| 266 | 266 |
| 267 GURL GetDocumentEntryOperation::GetURL() const { | 267 GURL GetDocumentEntryOperation::GetURL() const { |
| 268 GURL result = GURL(base::StringPrintf(kGetDocumentEntryURLFormat, | 268 GURL result = GURL(base::StringPrintf(kGetDocumentEntryURLFormat, |
| 269 net::EscapePath(resource_id_).c_str())); | 269 net::EscapePath(resource_id_).c_str())); |
| 270 return AddStandardUrlParams(result); | 270 return AddStandardUrlParams(result); |
| 271 } | 271 } |
| 272 | 272 |
| 273 //========================= GetAccountMetadataOperation ======================== | 273 //========================= GetAccountMetadataOperation ======================== |
| 274 | 274 |
| 275 GetAccountMetadataOperation::GetAccountMetadataOperation( | 275 GetAccountMetadataOperation::GetAccountMetadataOperation( |
| 276 GDataOperationRegistry* registry, | 276 OperationRegistry* registry, |
| 277 const GetDataCallback& callback) | 277 const GetDataCallback& callback) |
| 278 : GetDataOperation(registry, callback) { | 278 : GetDataOperation(registry, callback) { |
| 279 } | 279 } |
| 280 | 280 |
| 281 GetAccountMetadataOperation::~GetAccountMetadataOperation() {} | 281 GetAccountMetadataOperation::~GetAccountMetadataOperation() {} |
| 282 | 282 |
| 283 GURL GetAccountMetadataOperation::GetURL() const { | 283 GURL GetAccountMetadataOperation::GetURL() const { |
| 284 return AddMetadataUrlParams(GURL(kAccountMetadataURL)); | 284 return AddMetadataUrlParams(GURL(kAccountMetadataURL)); |
| 285 } | 285 } |
| 286 | 286 |
| 287 //============================ DownloadFileOperation =========================== | 287 //============================ DownloadFileOperation =========================== |
| 288 | 288 |
| 289 DownloadFileOperation::DownloadFileOperation( | 289 DownloadFileOperation::DownloadFileOperation( |
| 290 GDataOperationRegistry* registry, | 290 OperationRegistry* registry, |
| 291 const DownloadActionCallback& download_action_callback, | 291 const DownloadActionCallback& download_action_callback, |
| 292 const GetContentCallback& get_content_callback, | 292 const GetContentCallback& get_content_callback, |
| 293 const GURL& document_url, | 293 const GURL& document_url, |
| 294 const FilePath& virtual_path, | 294 const FilePath& virtual_path, |
| 295 const FilePath& output_file_path) | 295 const FilePath& output_file_path) |
| 296 : UrlFetchOperationBase(registry, | 296 : UrlFetchOperationBase(registry, |
| 297 GDataOperationRegistry::OPERATION_DOWNLOAD, | 297 OperationRegistry::OPERATION_DOWNLOAD, |
| 298 virtual_path), | 298 virtual_path), |
| 299 download_action_callback_(download_action_callback), | 299 download_action_callback_(download_action_callback), |
| 300 get_content_callback_(get_content_callback), | 300 get_content_callback_(get_content_callback), |
| 301 document_url_(document_url) { | 301 document_url_(document_url) { |
| 302 // Make sure we download the content into a temp file. | 302 // Make sure we download the content into a temp file. |
| 303 if (output_file_path.empty()) | 303 if (output_file_path.empty()) |
| 304 save_temp_file_ = true; | 304 save_temp_file_ = true; |
| 305 else | 305 else |
| 306 output_file_path_ = output_file_path; | 306 output_file_path_ = output_file_path; |
| 307 } | 307 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 void DownloadFileOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { | 349 void DownloadFileOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { |
| 350 if (!download_action_callback_.is_null()) | 350 if (!download_action_callback_.is_null()) |
| 351 download_action_callback_.Run(code, document_url_, FilePath()); | 351 download_action_callback_.Run(code, document_url_, FilePath()); |
| 352 } | 352 } |
| 353 | 353 |
| 354 //=========================== DeleteDocumentOperation ========================== | 354 //=========================== DeleteDocumentOperation ========================== |
| 355 | 355 |
| 356 DeleteDocumentOperation::DeleteDocumentOperation( | 356 DeleteDocumentOperation::DeleteDocumentOperation( |
| 357 GDataOperationRegistry* registry, | 357 OperationRegistry* registry, |
| 358 const EntryActionCallback& callback, | 358 const EntryActionCallback& callback, |
| 359 const GURL& document_url) | 359 const GURL& document_url) |
| 360 : EntryActionOperation(registry, callback, document_url) { | 360 : EntryActionOperation(registry, callback, document_url) { |
| 361 } | 361 } |
| 362 | 362 |
| 363 DeleteDocumentOperation::~DeleteDocumentOperation() {} | 363 DeleteDocumentOperation::~DeleteDocumentOperation() {} |
| 364 | 364 |
| 365 GURL DeleteDocumentOperation::GetURL() const { | 365 GURL DeleteDocumentOperation::GetURL() const { |
| 366 return AddStandardUrlParams(document_url()); | 366 return AddStandardUrlParams(document_url()); |
| 367 } | 367 } |
| 368 | 368 |
| 369 URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { | 369 URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { |
| 370 return URLFetcher::DELETE_REQUEST; | 370 return URLFetcher::DELETE_REQUEST; |
| 371 } | 371 } |
| 372 | 372 |
| 373 std::vector<std::string> | 373 std::vector<std::string> |
| 374 DeleteDocumentOperation::GetExtraRequestHeaders() const { | 374 DeleteDocumentOperation::GetExtraRequestHeaders() const { |
| 375 std::vector<std::string> headers; | 375 std::vector<std::string> headers; |
| 376 headers.push_back(kIfMatchAllHeader); | 376 headers.push_back(kIfMatchAllHeader); |
| 377 return headers; | 377 return headers; |
| 378 } | 378 } |
| 379 | 379 |
| 380 //========================== CreateDirectoryOperation ========================== | 380 //========================== CreateDirectoryOperation ========================== |
| 381 | 381 |
| 382 CreateDirectoryOperation::CreateDirectoryOperation( | 382 CreateDirectoryOperation::CreateDirectoryOperation( |
| 383 GDataOperationRegistry* registry, | 383 OperationRegistry* registry, |
| 384 const GetDataCallback& callback, | 384 const GetDataCallback& callback, |
| 385 const GURL& parent_content_url, | 385 const GURL& parent_content_url, |
| 386 const FilePath::StringType& directory_name) | 386 const FilePath::StringType& directory_name) |
| 387 : GetDataOperation(registry, callback), | 387 : GetDataOperation(registry, callback), |
| 388 parent_content_url_(parent_content_url), | 388 parent_content_url_(parent_content_url), |
| 389 directory_name_(directory_name) { | 389 directory_name_(directory_name) { |
| 390 } | 390 } |
| 391 | 391 |
| 392 CreateDirectoryOperation::~CreateDirectoryOperation() {} | 392 CreateDirectoryOperation::~CreateDirectoryOperation() {} |
| 393 | 393 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 424 xml_writer.StopWriting(); | 424 xml_writer.StopWriting(); |
| 425 upload_content->assign(xml_writer.GetWrittenString()); | 425 upload_content->assign(xml_writer.GetWrittenString()); |
| 426 DVLOG(1) << "CreateDirectory data: " << *upload_content_type << ", [" | 426 DVLOG(1) << "CreateDirectory data: " << *upload_content_type << ", [" |
| 427 << *upload_content << "]"; | 427 << *upload_content << "]"; |
| 428 return true; | 428 return true; |
| 429 } | 429 } |
| 430 | 430 |
| 431 //============================ CopyDocumentOperation =========================== | 431 //============================ CopyDocumentOperation =========================== |
| 432 | 432 |
| 433 CopyDocumentOperation::CopyDocumentOperation( | 433 CopyDocumentOperation::CopyDocumentOperation( |
| 434 GDataOperationRegistry* registry, | 434 OperationRegistry* registry, |
| 435 const GetDataCallback& callback, | 435 const GetDataCallback& callback, |
| 436 const std::string& resource_id, | 436 const std::string& resource_id, |
| 437 const FilePath::StringType& new_name) | 437 const FilePath::StringType& new_name) |
| 438 : GetDataOperation(registry, callback), | 438 : GetDataOperation(registry, callback), |
| 439 resource_id_(resource_id), | 439 resource_id_(resource_id), |
| 440 new_name_(new_name) { | 440 new_name_(new_name) { |
| 441 } | 441 } |
| 442 | 442 |
| 443 CopyDocumentOperation::~CopyDocumentOperation() {} | 443 CopyDocumentOperation::~CopyDocumentOperation() {} |
| 444 | 444 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 465 xml_writer.StopWriting(); | 465 xml_writer.StopWriting(); |
| 466 upload_content->assign(xml_writer.GetWrittenString()); | 466 upload_content->assign(xml_writer.GetWrittenString()); |
| 467 DVLOG(1) << "CopyDocumentOperation data: " << *upload_content_type << ", [" | 467 DVLOG(1) << "CopyDocumentOperation data: " << *upload_content_type << ", [" |
| 468 << *upload_content << "]"; | 468 << *upload_content << "]"; |
| 469 return true; | 469 return true; |
| 470 } | 470 } |
| 471 | 471 |
| 472 //=========================== RenameResourceOperation ========================== | 472 //=========================== RenameResourceOperation ========================== |
| 473 | 473 |
| 474 RenameResourceOperation::RenameResourceOperation( | 474 RenameResourceOperation::RenameResourceOperation( |
| 475 GDataOperationRegistry* registry, | 475 OperationRegistry* registry, |
| 476 const EntryActionCallback& callback, | 476 const EntryActionCallback& callback, |
| 477 const GURL& document_url, | 477 const GURL& document_url, |
| 478 const FilePath::StringType& new_name) | 478 const FilePath::StringType& new_name) |
| 479 : EntryActionOperation(registry, callback, document_url), | 479 : EntryActionOperation(registry, callback, document_url), |
| 480 new_name_(new_name) { | 480 new_name_(new_name) { |
| 481 } | 481 } |
| 482 | 482 |
| 483 RenameResourceOperation::~RenameResourceOperation() {} | 483 RenameResourceOperation::~RenameResourceOperation() {} |
| 484 | 484 |
| 485 URLFetcher::RequestType RenameResourceOperation::GetRequestType() const { | 485 URLFetcher::RequestType RenameResourceOperation::GetRequestType() const { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 511 xml_writer.StopWriting(); | 511 xml_writer.StopWriting(); |
| 512 upload_content->assign(xml_writer.GetWrittenString()); | 512 upload_content->assign(xml_writer.GetWrittenString()); |
| 513 DVLOG(1) << "RenameResourceOperation data: " << *upload_content_type << ", [" | 513 DVLOG(1) << "RenameResourceOperation data: " << *upload_content_type << ", [" |
| 514 << *upload_content << "]"; | 514 << *upload_content << "]"; |
| 515 return true; | 515 return true; |
| 516 } | 516 } |
| 517 | 517 |
| 518 //=========================== AuthorizeAppOperation ========================== | 518 //=========================== AuthorizeAppOperation ========================== |
| 519 | 519 |
| 520 AuthorizeAppsOperation::AuthorizeAppsOperation( | 520 AuthorizeAppsOperation::AuthorizeAppsOperation( |
| 521 GDataOperationRegistry* registry, | 521 OperationRegistry* registry, |
| 522 const GetDataCallback& callback, | 522 const GetDataCallback& callback, |
| 523 const GURL& document_url, | 523 const GURL& document_url, |
| 524 const std::string& app_id) | 524 const std::string& app_id) |
| 525 : GetDataOperation(registry, callback), | 525 : GetDataOperation(registry, callback), |
| 526 app_id_(app_id), | 526 app_id_(app_id), |
| 527 document_url_(document_url) { | 527 document_url_(document_url) { |
| 528 } | 528 } |
| 529 | 529 |
| 530 AuthorizeAppsOperation::~AuthorizeAppsOperation() {} | 530 AuthorizeAppsOperation::~AuthorizeAppsOperation() {} |
| 531 | 531 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 OnProcessURLFetchResultsComplete(success); | 600 OnProcessURLFetchResultsComplete(success); |
| 601 } | 601 } |
| 602 | 602 |
| 603 GURL AuthorizeAppsOperation::GetURL() const { | 603 GURL AuthorizeAppsOperation::GetURL() const { |
| 604 return document_url_; | 604 return document_url_; |
| 605 } | 605 } |
| 606 | 606 |
| 607 //======================= AddResourceToDirectoryOperation ====================== | 607 //======================= AddResourceToDirectoryOperation ====================== |
| 608 | 608 |
| 609 AddResourceToDirectoryOperation::AddResourceToDirectoryOperation( | 609 AddResourceToDirectoryOperation::AddResourceToDirectoryOperation( |
| 610 GDataOperationRegistry* registry, | 610 OperationRegistry* registry, |
| 611 const EntryActionCallback& callback, | 611 const EntryActionCallback& callback, |
| 612 const GURL& parent_content_url, | 612 const GURL& parent_content_url, |
| 613 const GURL& document_url) | 613 const GURL& document_url) |
| 614 : EntryActionOperation(registry, callback, document_url), | 614 : EntryActionOperation(registry, callback, document_url), |
| 615 parent_content_url_(parent_content_url) { | 615 parent_content_url_(parent_content_url) { |
| 616 } | 616 } |
| 617 | 617 |
| 618 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} | 618 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} |
| 619 | 619 |
| 620 GURL AddResourceToDirectoryOperation::GetURL() const { | 620 GURL AddResourceToDirectoryOperation::GetURL() const { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 643 xml_writer.StopWriting(); | 643 xml_writer.StopWriting(); |
| 644 upload_content->assign(xml_writer.GetWrittenString()); | 644 upload_content->assign(xml_writer.GetWrittenString()); |
| 645 DVLOG(1) << "AddResourceToDirectoryOperation data: " << *upload_content_type | 645 DVLOG(1) << "AddResourceToDirectoryOperation data: " << *upload_content_type |
| 646 << ", [" << *upload_content << "]"; | 646 << ", [" << *upload_content << "]"; |
| 647 return true; | 647 return true; |
| 648 } | 648 } |
| 649 | 649 |
| 650 //==================== RemoveResourceFromDirectoryOperation ==================== | 650 //==================== RemoveResourceFromDirectoryOperation ==================== |
| 651 | 651 |
| 652 RemoveResourceFromDirectoryOperation::RemoveResourceFromDirectoryOperation( | 652 RemoveResourceFromDirectoryOperation::RemoveResourceFromDirectoryOperation( |
| 653 GDataOperationRegistry* registry, | 653 OperationRegistry* registry, |
| 654 const EntryActionCallback& callback, | 654 const EntryActionCallback& callback, |
| 655 const GURL& parent_content_url, | 655 const GURL& parent_content_url, |
| 656 const GURL& document_url, | 656 const GURL& document_url, |
| 657 const std::string& document_resource_id) | 657 const std::string& document_resource_id) |
| 658 : EntryActionOperation(registry, callback, document_url), | 658 : EntryActionOperation(registry, callback, document_url), |
| 659 resource_id_(document_resource_id), | 659 resource_id_(document_resource_id), |
| 660 parent_content_url_(parent_content_url) { | 660 parent_content_url_(parent_content_url) { |
| 661 } | 661 } |
| 662 | 662 |
| 663 RemoveResourceFromDirectoryOperation::~RemoveResourceFromDirectoryOperation() { | 663 RemoveResourceFromDirectoryOperation::~RemoveResourceFromDirectoryOperation() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 679 std::vector<std::string> | 679 std::vector<std::string> |
| 680 RemoveResourceFromDirectoryOperation::GetExtraRequestHeaders() const { | 680 RemoveResourceFromDirectoryOperation::GetExtraRequestHeaders() const { |
| 681 std::vector<std::string> headers; | 681 std::vector<std::string> headers; |
| 682 headers.push_back(kIfMatchAllHeader); | 682 headers.push_back(kIfMatchAllHeader); |
| 683 return headers; | 683 return headers; |
| 684 } | 684 } |
| 685 | 685 |
| 686 //=========================== InitiateUploadOperation ========================== | 686 //=========================== InitiateUploadOperation ========================== |
| 687 | 687 |
| 688 InitiateUploadOperation::InitiateUploadOperation( | 688 InitiateUploadOperation::InitiateUploadOperation( |
| 689 GDataOperationRegistry* registry, | 689 OperationRegistry* registry, |
| 690 const InitiateUploadCallback& callback, | 690 const InitiateUploadCallback& callback, |
| 691 const InitiateUploadParams& params) | 691 const InitiateUploadParams& params) |
| 692 : UrlFetchOperationBase(registry, | 692 : UrlFetchOperationBase(registry, |
| 693 GDataOperationRegistry::OPERATION_UPLOAD, | 693 OperationRegistry::OPERATION_UPLOAD, |
| 694 params.virtual_path), | 694 params.virtual_path), |
| 695 callback_(callback), | 695 callback_(callback), |
| 696 params_(params), | 696 params_(params), |
| 697 initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter( | 697 initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter( |
| 698 params.upload_location, | 698 params.upload_location, |
| 699 kUploadParamConvertKey, | 699 kUploadParamConvertKey, |
| 700 kUploadParamConvertValue)) { | 700 kUploadParamConvertValue)) { |
| 701 } | 701 } |
| 702 | 702 |
| 703 InitiateUploadOperation::~InitiateUploadOperation() {} | 703 InitiateUploadOperation::~InitiateUploadOperation() {} |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 xml_writer.StopWriting(); | 784 xml_writer.StopWriting(); |
| 785 upload_content->assign(xml_writer.GetWrittenString()); | 785 upload_content->assign(xml_writer.GetWrittenString()); |
| 786 DVLOG(1) << "Upload data: " << *upload_content_type << ", [" | 786 DVLOG(1) << "Upload data: " << *upload_content_type << ", [" |
| 787 << *upload_content << "]"; | 787 << *upload_content << "]"; |
| 788 return true; | 788 return true; |
| 789 } | 789 } |
| 790 | 790 |
| 791 //============================ ResumeUploadOperation =========================== | 791 //============================ ResumeUploadOperation =========================== |
| 792 | 792 |
| 793 ResumeUploadOperation::ResumeUploadOperation( | 793 ResumeUploadOperation::ResumeUploadOperation( |
| 794 GDataOperationRegistry* registry, | 794 OperationRegistry* registry, |
| 795 const ResumeUploadCallback& callback, | 795 const ResumeUploadCallback& callback, |
| 796 const ResumeUploadParams& params) | 796 const ResumeUploadParams& params) |
| 797 : UrlFetchOperationBase(registry, | 797 : UrlFetchOperationBase(registry, |
| 798 GDataOperationRegistry::OPERATION_UPLOAD, | 798 OperationRegistry::OPERATION_UPLOAD, |
| 799 params.virtual_path), | 799 params.virtual_path), |
| 800 callback_(callback), | 800 callback_(callback), |
| 801 params_(params), | 801 params_(params), |
| 802 last_chunk_completed_(false) { | 802 last_chunk_completed_(false) { |
| 803 } | 803 } |
| 804 | 804 |
| 805 ResumeUploadOperation::~ResumeUploadOperation() {} | 805 ResumeUploadOperation::~ResumeUploadOperation() {} |
| 806 | 806 |
| 807 GURL ResumeUploadOperation::GetURL() const { | 807 GURL ResumeUploadOperation::GetURL() const { |
| 808 return params_.upload_location; | 808 return params_.upload_location; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 OnProcessURLFetchResultsComplete( | 872 OnProcessURLFetchResultsComplete( |
| 873 last_chunk_completed_ || code == HTTP_RESUME_INCOMPLETE); | 873 last_chunk_completed_ || code == HTTP_RESUME_INCOMPLETE); |
| 874 } | 874 } |
| 875 | 875 |
| 876 void ResumeUploadOperation::NotifyStartToOperationRegistry() { | 876 void ResumeUploadOperation::NotifyStartToOperationRegistry() { |
| 877 NotifyResume(); | 877 NotifyResume(); |
| 878 } | 878 } |
| 879 | 879 |
| 880 void ResumeUploadOperation::NotifySuccessToOperationRegistry() { | 880 void ResumeUploadOperation::NotifySuccessToOperationRegistry() { |
| 881 if (last_chunk_completed_) | 881 if (last_chunk_completed_) |
| 882 NotifyFinish(GDataOperationRegistry::OPERATION_COMPLETED); | 882 NotifyFinish(OperationRegistry::OPERATION_COMPLETED); |
| 883 else | 883 else |
| 884 NotifySuspend(); | 884 NotifySuspend(); |
| 885 } | 885 } |
| 886 | 886 |
| 887 void ResumeUploadOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { | 887 void ResumeUploadOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { |
| 888 scoped_ptr<DocumentEntry> entry; | 888 scoped_ptr<DocumentEntry> entry; |
| 889 if (!callback_.is_null()) | 889 if (!callback_.is_null()) |
| 890 callback_.Run(ResumeUploadResponse(code, 0, 0), entry.Pass()); | 890 callback_.Run(ResumeUploadResponse(code, 0, 0), entry.Pass()); |
| 891 } | 891 } |
| 892 | 892 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 | 931 |
| 932 void ResumeUploadOperation::OnURLFetchUploadProgress( | 932 void ResumeUploadOperation::OnURLFetchUploadProgress( |
| 933 const URLFetcher* source, int64 current, int64 total) { | 933 const URLFetcher* source, int64 current, int64 total) { |
| 934 // Adjust the progress values according to the range currently uploaded. | 934 // Adjust the progress values according to the range currently uploaded. |
| 935 NotifyProgress(params_.start_range + current, params_.content_length); | 935 NotifyProgress(params_.start_range + current, params_.content_length); |
| 936 } | 936 } |
| 937 | 937 |
| 938 //========================== GetContactGroupsOperation ========================= | 938 //========================== GetContactGroupsOperation ========================= |
| 939 | 939 |
| 940 GetContactGroupsOperation::GetContactGroupsOperation( | 940 GetContactGroupsOperation::GetContactGroupsOperation( |
| 941 GDataOperationRegistry* registry, | 941 OperationRegistry* registry, |
| 942 const GetDataCallback& callback) | 942 const GetDataCallback& callback) |
| 943 : GetDataOperation(registry, callback) { | 943 : GetDataOperation(registry, callback) { |
| 944 } | 944 } |
| 945 | 945 |
| 946 GetContactGroupsOperation::~GetContactGroupsOperation() {} | 946 GetContactGroupsOperation::~GetContactGroupsOperation() {} |
| 947 | 947 |
| 948 GURL GetContactGroupsOperation::GetURL() const { | 948 GURL GetContactGroupsOperation::GetURL() const { |
| 949 return !feed_url_for_testing_.is_empty() ? | 949 return !feed_url_for_testing_.is_empty() ? |
| 950 feed_url_for_testing_ : | 950 feed_url_for_testing_ : |
| 951 GURL(kGetContactGroupsURL); | 951 GURL(kGetContactGroupsURL); |
| 952 } | 952 } |
| 953 | 953 |
| 954 //============================ GetContactsOperation ============================ | 954 //============================ GetContactsOperation ============================ |
| 955 | 955 |
| 956 GetContactsOperation::GetContactsOperation(GDataOperationRegistry* registry, | 956 GetContactsOperation::GetContactsOperation(OperationRegistry* registry, |
| 957 const std::string& group_id, | 957 const std::string& group_id, |
| 958 const base::Time& min_update_time, | 958 const base::Time& min_update_time, |
| 959 const GetDataCallback& callback) | 959 const GetDataCallback& callback) |
| 960 : GetDataOperation(registry, callback), | 960 : GetDataOperation(registry, callback), |
| 961 group_id_(group_id), | 961 group_id_(group_id), |
| 962 min_update_time_(min_update_time) { | 962 min_update_time_(min_update_time) { |
| 963 } | 963 } |
| 964 | 964 |
| 965 GetContactsOperation::~GetContactsOperation() {} | 965 GetContactsOperation::~GetContactsOperation() {} |
| 966 | 966 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 978 std::string time_rfc3339 = util::FormatTimeAsString(min_update_time_); | 978 std::string time_rfc3339 = util::FormatTimeAsString(min_update_time_); |
| 979 url = chrome_common_net::AppendQueryParameter( | 979 url = chrome_common_net::AppendQueryParameter( |
| 980 url, kGetContactsUpdatedMinParam, time_rfc3339); | 980 url, kGetContactsUpdatedMinParam, time_rfc3339); |
| 981 } | 981 } |
| 982 return url; | 982 return url; |
| 983 } | 983 } |
| 984 | 984 |
| 985 //========================== GetContactPhotoOperation ========================== | 985 //========================== GetContactPhotoOperation ========================== |
| 986 | 986 |
| 987 GetContactPhotoOperation::GetContactPhotoOperation( | 987 GetContactPhotoOperation::GetContactPhotoOperation( |
| 988 GDataOperationRegistry* registry, | 988 OperationRegistry* registry, |
| 989 const GURL& photo_url, | 989 const GURL& photo_url, |
| 990 const GetContentCallback& callback) | 990 const GetContentCallback& callback) |
| 991 : UrlFetchOperationBase(registry), | 991 : UrlFetchOperationBase(registry), |
| 992 photo_url_(photo_url), | 992 photo_url_(photo_url), |
| 993 callback_(callback) { | 993 callback_(callback) { |
| 994 } | 994 } |
| 995 | 995 |
| 996 GetContactPhotoOperation::~GetContactPhotoOperation() {} | 996 GetContactPhotoOperation::~GetContactPhotoOperation() {} |
| 997 | 997 |
| 998 GURL GetContactPhotoOperation::GetURL() const { | 998 GURL GetContactPhotoOperation::GetURL() const { |
| 999 return photo_url_; | 999 return photo_url_; |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 void GetContactPhotoOperation::ProcessURLFetchResults( | 1002 void GetContactPhotoOperation::ProcessURLFetchResults( |
| 1003 const net::URLFetcher* source) { | 1003 const net::URLFetcher* source) { |
| 1004 GDataErrorCode code = static_cast<GDataErrorCode>(source->GetResponseCode()); | 1004 GDataErrorCode code = static_cast<GDataErrorCode>(source->GetResponseCode()); |
| 1005 scoped_ptr<std::string> data(new std::string); | 1005 scoped_ptr<std::string> data(new std::string); |
| 1006 source->GetResponseAsString(data.get()); | 1006 source->GetResponseAsString(data.get()); |
| 1007 callback_.Run(code, data.Pass()); | 1007 callback_.Run(code, data.Pass()); |
| 1008 OnProcessURLFetchResultsComplete(code == HTTP_SUCCESS); | 1008 OnProcessURLFetchResultsComplete(code == HTTP_SUCCESS); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 void GetContactPhotoOperation::RunCallbackOnPrematureFailure( | 1011 void GetContactPhotoOperation::RunCallbackOnPrematureFailure( |
| 1012 GDataErrorCode code) { | 1012 GDataErrorCode code) { |
| 1013 scoped_ptr<std::string> data(new std::string); | 1013 scoped_ptr<std::string> data(new std::string); |
| 1014 callback_.Run(code, data.Pass()); | 1014 callback_.Run(code, data.Pass()); |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 } // namespace gdata | 1017 } // namespace gdata |
| OLD | NEW |