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

Side by Side Diff: chrome/browser/google_apis/base_operations.h

Issue 14215003: Add ProgressCallback to DriveServiceInterface::DownloadFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 8 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 // This file provides base classes used to implement operations for Google APIs. 5 // This file provides base classes used to implement operations for Google APIs.
6 6
7 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ 7 #ifndef CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_
8 #define CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ 8 #define CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 16 matching lines...) Expand all
27 class IOBuffer; 27 class IOBuffer;
28 class URLRequestContextGetter; 28 class URLRequestContextGetter;
29 } // namespace net 29 } // namespace net
30 30
31 namespace google_apis { 31 namespace google_apis {
32 32
33 // Callback used to pass parsed JSON from ParseJson(). If parsing error occurs, 33 // Callback used to pass parsed JSON from ParseJson(). If parsing error occurs,
34 // then the passed argument is null. 34 // then the passed argument is null.
35 typedef base::Callback<void(scoped_ptr<base::Value> value)> ParseJsonCallback; 35 typedef base::Callback<void(scoped_ptr<base::Value> value)> ParseJsonCallback;
36 36
37 // Callback used for DownloadOperation and ResumeUploadOperation.
38 typedef base::Callback<void(int64 progress, int64 total)> ProgressCallback;
39
37 // Parses JSON passed in |json| on blocking pool. Runs |callback| on the calling 40 // Parses JSON passed in |json| on blocking pool. Runs |callback| on the calling
38 // thread when finished with either success or failure. 41 // thread when finished with either success or failure.
39 // The callback must not be null. 42 // The callback must not be null.
40 void ParseJson(const std::string& json, const ParseJsonCallback& callback); 43 void ParseJson(const std::string& json, const ParseJsonCallback& callback);
41 44
42 //======================= AuthenticatedOperationInterface ====================== 45 //======================= AuthenticatedOperationInterface ======================
43 46
44 // An interface class for implementing an operation which requires OAuth2 47 // An interface class for implementing an operation which requires OAuth2
45 // authentication. 48 // authentication.
46 class AuthenticatedOperationInterface { 49 class AuthenticatedOperationInterface {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 // This class performs the operation for downloading of a given document/file. 454 // This class performs the operation for downloading of a given document/file.
452 class DownloadFileOperation : public UrlFetchOperationBase { 455 class DownloadFileOperation : public UrlFetchOperationBase {
453 public: 456 public:
454 // download_action_callback: 457 // download_action_callback:
455 // This callback is called when the download is complete. Must not be null. 458 // This callback is called when the download is complete. Must not be null.
456 // 459 //
457 // get_content_callback: 460 // get_content_callback:
458 // This callback is called when some part of the content is 461 // This callback is called when some part of the content is
459 // read. Used to read the download content progressively. May be null. 462 // read. Used to read the download content progressively. May be null.
460 // 463 //
464 // progress_callback:
465 // This callback is called for periodically reporting the number of bytes
466 // downloaded so far. May be null.
467 //
461 // download_url: 468 // download_url:
462 // Specifies the target file to download. 469 // Specifies the target file to download.
463 // 470 //
464 // drive_file_path: 471 // drive_file_path:
465 // Specifies the drive path of the target file. Shown in UI. 472 // Specifies the drive path of the target file. Shown in UI.
466 // TODO(satorux): Remove the drive file path hack. crbug.com/163296 473 // TODO(satorux): Remove the drive file path hack. crbug.com/163296
467 // 474 //
468 // output_file_path: 475 // output_file_path:
469 // Specifies the file path to save the downloaded file. 476 // Specifies the file path to save the downloaded file.
470 // 477 //
471 DownloadFileOperation( 478 DownloadFileOperation(
472 OperationRegistry* registry, 479 OperationRegistry* registry,
473 net::URLRequestContextGetter* url_request_context_getter, 480 net::URLRequestContextGetter* url_request_context_getter,
474 const DownloadActionCallback& download_action_callback, 481 const DownloadActionCallback& download_action_callback,
475 const GetContentCallback& get_content_callback, 482 const GetContentCallback& get_content_callback,
483 const ProgressCallback& progress_callback,
476 const GURL& download_url, 484 const GURL& download_url,
477 const base::FilePath& drive_file_path, 485 const base::FilePath& drive_file_path,
478 const base::FilePath& output_file_path); 486 const base::FilePath& output_file_path);
479 virtual ~DownloadFileOperation(); 487 virtual ~DownloadFileOperation();
480 488
481 protected: 489 protected:
482 // UrlFetchOperationBase overrides. 490 // UrlFetchOperationBase overrides.
483 virtual GURL GetURL() const OVERRIDE; 491 virtual GURL GetURL() const OVERRIDE;
484 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; 492 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE;
485 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; 493 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE;
486 494
487 // net::URLFetcherDelegate overrides. 495 // net::URLFetcherDelegate overrides.
488 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, 496 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source,
489 int64 current, int64 total) OVERRIDE; 497 int64 current, int64 total) OVERRIDE;
490 virtual bool ShouldSendDownloadData() OVERRIDE; 498 virtual bool ShouldSendDownloadData() OVERRIDE;
491 virtual void OnURLFetchDownloadData( 499 virtual void OnURLFetchDownloadData(
492 const net::URLFetcher* source, 500 const net::URLFetcher* source,
493 scoped_ptr<std::string> download_data) OVERRIDE; 501 scoped_ptr<std::string> download_data) OVERRIDE;
494 502
495 private: 503 private:
496 const DownloadActionCallback download_action_callback_; 504 const DownloadActionCallback download_action_callback_;
497 const GetContentCallback get_content_callback_; 505 const GetContentCallback get_content_callback_;
506 const ProgressCallback progress_callback_;
498 const GURL download_url_; 507 const GURL download_url_;
499 508
500 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation); 509 DISALLOW_COPY_AND_ASSIGN(DownloadFileOperation);
501 }; 510 };
502 511
503 } // namespace google_apis 512 } // namespace google_apis
504 513
505 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_ 514 #endif // CHROME_BROWSER_GOOGLE_APIS_BASE_OPERATIONS_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_scheduler.cc ('k') | chrome/browser/google_apis/base_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698