Chromium Code Reviews| 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 |
| 11 #include "chrome/browser/chromeos/gdata/operations_base.h" | 11 #include "chrome/browser/chromeos/gdata/operations_base.h" |
| 12 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" | |
| 12 | 13 |
| 13 namespace gdata { | 14 namespace gdata { |
| 14 | 15 |
| 16 class GDataEntry; | |
| 17 class DocumentEntry; | |
| 18 | |
| 19 //================================== Callbacks ================================= | |
| 20 | |
| 21 // Callback type for getting download data from DownloadFile | |
| 22 // DocumentServiceInterface calls. | |
|
satorux1
2012/08/09 22:13:09
The function comment seems to be out of sync. What
yoshiki
2012/08/10 02:11:45
Done.
| |
| 23 typedef base::Callback<void( | |
| 24 GDataErrorCode error, | |
| 25 scoped_ptr<std::string> download_data)> GetDownloadDataCallback; | |
|
satorux1
2012/08/09 22:13:09
renamed this to GetContentCallback?
I think we c
yoshiki
2012/08/10 02:11:45
Done.
| |
| 26 | |
| 15 //============================ GetDocumentsOperation =========================== | 27 //============================ GetDocumentsOperation =========================== |
| 16 | 28 |
| 17 // This class performs the operation for fetching a document list. | 29 // This class performs the operation for fetching a document list. |
| 18 class GetDocumentsOperation : public GetDataOperation { | 30 class GetDocumentsOperation : public GetDataOperation { |
| 19 public: | 31 public: |
| 20 // |start_changestamp| specifies the starting point of change list or 0 if | 32 // |start_changestamp| specifies the starting point of change list or 0 if |
| 21 // all changes are necessary. | 33 // all changes are necessary. |
| 22 // |url| specifies URL for documents feed fetching operation. If empty URL is | 34 // |url| specifies URL for documents feed fetching operation. If empty URL is |
| 23 // passed, the default URL is used and returns the first page of the result. | 35 // passed, the default URL is used and returns the first page of the result. |
| 24 // When non-first page result is requested, |url| should be specified. | 36 // When non-first page result is requested, |url| should be specified. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 protected: | 88 protected: |
| 77 // Overridden from GetDataOperation. | 89 // Overridden from GetDataOperation. |
| 78 virtual GURL GetURL() const OVERRIDE; | 90 virtual GURL GetURL() const OVERRIDE; |
| 79 | 91 |
| 80 private: | 92 private: |
| 81 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); | 93 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); |
| 82 }; | 94 }; |
| 83 | 95 |
| 84 //============================ DownloadFileOperation =========================== | 96 //============================ DownloadFileOperation =========================== |
| 85 | 97 |
| 98 // Callback type for DownloadDocument/DownloadFile DocumentServiceInterface | |
| 99 // calls. | |
| 100 typedef base::Callback<void(GDataErrorCode error, | |
| 101 const GURL& content_url, | |
| 102 const FilePath& temp_file)> DownloadActionCallback; | |
| 103 | |
| 86 // This class performs the operation for downloading of a given document/file. | 104 // This class performs the operation for downloading of a given document/file. |
| 87 class DownloadFileOperation : public UrlFetchOperationBase { | 105 class DownloadFileOperation : public UrlFetchOperationBase { |
| 88 public: | 106 public: |
| 89 DownloadFileOperation( | 107 DownloadFileOperation( |
| 90 GDataOperationRegistry* registry, | 108 GDataOperationRegistry* registry, |
| 91 const DownloadActionCallback& download_action_callback, | 109 const DownloadActionCallback& download_action_callback, |
| 92 const GetDownloadDataCallback& get_download_data_callback, | 110 const GetDownloadDataCallback& get_download_data_callback, |
| 93 const GURL& document_url, | 111 const GURL& document_url, |
| 94 const FilePath& virtual_path, | 112 const FilePath& virtual_path, |
| 95 const FilePath& output_file_path); | 113 const FilePath& output_file_path); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 | 319 |
| 302 private: | 320 private: |
| 303 std::string resource_id_; | 321 std::string resource_id_; |
| 304 GURL parent_content_url_; | 322 GURL parent_content_url_; |
| 305 | 323 |
| 306 DISALLOW_COPY_AND_ASSIGN(RemoveResourceFromDirectoryOperation); | 324 DISALLOW_COPY_AND_ASSIGN(RemoveResourceFromDirectoryOperation); |
| 307 }; | 325 }; |
| 308 | 326 |
| 309 //=========================== InitiateUploadOperation ========================== | 327 //=========================== InitiateUploadOperation ========================== |
| 310 | 328 |
| 329 // Struct for passing params needed for DocumentsService::InitiateUpload() | |
| 330 // calls. | |
| 331 // | |
| 332 // When uploading a new file (UPLOAD_NEW_FILE): | |
| 333 // - |title| should be set. | |
| 334 // - |upload_location| should be the upload_url() of the parent directory. | |
| 335 // | |
| 336 // When updating an existing file (UPLOAD_EXISTING_FILE): | |
| 337 // - |title| should be empty | |
| 338 // - |upload_location| should be the upload_url() of the existing file. | |
| 339 struct InitiateUploadParams { | |
| 340 InitiateUploadParams(UploadMode upload_mode, | |
| 341 const std::string& title, | |
| 342 const std::string& content_type, | |
| 343 int64 content_length, | |
| 344 const GURL& upload_location, | |
| 345 const FilePath& virtual_path); | |
| 346 ~InitiateUploadParams(); | |
| 347 | |
| 348 UploadMode upload_mode; | |
| 349 std::string title; | |
| 350 std::string content_type; | |
| 351 int64 content_length; | |
| 352 GURL upload_location; | |
| 353 const FilePath& virtual_path; | |
| 354 }; | |
| 355 | |
| 356 // Callback type for DocumentServiceInterface::InitiateUpload. | |
| 357 typedef base::Callback<void(GDataErrorCode error, | |
| 358 const GURL& upload_url)> InitiateUploadCallback; | |
| 359 | |
| 311 // This class performs the operation for initiating the upload of a file. | 360 // This class performs the operation for initiating the upload of a file. |
| 312 class InitiateUploadOperation : public UrlFetchOperationBase { | 361 class InitiateUploadOperation : public UrlFetchOperationBase { |
| 313 public: | 362 public: |
| 314 InitiateUploadOperation(GDataOperationRegistry* registry, | 363 InitiateUploadOperation(GDataOperationRegistry* registry, |
| 315 const InitiateUploadCallback& callback, | 364 const InitiateUploadCallback& callback, |
| 316 const InitiateUploadParams& params); | 365 const InitiateUploadParams& params); |
| 317 virtual ~InitiateUploadOperation(); | 366 virtual ~InitiateUploadOperation(); |
| 318 | 367 |
| 319 protected: | 368 protected: |
| 320 // Overridden from UrlFetchOperationBase. | 369 // Overridden from UrlFetchOperationBase. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 332 private: | 381 private: |
| 333 InitiateUploadCallback callback_; | 382 InitiateUploadCallback callback_; |
| 334 InitiateUploadParams params_; | 383 InitiateUploadParams params_; |
| 335 GURL initiate_upload_url_; | 384 GURL initiate_upload_url_; |
| 336 | 385 |
| 337 DISALLOW_COPY_AND_ASSIGN(InitiateUploadOperation); | 386 DISALLOW_COPY_AND_ASSIGN(InitiateUploadOperation); |
| 338 }; | 387 }; |
| 339 | 388 |
| 340 //============================ ResumeUploadOperation =========================== | 389 //============================ ResumeUploadOperation =========================== |
| 341 | 390 |
| 391 // Struct for response to ResumeUpload. | |
| 392 struct ResumeUploadResponse { | |
| 393 ResumeUploadResponse(GDataErrorCode code, | |
| 394 int64 start_range_received, | |
| 395 int64 end_range_received); | |
| 396 ~ResumeUploadResponse(); | |
| 397 | |
| 398 GDataErrorCode code; | |
| 399 int64 start_range_received; | |
| 400 int64 end_range_received; | |
| 401 FilePath virtual_path; | |
| 402 }; | |
| 403 | |
| 404 // Struct for passing params needed for DocumentsService::ResumeUpload() calls. | |
| 405 struct ResumeUploadParams { | |
| 406 ResumeUploadParams(UploadMode upload_mode, | |
| 407 int64 start_range, | |
| 408 int64 end_range, | |
| 409 int64 content_length, | |
| 410 const std::string& content_type, | |
| 411 scoped_refptr<net::IOBuffer> buf, | |
| 412 const GURL& upload_location, | |
| 413 const FilePath& virtual_path); | |
| 414 ~ResumeUploadParams(); | |
| 415 | |
| 416 UploadMode upload_mode; // Mode of the upload. | |
| 417 int64 start_range; // Start of range of contents currently stored in |buf|. | |
| 418 int64 end_range; // End of range of contents currently stored in |buf|. | |
| 419 int64 content_length; // File content-Length. | |
| 420 std::string content_type; // Content-Type of file. | |
| 421 scoped_refptr<net::IOBuffer> buf; // Holds current content to be uploaded. | |
| 422 GURL upload_location; // Url of where to upload the file to. | |
| 423 // Virtual GData path of the file seen in the UI. Not necessary for | |
| 424 // resuming an upload, but used for adding an entry to | |
| 425 // GDataOperationRegistry. | |
| 426 FilePath virtual_path; | |
| 427 }; | |
| 428 | |
| 429 // Callback type for DocumentServiceInterface::ResumeUpload. | |
| 430 typedef base::Callback<void( | |
| 431 const ResumeUploadResponse& response, | |
| 432 scoped_ptr<gdata::DocumentEntry> new_entry)> ResumeUploadCallback; | |
| 433 | |
| 342 // This class performs the operation for resuming the upload of a file. | 434 // This class performs the operation for resuming the upload of a file. |
| 343 class ResumeUploadOperation : public UrlFetchOperationBase { | 435 class ResumeUploadOperation : public UrlFetchOperationBase { |
| 344 public: | 436 public: |
| 345 ResumeUploadOperation(GDataOperationRegistry* registry, | 437 ResumeUploadOperation(GDataOperationRegistry* registry, |
| 346 const ResumeUploadCallback& callback, | 438 const ResumeUploadCallback& callback, |
| 347 const ResumeUploadParams& params); | 439 const ResumeUploadParams& params); |
| 348 virtual ~ResumeUploadOperation(); | 440 virtual ~ResumeUploadOperation(); |
| 349 | 441 |
| 350 protected: | 442 protected: |
| 351 // Overridden from UrlFetchOperationBase. | 443 // Overridden from UrlFetchOperationBase. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 | 546 |
| 455 // Callback to which the photo data is passed. | 547 // Callback to which the photo data is passed. |
| 456 GetDownloadDataCallback callback_; | 548 GetDownloadDataCallback callback_; |
| 457 | 549 |
| 458 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); | 550 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); |
| 459 }; | 551 }; |
| 460 | 552 |
| 461 } // namespace gdata | 553 } // namespace gdata |
| 462 | 554 |
| 463 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ | 555 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ |
| OLD | NEW |