| 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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 virtual GURL GetURL() const OVERRIDE; | 82 virtual GURL GetURL() const OVERRIDE; |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); | 85 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 //============================ DownloadFileOperation =========================== | 88 //============================ DownloadFileOperation =========================== |
| 89 | 89 |
| 90 // Callback type for DownloadDocument/DownloadFile DocumentServiceInterface | 90 // Callback type for DownloadDocument/DownloadFile DocumentServiceInterface |
| 91 // calls. | 91 // calls. |
| 92 typedef base::Callback<void(GDataErrorCode error, | 92 typedef base::Callback<void(DriveErrorCode error, |
| 93 const GURL& content_url, | 93 const GURL& content_url, |
| 94 const FilePath& temp_file)> DownloadActionCallback; | 94 const FilePath& temp_file)> DownloadActionCallback; |
| 95 | 95 |
| 96 // This class performs the operation for downloading of a given document/file. | 96 // This class performs the operation for downloading of a given document/file. |
| 97 class DownloadFileOperation : public UrlFetchOperationBase { | 97 class DownloadFileOperation : public UrlFetchOperationBase { |
| 98 public: | 98 public: |
| 99 DownloadFileOperation( | 99 DownloadFileOperation( |
| 100 OperationRegistry* registry, | 100 OperationRegistry* registry, |
| 101 const DownloadActionCallback& download_action_callback, | 101 const DownloadActionCallback& download_action_callback, |
| 102 const GetContentCallback& get_content_callback, | 102 const GetContentCallback& get_content_callback, |
| 103 const GURL& document_url, | 103 const GURL& document_url, |
| 104 const FilePath& virtual_path, | 104 const FilePath& virtual_path, |
| 105 const FilePath& output_file_path); | 105 const FilePath& output_file_path); |
| 106 virtual ~DownloadFileOperation(); | 106 virtual ~DownloadFileOperation(); |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 // Overridden from UrlFetchOperationBase. | 109 // Overridden from UrlFetchOperationBase. |
| 110 virtual GURL GetURL() const OVERRIDE; | 110 virtual GURL GetURL() const OVERRIDE; |
| 111 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | 111 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
| 112 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; | 112 virtual void RunCallbackOnPrematureFailure(DriveErrorCode code) OVERRIDE; |
| 113 | 113 |
| 114 // Overridden from net::URLFetcherDelegate. | 114 // Overridden from net::URLFetcherDelegate. |
| 115 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, | 115 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, |
| 116 int64 current, int64 total) OVERRIDE; | 116 int64 current, int64 total) OVERRIDE; |
| 117 virtual bool ShouldSendDownloadData() OVERRIDE; | 117 virtual bool ShouldSendDownloadData() OVERRIDE; |
| 118 virtual void OnURLFetchDownloadData( | 118 virtual void OnURLFetchDownloadData( |
| 119 const net::URLFetcher* source, | 119 const net::URLFetcher* source, |
| 120 scoped_ptr<std::string> download_data) OVERRIDE; | 120 scoped_ptr<std::string> download_data) OVERRIDE; |
| 121 | 121 |
| 122 private: | 122 private: |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 virtual bool GetContentData(std::string* upload_content_type, | 250 virtual bool GetContentData(std::string* upload_content_type, |
| 251 std::string* upload_content) OVERRIDE; | 251 std::string* upload_content) OVERRIDE; |
| 252 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 252 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 253 | 253 |
| 254 // Overridden from GetDataOperation. | 254 // Overridden from GetDataOperation. |
| 255 virtual GURL GetURL() const OVERRIDE; | 255 virtual GURL GetURL() const OVERRIDE; |
| 256 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | 256 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
| 257 | 257 |
| 258 // Must override GetDataOperation's ParseResponse because the response is XML | 258 // Must override GetDataOperation's ParseResponse because the response is XML |
| 259 // not JSON. | 259 // not JSON. |
| 260 virtual void ParseResponse(GDataErrorCode fetch_error_code, | 260 virtual void ParseResponse(DriveErrorCode fetch_error_code, |
| 261 const std::string& data) OVERRIDE; | 261 const std::string& data) OVERRIDE; |
| 262 | 262 |
| 263 private: | 263 private: |
| 264 std::string app_id_; | 264 std::string app_id_; |
| 265 GURL document_url_; | 265 GURL document_url_; |
| 266 | 266 |
| 267 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppsOperation); | 267 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppsOperation); |
| 268 }; | 268 }; |
| 269 | 269 |
| 270 //======================= AddResourceToDirectoryOperation ====================== | 270 //======================= AddResourceToDirectoryOperation ====================== |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 341 |
| 342 UploadMode upload_mode; | 342 UploadMode upload_mode; |
| 343 std::string title; | 343 std::string title; |
| 344 std::string content_type; | 344 std::string content_type; |
| 345 int64 content_length; | 345 int64 content_length; |
| 346 GURL upload_location; | 346 GURL upload_location; |
| 347 const FilePath& virtual_path; | 347 const FilePath& virtual_path; |
| 348 }; | 348 }; |
| 349 | 349 |
| 350 // Callback type for DocumentServiceInterface::InitiateUpload. | 350 // Callback type for DocumentServiceInterface::InitiateUpload. |
| 351 typedef base::Callback<void(GDataErrorCode error, | 351 typedef base::Callback<void(DriveErrorCode error, |
| 352 const GURL& upload_url)> InitiateUploadCallback; | 352 const GURL& upload_url)> InitiateUploadCallback; |
| 353 | 353 |
| 354 // This class performs the operation for initiating the upload of a file. | 354 // This class performs the operation for initiating the upload of a file. |
| 355 class InitiateUploadOperation : public UrlFetchOperationBase { | 355 class InitiateUploadOperation : public UrlFetchOperationBase { |
| 356 public: | 356 public: |
| 357 InitiateUploadOperation(OperationRegistry* registry, | 357 InitiateUploadOperation(OperationRegistry* registry, |
| 358 const InitiateUploadCallback& callback, | 358 const InitiateUploadCallback& callback, |
| 359 const InitiateUploadParams& params); | 359 const InitiateUploadParams& params); |
| 360 virtual ~InitiateUploadOperation(); | 360 virtual ~InitiateUploadOperation(); |
| 361 | 361 |
| 362 protected: | 362 protected: |
| 363 // Overridden from UrlFetchOperationBase. | 363 // Overridden from UrlFetchOperationBase. |
| 364 virtual GURL GetURL() const OVERRIDE; | 364 virtual GURL GetURL() const OVERRIDE; |
| 365 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | 365 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
| 366 virtual void NotifySuccessToOperationRegistry() OVERRIDE; | 366 virtual void NotifySuccessToOperationRegistry() OVERRIDE; |
| 367 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; | 367 virtual void RunCallbackOnPrematureFailure(DriveErrorCode code) OVERRIDE; |
| 368 | 368 |
| 369 // Overridden from UrlFetchOperationBase. | 369 // Overridden from UrlFetchOperationBase. |
| 370 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 370 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 371 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 371 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 372 virtual bool GetContentData(std::string* upload_content_type, | 372 virtual bool GetContentData(std::string* upload_content_type, |
| 373 std::string* upload_content) OVERRIDE; | 373 std::string* upload_content) OVERRIDE; |
| 374 | 374 |
| 375 private: | 375 private: |
| 376 InitiateUploadCallback callback_; | 376 InitiateUploadCallback callback_; |
| 377 InitiateUploadParams params_; | 377 InitiateUploadParams params_; |
| 378 GURL initiate_upload_url_; | 378 GURL initiate_upload_url_; |
| 379 | 379 |
| 380 DISALLOW_COPY_AND_ASSIGN(InitiateUploadOperation); | 380 DISALLOW_COPY_AND_ASSIGN(InitiateUploadOperation); |
| 381 }; | 381 }; |
| 382 | 382 |
| 383 //============================ ResumeUploadOperation =========================== | 383 //============================ ResumeUploadOperation =========================== |
| 384 | 384 |
| 385 // Struct for response to ResumeUpload. | 385 // Struct for response to ResumeUpload. |
| 386 struct ResumeUploadResponse { | 386 struct ResumeUploadResponse { |
| 387 ResumeUploadResponse(GDataErrorCode code, | 387 ResumeUploadResponse(DriveErrorCode code, |
| 388 int64 start_range_received, | 388 int64 start_range_received, |
| 389 int64 end_range_received); | 389 int64 end_range_received); |
| 390 ~ResumeUploadResponse(); | 390 ~ResumeUploadResponse(); |
| 391 | 391 |
| 392 GDataErrorCode code; | 392 DriveErrorCode code; |
| 393 int64 start_range_received; | 393 int64 start_range_received; |
| 394 int64 end_range_received; | 394 int64 end_range_received; |
| 395 FilePath virtual_path; | 395 FilePath virtual_path; |
| 396 }; | 396 }; |
| 397 | 397 |
| 398 // Struct for passing params needed for DriveServiceInterface::ResumeUpload() | 398 // Struct for passing params needed for DriveServiceInterface::ResumeUpload() |
| 399 // calls. | 399 // calls. |
| 400 struct ResumeUploadParams { | 400 struct ResumeUploadParams { |
| 401 ResumeUploadParams(UploadMode upload_mode, | 401 ResumeUploadParams(UploadMode upload_mode, |
| 402 int64 start_range, | 402 int64 start_range, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 432 const ResumeUploadCallback& callback, | 432 const ResumeUploadCallback& callback, |
| 433 const ResumeUploadParams& params); | 433 const ResumeUploadParams& params); |
| 434 virtual ~ResumeUploadOperation(); | 434 virtual ~ResumeUploadOperation(); |
| 435 | 435 |
| 436 protected: | 436 protected: |
| 437 // Overridden from UrlFetchOperationBase. | 437 // Overridden from UrlFetchOperationBase. |
| 438 virtual GURL GetURL() const OVERRIDE; | 438 virtual GURL GetURL() const OVERRIDE; |
| 439 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | 439 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
| 440 virtual void NotifyStartToOperationRegistry() OVERRIDE; | 440 virtual void NotifyStartToOperationRegistry() OVERRIDE; |
| 441 virtual void NotifySuccessToOperationRegistry() OVERRIDE; | 441 virtual void NotifySuccessToOperationRegistry() OVERRIDE; |
| 442 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; | 442 virtual void RunCallbackOnPrematureFailure(DriveErrorCode code) OVERRIDE; |
| 443 | 443 |
| 444 // Overridden from UrlFetchOperationBase. | 444 // Overridden from UrlFetchOperationBase. |
| 445 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 445 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 446 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 446 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 447 virtual bool GetContentData(std::string* upload_content_type, | 447 virtual bool GetContentData(std::string* upload_content_type, |
| 448 std::string* upload_content) OVERRIDE; | 448 std::string* upload_content) OVERRIDE; |
| 449 | 449 |
| 450 // Overridden from content::UrlFetcherDelegate | 450 // Overridden from content::UrlFetcherDelegate |
| 451 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, | 451 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, |
| 452 int64 current, int64 total) OVERRIDE; | 452 int64 current, int64 total) OVERRIDE; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 public: | 525 public: |
| 526 GetContactPhotoOperation(OperationRegistry* registry, | 526 GetContactPhotoOperation(OperationRegistry* registry, |
| 527 const GURL& photo_url, | 527 const GURL& photo_url, |
| 528 const GetContentCallback& callback); | 528 const GetContentCallback& callback); |
| 529 virtual ~GetContactPhotoOperation(); | 529 virtual ~GetContactPhotoOperation(); |
| 530 | 530 |
| 531 protected: | 531 protected: |
| 532 // Overridden from UrlFetchOperationBase. | 532 // Overridden from UrlFetchOperationBase. |
| 533 virtual GURL GetURL() const OVERRIDE; | 533 virtual GURL GetURL() const OVERRIDE; |
| 534 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; | 534 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
| 535 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; | 535 virtual void RunCallbackOnPrematureFailure(DriveErrorCode code) OVERRIDE; |
| 536 | 536 |
| 537 private: | 537 private: |
| 538 // Location of the photo to fetch. | 538 // Location of the photo to fetch. |
| 539 GURL photo_url_; | 539 GURL photo_url_; |
| 540 | 540 |
| 541 // Callback to which the photo data is passed. | 541 // Callback to which the photo data is passed. |
| 542 GetContentCallback callback_; | 542 GetContentCallback callback_; |
| 543 | 543 |
| 544 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); | 544 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); |
| 545 }; | 545 }; |
| 546 | 546 |
| 547 } // namespace gdata | 547 } // namespace gdata |
| 548 | 548 |
| 549 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ | 549 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ |
| OLD | NEW |