From 2535809b821e0afa88dcbe541dffb30a64a2b8e6 Mon Sep 17 00:00:00 2001 From: "hidehiko@chromium.org" Date: Wed, 3 Apr 2013 22:49:54 +0000 Subject: Move the implementation of callback OnProgressWithRemainingTime to BurnManager. Now, BurnController::OnProgressWithRemainingTime is just a proxy. BUG=126979 TEST=Burned the image on device. Review URL: https://chromiumcodereview.appspot.com/13450002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192177 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/chromeos/imageburner/burn_controller.cc | 11 ++++------- chrome/browser/chromeos/imageburner/burn_controller.h | 8 +------- chrome/browser/chromeos/imageburner/burn_manager.cc | 12 ++++++++---- chrome/browser/chromeos/imageburner/burn_manager.h | 11 ++++++++++- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/chrome/browser/chromeos/imageburner/burn_controller.cc b/chrome/browser/chromeos/imageburner/burn_controller.cc index f3eeb99..7b30a7e 100644 --- a/chrome/browser/chromeos/imageburner/burn_controller.cc +++ b/chrome/browser/chromeos/imageburner/burn_controller.cc @@ -59,16 +59,13 @@ class BurnControllerImpl } // BurnManager::Observer override. - virtual void OnImageFileFetchDownloadProgressUpdated( + virtual void OnProgressWithRemainingTime( + ProgressType progress_type, int64 received_bytes, int64 total_bytes, const base::TimeDelta& estimated_remaining_time) OVERRIDE { - if (state_machine_->state() == StateMachine::DOWNLOADING) { - delegate_->OnProgressWithRemainingTime(DOWNLOADING, - received_bytes, - total_bytes, - estimated_remaining_time); - } + delegate_->OnProgressWithRemainingTime( + progress_type, received_bytes, total_bytes, estimated_remaining_time); } // BurnManager::Observer override. diff --git a/chrome/browser/chromeos/imageburner/burn_controller.h b/chrome/browser/chromeos/imageburner/burn_controller.h index a0e62c9..abf1feb 100644 --- a/chrome/browser/chromeos/imageburner/burn_controller.h +++ b/chrome/browser/chromeos/imageburner/burn_controller.h @@ -8,6 +8,7 @@ #include #include "base/basictypes.h" +#include "chrome/browser/chromeos/imageburner/burn_manager.h" #include "chromeos/disks/disk_mount_manager.h" namespace base { @@ -22,13 +23,6 @@ class WebContents; namespace chromeos { namespace imageburner { -// An enum used to describe what type of progress is being made. -enum ProgressType { - DOWNLOADING, - UNZIPPING, - BURNING -}; - // A class to control recovery media creating process. class BurnController { public: diff --git a/chrome/browser/chromeos/imageburner/burn_manager.cc b/chrome/browser/chromeos/imageburner/burn_manager.cc index 3700584..a917af3 100644 --- a/chrome/browser/chromeos/imageburner/burn_manager.cc +++ b/chrome/browser/chromeos/imageburner/burn_manager.cc @@ -479,10 +479,14 @@ void BurnManager::OnURLFetchDownloadProgress(const net::URLFetcher* source, base::TimeTicks::Now() - tick_image_download_start_; estimated_remaining_time = elapsed_time * (total - current) / current; } - FOR_EACH_OBSERVER( - Observer, observers_, - OnImageFileFetchDownloadProgressUpdated( - current, total, estimated_remaining_time)); + + // TODO(hidehiko): We should be able to clean the state check here. + if (state_machine_->state() == StateMachine::DOWNLOADING) { + FOR_EACH_OBSERVER( + Observer, observers_, + OnProgressWithRemainingTime( + DOWNLOADING, current, total, estimated_remaining_time)); + } } } } diff --git a/chrome/browser/chromeos/imageburner/burn_manager.h b/chrome/browser/chromeos/imageburner/burn_manager.h index 8826f85..8014df3 100644 --- a/chrome/browser/chromeos/imageburner/burn_manager.h +++ b/chrome/browser/chromeos/imageburner/burn_manager.h @@ -52,6 +52,14 @@ struct ImageBurnStatus { namespace imageburner { +// An enum used to describe what type of progress is being made. +// TODO(hidehiko): This should be merged into the StateMachine's state. +enum ProgressType { + DOWNLOADING, + UNZIPPING, + BURNING +}; + // Config file properties. extern const char kName[]; extern const char kHwid[]; @@ -220,7 +228,8 @@ class BurnManager : public net::URLFetcherDelegate, // Triggered during the image file downloading periodically. // |estimated_remaining_time| is the remaining duration to download the // remaining content estimated based on the elapsed time. - virtual void OnImageFileFetchDownloadProgressUpdated( + virtual void OnProgressWithRemainingTime( + ProgressType progress_type, int64 received_bytes, int64 total_bytes, const base::TimeDelta& estimated_remaining_time) = 0; -- cgit v1.1