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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_operations.h

Issue 10855034: Drive: Remove gdata_params.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review (#16) fix & rebase Created 8 years, 4 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 #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
15 //============================ GetDocumentsOperation =========================== 19 //============================ GetDocumentsOperation ===========================
16 20
17 // This class performs the operation for fetching a document list. 21 // This class performs the operation for fetching a document list.
18 class GetDocumentsOperation : public GetDataOperation { 22 class GetDocumentsOperation : public GetDataOperation {
19 public: 23 public:
20 // |start_changestamp| specifies the starting point of change list or 0 if 24 // |start_changestamp| specifies the starting point of change list or 0 if
21 // all changes are necessary. 25 // all changes are necessary.
22 // |url| specifies URL for documents feed fetching operation. If empty URL is 26 // |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. 27 // 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. 28 // When non-first page result is requested, |url| should be specified.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 protected: 80 protected:
77 // Overridden from GetDataOperation. 81 // Overridden from GetDataOperation.
78 virtual GURL GetURL() const OVERRIDE; 82 virtual GURL GetURL() const OVERRIDE;
79 83
80 private: 84 private:
81 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation); 85 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataOperation);
82 }; 86 };
83 87
84 //============================ DownloadFileOperation =========================== 88 //============================ DownloadFileOperation ===========================
85 89
90 // Callback type for DownloadDocument/DownloadFile DocumentServiceInterface
91 // calls.
92 typedef base::Callback<void(GDataErrorCode error,
93 const GURL& content_url,
94 const FilePath& temp_file)> DownloadActionCallback;
95
86 // 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.
87 class DownloadFileOperation : public UrlFetchOperationBase { 97 class DownloadFileOperation : public UrlFetchOperationBase {
88 public: 98 public:
89 DownloadFileOperation( 99 DownloadFileOperation(
90 GDataOperationRegistry* registry, 100 GDataOperationRegistry* registry,
91 const DownloadActionCallback& download_action_callback, 101 const DownloadActionCallback& download_action_callback,
92 const GetDownloadDataCallback& get_download_data_callback, 102 const GetContentCallback& get_content_callback,
93 const GURL& document_url, 103 const GURL& document_url,
94 const FilePath& virtual_path, 104 const FilePath& virtual_path,
95 const FilePath& output_file_path); 105 const FilePath& output_file_path);
96 virtual ~DownloadFileOperation(); 106 virtual ~DownloadFileOperation();
97 107
98 protected: 108 protected:
99 // Overridden from UrlFetchOperationBase. 109 // Overridden from UrlFetchOperationBase.
100 virtual GURL GetURL() const OVERRIDE; 110 virtual GURL GetURL() const OVERRIDE;
101 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; 111 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
102 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; 112 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
103 113
104 // Overridden from net::URLFetcherDelegate. 114 // Overridden from net::URLFetcherDelegate.
105 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, 115 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source,
106 int64 current, int64 total) OVERRIDE; 116 int64 current, int64 total) OVERRIDE;
107 virtual bool ShouldSendDownloadData() OVERRIDE; 117 virtual bool ShouldSendDownloadData() OVERRIDE;
108 virtual void OnURLFetchDownloadData( 118 virtual void OnURLFetchDownloadData(
109 const net::URLFetcher* source, 119 const net::URLFetcher* source,
110 scoped_ptr<std::string> download_data) OVERRIDE; 120 scoped_ptr<std::string> download_data) OVERRIDE;
111 121
112 private: 122 private:
113 DownloadActionCallback download_action_callback_; 123 DownloadActionCallback download_action_callback_;
114 GetDownloadDataCallback get_download_data_callback_; 124 GetContentCallback get_content_callback_;
115 GURL document_url_; 125 GURL document_url_;
116 126
117 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); 127 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation);
118 }; 128 };
119 129
120 //=========================== DeleteDocumentOperation ========================== 130 //=========================== DeleteDocumentOperation ==========================
121 131
122 // This class performs the operation for deleting a document. 132 // This class performs the operation for deleting a document.
123 class DeleteDocumentOperation : public EntryActionOperation { 133 class DeleteDocumentOperation : public EntryActionOperation {
124 public: 134 public:
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 311
302 private: 312 private:
303 std::string resource_id_; 313 std::string resource_id_;
304 GURL parent_content_url_; 314 GURL parent_content_url_;
305 315
306 DISALLOW_COPY_AND_ASSIGN(RemoveResourceFromDirectoryOperation); 316 DISALLOW_COPY_AND_ASSIGN(RemoveResourceFromDirectoryOperation);
307 }; 317 };
308 318
309 //=========================== InitiateUploadOperation ========================== 319 //=========================== InitiateUploadOperation ==========================
310 320
321 // Struct for passing params needed for DocumentsService::InitiateUpload()
322 // calls.
323 //
324 // When uploading a new file (UPLOAD_NEW_FILE):
325 // - |title| should be set.
326 // - |upload_location| should be the upload_url() of the parent directory.
327 //
328 // When updating an existing file (UPLOAD_EXISTING_FILE):
329 // - |title| should be empty
330 // - |upload_location| should be the upload_url() of the existing file.
331 struct InitiateUploadParams {
332 InitiateUploadParams(UploadMode upload_mode,
333 const std::string& title,
334 const std::string& content_type,
335 int64 content_length,
336 const GURL& upload_location,
337 const FilePath& virtual_path);
338 ~InitiateUploadParams();
339
340 UploadMode upload_mode;
341 std::string title;
342 std::string content_type;
343 int64 content_length;
344 GURL upload_location;
345 const FilePath& virtual_path;
346 };
347
348 // Callback type for DocumentServiceInterface::InitiateUpload.
349 typedef base::Callback<void(GDataErrorCode error,
350 const GURL& upload_url)> InitiateUploadCallback;
351
311 // This class performs the operation for initiating the upload of a file. 352 // This class performs the operation for initiating the upload of a file.
312 class InitiateUploadOperation : public UrlFetchOperationBase { 353 class InitiateUploadOperation : public UrlFetchOperationBase {
313 public: 354 public:
314 InitiateUploadOperation(GDataOperationRegistry* registry, 355 InitiateUploadOperation(GDataOperationRegistry* registry,
315 const InitiateUploadCallback& callback, 356 const InitiateUploadCallback& callback,
316 const InitiateUploadParams& params); 357 const InitiateUploadParams& params);
317 virtual ~InitiateUploadOperation(); 358 virtual ~InitiateUploadOperation();
318 359
319 protected: 360 protected:
320 // Overridden from UrlFetchOperationBase. 361 // Overridden from UrlFetchOperationBase.
(...skipping 11 matching lines...) Expand all
332 private: 373 private:
333 InitiateUploadCallback callback_; 374 InitiateUploadCallback callback_;
334 InitiateUploadParams params_; 375 InitiateUploadParams params_;
335 GURL initiate_upload_url_; 376 GURL initiate_upload_url_;
336 377
337 DISALLOW_COPY_AND_ASSIGN(InitiateUploadOperation); 378 DISALLOW_COPY_AND_ASSIGN(InitiateUploadOperation);
338 }; 379 };
339 380
340 //============================ ResumeUploadOperation =========================== 381 //============================ ResumeUploadOperation ===========================
341 382
383 // Struct for response to ResumeUpload.
384 struct ResumeUploadResponse {
385 ResumeUploadResponse(GDataErrorCode code,
386 int64 start_range_received,
387 int64 end_range_received);
388 ~ResumeUploadResponse();
389
390 GDataErrorCode code;
391 int64 start_range_received;
392 int64 end_range_received;
393 FilePath virtual_path;
394 };
395
396 // Struct for passing params needed for DocumentsService::ResumeUpload() calls.
397 struct ResumeUploadParams {
398 ResumeUploadParams(UploadMode upload_mode,
399 int64 start_range,
400 int64 end_range,
401 int64 content_length,
402 const std::string& content_type,
403 scoped_refptr<net::IOBuffer> buf,
404 const GURL& upload_location,
405 const FilePath& virtual_path);
406 ~ResumeUploadParams();
407
408 UploadMode upload_mode; // Mode of the upload.
409 int64 start_range; // Start of range of contents currently stored in |buf|.
410 int64 end_range; // End of range of contents currently stored in |buf|.
411 int64 content_length; // File content-Length.
412 std::string content_type; // Content-Type of file.
413 scoped_refptr<net::IOBuffer> buf; // Holds current content to be uploaded.
414 GURL upload_location; // Url of where to upload the file to.
415 // Virtual GData path of the file seen in the UI. Not necessary for
416 // resuming an upload, but used for adding an entry to
417 // GDataOperationRegistry.
418 FilePath virtual_path;
419 };
420
421 // Callback type for DocumentServiceInterface::ResumeUpload.
422 typedef base::Callback<void(
423 const ResumeUploadResponse& response,
424 scoped_ptr<gdata::DocumentEntry> new_entry)> ResumeUploadCallback;
425
342 // This class performs the operation for resuming the upload of a file. 426 // This class performs the operation for resuming the upload of a file.
343 class ResumeUploadOperation : public UrlFetchOperationBase { 427 class ResumeUploadOperation : public UrlFetchOperationBase {
344 public: 428 public:
345 ResumeUploadOperation(GDataOperationRegistry* registry, 429 ResumeUploadOperation(GDataOperationRegistry* registry,
346 const ResumeUploadCallback& callback, 430 const ResumeUploadCallback& callback,
347 const ResumeUploadParams& params); 431 const ResumeUploadParams& params);
348 virtual ~ResumeUploadOperation(); 432 virtual ~ResumeUploadOperation();
349 433
350 protected: 434 protected:
351 // Overridden from UrlFetchOperationBase. 435 // Overridden from UrlFetchOperationBase.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 DISALLOW_COPY_AND_ASSIGN(GetContactsOperation); 516 DISALLOW_COPY_AND_ASSIGN(GetContactsOperation);
433 }; 517 };
434 518
435 //========================== GetContactPhotoOperation ========================== 519 //========================== GetContactPhotoOperation ==========================
436 520
437 // This class fetches a contact's photo. 521 // This class fetches a contact's photo.
438 class GetContactPhotoOperation : public UrlFetchOperationBase { 522 class GetContactPhotoOperation : public UrlFetchOperationBase {
439 public: 523 public:
440 GetContactPhotoOperation(GDataOperationRegistry* registry, 524 GetContactPhotoOperation(GDataOperationRegistry* registry,
441 const GURL& photo_url, 525 const GURL& photo_url,
442 const GetDownloadDataCallback& callback); 526 const GetContentCallback& callback);
443 virtual ~GetContactPhotoOperation(); 527 virtual ~GetContactPhotoOperation();
444 528
445 protected: 529 protected:
446 // Overridden from UrlFetchOperationBase. 530 // Overridden from UrlFetchOperationBase.
447 virtual GURL GetURL() const OVERRIDE; 531 virtual GURL GetURL() const OVERRIDE;
448 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; 532 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
449 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; 533 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
450 534
451 private: 535 private:
452 // Location of the photo to fetch. 536 // Location of the photo to fetch.
453 GURL photo_url_; 537 GURL photo_url_;
454 538
455 // Callback to which the photo data is passed. 539 // Callback to which the photo data is passed.
456 GetDownloadDataCallback callback_; 540 GetContentCallback callback_;
457 541
458 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation); 542 DISALLOW_COPY_AND_ASSIGN(GetContactPhotoOperation);
459 }; 543 };
460 544
461 } // namespace gdata 545 } // namespace gdata
462 546
463 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_ 547 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATIONS_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_operation_runner.h ('k') | chrome/browser/chromeos/gdata/gdata_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698