summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 05:00:28 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 05:00:28 +0000
commit03f4e0245d53ff6cdec36ff2de3b3cdb650ae187 (patch)
tree66d1de56f0bd2c6eea8ff64eb57e52327f7576f1
parent8c34c7968e3b24495a0b8598a3496c001ad5b69d (diff)
downloadchromium_src-03f4e0245d53ff6cdec36ff2de3b3cdb650ae187.zip
chromium_src-03f4e0245d53ff6cdec36ff2de3b3cdb650ae187.tar.gz
chromium_src-03f4e0245d53ff6cdec36ff2de3b3cdb650ae187.tar.bz2
chromeos: Use URLFetcher to download recovery image
Replace Downloader with URLFetcher. BUG=113469 TEST=chromeos://imageburner works Review URL: http://codereview.chromium.org/9731011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127642 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/imageburner/burn_controller.cc129
-rw-r--r--chrome/browser/chromeos/imageburner/burn_manager.cc158
-rw-r--r--chrome/browser/chromeos/imageburner/burn_manager.h93
-rw-r--r--chrome/browser/chromeos/imageburner/burn_manager_unittest.cc17
4 files changed, 119 insertions, 278 deletions
diff --git a/chrome/browser/chromeos/imageburner/burn_controller.cc b/chrome/browser/chromeos/imageburner/burn_controller.cc
index ed01efc..fffc9d0 100644
--- a/chrome/browser/chromeos/imageburner/burn_controller.cc
+++ b/chrome/browser/chromeos/imageburner/burn_controller.cc
@@ -12,10 +12,6 @@
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/imageburner/burn_manager.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
-#include "content/public/browser/browser_context.h"
-#include "content/public/browser/download_item.h"
-#include "content/public/browser/download_manager.h"
-#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "googleurl/src/gurl.h"
@@ -44,18 +40,12 @@ class BurnControllerImpl
public disks::DiskMountManager::Observer,
public BurnLibrary::Observer,
public NetworkLibrary::NetworkManagerObserver,
- public content::DownloadItem::Observer,
- public content::DownloadManager::Observer,
- public Downloader::Listener,
public StateMachine::Observer,
- public BurnManager::Delegate {
+ public BurnManager::Delegate,
+ public BurnManager::Observer {
public:
- explicit BurnControllerImpl(content::WebContents* contents,
- BurnController::Delegate* delegate)
- : web_contents_(contents),
- download_manager_(NULL),
- active_download_item_(NULL),
- burn_manager_(NULL),
+ explicit BurnControllerImpl(BurnController::Delegate* delegate)
+ : burn_manager_(NULL),
state_machine_(NULL),
observing_burn_lib_(false),
working_(false),
@@ -63,17 +53,18 @@ class BurnControllerImpl
disks::DiskMountManager::GetInstance()->AddObserver(this);
CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this);
burn_manager_ = BurnManager::GetInstance();
+ burn_manager_->AddObserver(this);
state_machine_ = burn_manager_->state_machine();
state_machine_->AddObserver(this);
}
virtual ~BurnControllerImpl() {
- disks::DiskMountManager::GetInstance()->RemoveObserver(this);
CrosLibrary::Get()->GetBurnLibrary()->RemoveObserver(this);
- CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this);
- CleanupDownloadObjects();
if (state_machine_)
state_machine_->RemoveObserver(this);
+ burn_manager_->RemoveObserver(this);
+ CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this);
+ disks::DiskMountManager::GetInstance()->RemoveObserver(this);
}
// disks::DiskMountManager::Observer interface.
@@ -141,54 +132,27 @@ class BurnControllerImpl
ProcessError(IDS_IMAGEBURN_NETWORK_ERROR);
}
- // content::DownloadItem::Observer interface.
- virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE {
- if (download->IsCancelled()) {
- DownloadCompleted(false);
- DCHECK(!active_download_item_);
- } else if (download->IsComplete()) {
- DownloadCompleted(true);
- DCHECK(!active_download_item_);
- } else if (download->IsPartialDownload() &&
- state_machine_->state() == StateMachine::DOWNLOADING) {
- base::TimeDelta remaining_time;
- download->TimeRemaining(&remaining_time);
- delegate_->OnProgressWithRemainingTime(
- DOWNLOADING, download->GetReceivedBytes(), download->GetTotalBytes(),
- remaining_time);
+ // BurnManager::Observer override.
+ virtual void OnDownloadUpdated(
+ int64 received_bytes,
+ int64 total_bytes,
+ const base::TimeDelta& time_remaining) OVERRIDE {
+ if (state_machine_->state() == StateMachine::DOWNLOADING) {
+ delegate_->OnProgressWithRemainingTime(DOWNLOADING,
+ received_bytes,
+ total_bytes,
+ time_remaining);
}
}
- virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE {
- if (download->GetSafetyState() == content::DownloadItem::DANGEROUS)
- download->DangerousDownloadValidated();
+ // BurnManager::Observer override.
+ virtual void OnDownloadCancelled() OVERRIDE {
+ DownloadCompleted(false);
}
- // content::DownloadManager::Observer interface.
- virtual void ModelChanged(content::DownloadManager* manager) OVERRIDE {
- DCHECK_EQ(download_manager_, manager);
- // Find our item and observe it.
- std::vector<content::DownloadItem*> downloads;
- download_manager_->GetTemporaryDownloads(
- burn_manager_->GetImageDir(), &downloads);
- if (active_download_item_)
- return;
- for (std::vector<content::DownloadItem*>::const_iterator it =
- downloads.begin(); it != downloads.end(); ++it) {
- if ((*it)->GetOriginalUrl() == image_download_url_) {
- (*it)->AddObserver(this);
- active_download_item_ = *it;
- break;
- }
- }
- }
-
- // Downloader::Listener interface.
- virtual void OnBurnDownloadStarted(bool success) OVERRIDE {
- if (success)
- state_machine_->OnDownloadStarted();
- else
- DownloadCompleted(false);
+ // BurnManager::Observer override.
+ virtual void OnDownloadCompleted() OVERRIDE {
+ DownloadCompleted(true);
}
// StateMachine::Observer interface.
@@ -230,19 +194,9 @@ class BurnControllerImpl
return;
}
- if (!download_manager_) {
- download_manager_ =
- web_contents_->GetBrowserContext()->GetDownloadManager();
- download_manager_->AddObserver(this);
- }
if (!state_machine_->download_started()) {
- burn_manager_->downloader()->AddListener(this, image_download_url_);
- if (!state_machine_->image_download_requested()) {
- state_machine_->OnImageDownloadRequested();
- burn_manager_->downloader()->DownloadFile(image_download_url_,
- zip_image_file_path_,
- web_contents_);
- }
+ burn_manager_->FetchImage(image_download_url_, zip_image_file_path_);
+ state_machine_->OnDownloadStarted();
}
}
@@ -313,7 +267,6 @@ class BurnControllerImpl
private:
void DownloadCompleted(bool success) {
- CleanupDownloadObjects();
if (success) {
state_machine_->OnDownloadFinished();
BurnImage();
@@ -368,19 +321,7 @@ class BurnControllerImpl
// Do cleanup.
if (state == StateMachine::DOWNLOADING) {
- if (active_download_item_) {
- // This will trigger Download canceled event. As a response to that
- // event, handlers will remove themselves as observers from download
- // manager and item.
- // We don't want to process Download Cancelled signal.
- active_download_item_->RemoveObserver(this);
- if (active_download_item_->IsPartialDownload())
- active_download_item_->Cancel(true);
- active_download_item_->Delete(
- content::DownloadItem::DELETE_DUE_TO_USER_DISCARD);
- active_download_item_ = NULL;
- CleanupDownloadObjects();
- }
+ burn_manager_->CancelImageFetch();
} else if (state == StateMachine::BURNING) {
DCHECK(observing_burn_lib_);
// Burn library doesn't send cancelled signal upon CancelBurnImage
@@ -411,17 +352,6 @@ class BurnControllerImpl
return true;
}
- void CleanupDownloadObjects() {
- if (active_download_item_) {
- active_download_item_->RemoveObserver(this);
- active_download_item_ = NULL;
- }
- if (download_manager_) {
- download_manager_->RemoveObserver(this);
- download_manager_ = NULL;
- }
- }
-
int64 GetDeviceSize(const std::string& device_path) {
disks::DiskMountManager* disk_mount_manager =
disks::DiskMountManager::GetInstance();
@@ -436,9 +366,6 @@ class BurnControllerImpl
FilePath zip_image_file_path_;
GURL image_download_url_;
std::string image_file_name_;
- content::WebContents* web_contents_;
- content::DownloadManager* download_manager_;
- content::DownloadItem* active_download_item_;
BurnManager* burn_manager_;
StateMachine* state_machine_;
bool observing_burn_lib_;
@@ -454,7 +381,7 @@ class BurnControllerImpl
BurnController* BurnController::CreateBurnController(
content::WebContents* web_contents,
Delegate* delegate) {
- return new BurnControllerImpl(web_contents, delegate);
+ return new BurnControllerImpl(delegate);
}
} // namespace imageburner
diff --git a/chrome/browser/chromeos/imageburner/burn_manager.cc b/chrome/browser/chromeos/imageburner/burn_manager.cc
index 380a5ef..b4d89c5 100644
--- a/chrome/browser/chromeos/imageburner/burn_manager.cc
+++ b/chrome/browser/chromeos/imageburner/burn_manager.cc
@@ -9,22 +9,12 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/download/download_util.h"
#include "chrome/common/chrome_paths.h"
-#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/download_manager.h"
-#include "content/public/browser/download_save_info.h"
-#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/web_contents.h"
#include "content/public/common/url_fetcher.h"
-#include "net/base/file_stream.h"
#include "net/url_request/url_request_status.h"
using content::BrowserThread;
-using content::DownloadManager;
-using content::WebContents;
namespace chromeos {
namespace imageburner {
@@ -35,6 +25,8 @@ const char kConfigFileUrl[] =
"https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf";
const char kTempImageFolderName[] = "chromeos_image";
+const int64 kBytesImageDownloadProgressReportInterval = 10240;
+
BurnManager* g_burn_manager = NULL;
// Cretes a directory and calls |callback| with the result on UI thread.
@@ -45,21 +37,6 @@ void CreateDirectory(const FilePath& path,
base::Bind(callback, success));
}
-// Creates a FileStream and calls |callback| with the result on UI thread.
-void CreateFileStream(
- const FilePath& file_path,
- base::Callback<void(net::FileStream* file_stream)> callback) {
- scoped_ptr<net::FileStream> file_stream(new net::FileStream(NULL));
- // TODO(tbarzic): Save temp image file to temp folder instead of Downloads
- // once extracting image directly to removalbe device is implemented
- if (file_stream->OpenSync(file_path, base::PLATFORM_FILE_OPEN_ALWAYS |
- base::PLATFORM_FILE_WRITE))
- file_stream.reset();
-
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(callback, file_stream.release()));
-}
-
} // namespace
const char kName[] = "name";
@@ -180,8 +157,7 @@ ConfigFile::ConfigFileBlock::~ConfigFileBlock() {
//
////////////////////////////////////////////////////////////////////////////////
StateMachine::StateMachine()
- : image_download_requested_(false),
- download_started_(false),
+ : download_started_(false),
download_finished_(false),
state_(INITIAL) {
}
@@ -192,10 +168,9 @@ StateMachine::~StateMachine() {
void StateMachine::OnError(int error_message_id) {
if (state_ == INITIAL)
return;
- if (!download_finished_) {
+ if (!download_finished_)
download_started_ = false;
- image_download_requested_ = false;
- }
+
state_ = INITIAL;
FOR_EACH_OBSERVER(Observer, observers_, OnError(error_message_id));
}
@@ -223,7 +198,7 @@ BurnManager::BurnManager()
: weak_ptr_factory_(this),
config_file_url_(kConfigFileUrl),
state_machine_(new StateMachine()),
- downloader_(NULL) {
+ bytes_image_download_progress_last_reported_(0) {
}
BurnManager::~BurnManager() {
@@ -258,6 +233,14 @@ BurnManager* BurnManager::GetInstance() {
return g_burn_manager;
}
+void BurnManager::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void BurnManager::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
void BurnManager::CreateImageDir(Delegate* delegate) {
if (image_dir_.empty()) {
CHECK(PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &image_dir_));
@@ -300,15 +283,57 @@ void BurnManager::FetchConfigFile(Delegate* delegate) {
config_fetcher_->Start();
}
+void BurnManager::FetchImage(const GURL& image_url, const FilePath& file_path) {
+ tick_image_download_start_ = base::TimeTicks::Now();
+ bytes_image_download_progress_last_reported_ = 0;
+ image_fetcher_.reset(content::URLFetcher::Create(image_url,
+ content::URLFetcher::GET,
+ this));
+ image_fetcher_->SetRequestContext(
+ g_browser_process->system_request_context());
+ image_fetcher_->SaveResponseToFileAtPath(
+ file_path,
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
+ image_fetcher_->Start();
+}
+
+void BurnManager::CancelImageFetch() {
+ image_fetcher_.reset();
+}
+
void BurnManager::OnURLFetchComplete(const content::URLFetcher* source) {
+ const bool success =
+ source->GetStatus().status() == net::URLRequestStatus::SUCCESS;
if (source == config_fetcher_.get()) {
std::string data;
- const bool success =
- source->GetStatus().status() == net::URLRequestStatus::SUCCESS;
if (success)
config_fetcher_->GetResponseAsString(&data);
config_fetcher_.reset();
ConfigFileFetched(success, data);
+ } else if (source == image_fetcher_.get()) {
+ if (success)
+ FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCompleted());
+ else
+ FOR_EACH_OBSERVER(Observer, observers_, OnDownloadCancelled());
+ }
+}
+
+void BurnManager::OnURLFetchDownloadProgress(const content::URLFetcher* source,
+ int64 current,
+ int64 total) {
+ if (source == image_fetcher_.get()) {
+ if (current >= bytes_image_download_progress_last_reported_ +
+ kBytesImageDownloadProgressReportInterval) {
+ bytes_image_download_progress_last_reported_ = current;
+ base::TimeDelta time_remaining;
+ if (current > 0) {
+ const base::TimeDelta diff =
+ base::TimeTicks::Now() - tick_image_download_start_;
+ time_remaining = diff*(total - current)/current;
+ }
+ FOR_EACH_OBSERVER(Observer, observers_,
+ OnDownloadUpdated(current, total, time_remaining));
+ }
}
}
@@ -330,72 +355,5 @@ void BurnManager::ConfigFileFetched(bool fetched, const std::string& content) {
downloaders_.clear();
}
-////////////////////////////////////////////////////////////////////////////////
-//
-// Downloader
-//
-////////////////////////////////////////////////////////////////////////////////
-
-Downloader::Downloader() : weak_ptr_factory_(this) {}
-
-Downloader::~Downloader() {}
-
-void Downloader::DownloadFile(const GURL& url,
- const FilePath& file_path, WebContents* web_contents) {
- BrowserThread::PostBlockingPoolTask(
- FROM_HERE,
- base::Bind(CreateFileStream,
- file_path,
- base::Bind(&Downloader::OnFileStreamCreated,
- weak_ptr_factory_.GetWeakPtr(),
- url,
- file_path,
- web_contents)));
-}
-
-void Downloader::OnFileStreamCreated(const GURL& url,
- const FilePath& file_path,
- WebContents* web_contents,
- net::FileStream* file_stream) {
- if (file_stream) {
- DownloadManager* download_manager =
- web_contents->GetBrowserContext()->GetDownloadManager();
- content::DownloadSaveInfo save_info;
- save_info.file_path = file_path;
- save_info.file_stream = linked_ptr<net::FileStream>(file_stream);
- DownloadStarted(true, url);
-
- download_util::RecordDownloadSource(
- download_util::INITIATED_BY_IMAGE_BURNER);
- download_manager->DownloadUrl(
- url,
- web_contents->GetURL(),
- web_contents->GetEncoding(),
- false,
- -1,
- save_info,
- web_contents,
- DownloadManager::OnStartedCallback());
- } else {
- DownloadStarted(false, url);
- }
-}
-
-void Downloader::AddListener(Listener* listener, const GURL& url) {
- listeners_.insert(std::make_pair(url, listener->AsWeakPtr()));
-}
-
-void Downloader::DownloadStarted(bool success, const GURL& url) {
- std::pair<ListenerMap::iterator, ListenerMap::iterator> listener_range =
- listeners_.equal_range(url);
- for (ListenerMap::iterator current_listener = listener_range.first;
- current_listener != listener_range.second;
- ++current_listener) {
- if (current_listener->second)
- current_listener->second->OnBurnDownloadStarted(success);
- }
- listeners_.erase(listener_range.first, listener_range.second);
-}
-
} // namespace imageburner
} // namespace chromeos
diff --git a/chrome/browser/chromeos/imageburner/burn_manager.h b/chrome/browser/chromeos/imageburner/burn_manager.h
index c13c35d..de125b4 100644
--- a/chrome/browser/chromeos/imageburner/burn_manager.h
+++ b/chrome/browser/chromeos/imageburner/burn_manager.h
@@ -14,17 +14,10 @@
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
+#include "base/time.h"
#include "content/public/common/url_fetcher_delegate.h"
#include "googleurl/src/gurl.h"
-namespace content {
-class WebContents;
-}
-
-namespace net {
-class FileStream;
-}
-
namespace chromeos {
namespace imageburner {
@@ -34,45 +27,6 @@ extern const char kHwid[];
extern const char kFileName[];
extern const char kUrl[];
-class Downloader {
- public:
- class Listener : public base::SupportsWeakPtr<Listener> {
- public:
- // After download starts download status updates can be followed through
- // content::DownloadItem::Observer interface.
- virtual void OnBurnDownloadStarted(bool success) = 0;
- };
-
- Downloader();
- ~Downloader();
-
- // Downloads a file from the Internet.
- // Should be called from UI thread.
- void DownloadFile(const GURL& url,
- const FilePath& target_file,
- content::WebContents* web_contents);
-
- // Adds an item to list of listeners that wait for confirmation that download
- // has started.
- void AddListener(Listener* listener, const GURL& url);
-
- private:
- // Let listeners know if download started successfully.
- void DownloadStarted(bool success, const GURL& url);
-
- // Gets called after file stream is created and starts download.
- void OnFileStreamCreated(const GURL& url,
- const FilePath& file_path,
- content::WebContents* web_contents,
- net::FileStream* file_stream);
-
- typedef std::multimap<GURL, base::WeakPtr<Listener> > ListenerMap;
- ListenerMap listeners_;
- base::WeakPtrFactory<Downloader> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(Downloader);
-};
-
// Config file is divided into blocks. Each block is associated with one image
// and containes information about that image in form of key-value pairs, one
// pair per line. Each block starts with name property.
@@ -156,9 +110,6 @@ class StateMachine {
StateMachine();
~StateMachine();
- bool image_download_requested() const { return image_download_requested_; }
- void OnImageDownloadRequested() { image_download_requested_ = true; }
-
bool download_started() const { return download_started_; }
void OnDownloadStarted() {
download_started_ = true;
@@ -193,7 +144,6 @@ class StateMachine {
}
private:
- bool image_download_requested_;
bool download_started_;
bool download_finished_;
@@ -211,7 +161,16 @@ class BurnManager : content::URLFetcherDelegate {
public:
virtual void OnImageDirCreated(bool success) = 0;
virtual void OnConfigFileFetched(const ConfigFile& config_file,
- bool success) = 0;
+ bool success) = 0;
+ };
+
+ class Observer {
+ public:
+ virtual void OnDownloadUpdated(int64 received_bytes,
+ int64 total_bytes,
+ const base::TimeDelta& time_remaining) = 0;
+ virtual void OnDownloadCancelled() = 0;
+ virtual void OnDownloadCompleted() = 0;
};
// Creates the global BurnManager instance.
@@ -224,12 +183,27 @@ class BurnManager : content::URLFetcherDelegate {
// Initialize() should already have been called.
static BurnManager* GetInstance();
+ // Add an observer.
+ void AddObserver(Observer* observer);
+
+ // Remove an observer.
+ void RemoveObserver(Observer* observer);
+
// Creates URL image should be fetched from.
// Must be called from UI thread.
void FetchConfigFile(Delegate* delegate);
- // URLFetcherDelegate override.
+ // Fetch a zipped recovery image.
+ void FetchImage(const GURL& image_url, const FilePath& file_path);
+
+ // Cancel fetching image.
+ void CancelImageFetch();
+
+ // URLFetcherDelegate overrides:
virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE;
+ virtual void OnURLFetchDownloadProgress(const content::URLFetcher* source,
+ int64 current,
+ int64 total) OVERRIDE;
// Creates directory image will be downloaded to.
// Must be called from FILE thread.
@@ -256,12 +230,6 @@ class BurnManager : content::URLFetcherDelegate {
StateMachine* state_machine() const { return state_machine_.get(); }
- Downloader* downloader() {
- if (!downloader_.get())
- downloader_.reset(new Downloader());
- return downloader_.get();
- }
-
private:
BurnManager();
virtual ~BurnManager();
@@ -283,8 +251,13 @@ class BurnManager : content::URLFetcherDelegate {
scoped_ptr<StateMachine> state_machine_;
- scoped_ptr<Downloader> downloader_;
scoped_ptr<content::URLFetcher> config_fetcher_;
+ scoped_ptr<content::URLFetcher> image_fetcher_;
+
+ base::TimeTicks tick_image_download_start_;
+ int64 bytes_image_download_progress_last_reported_;
+
+ ObserverList<Observer> observers_;
DISALLOW_COPY_AND_ASSIGN(BurnManager);
};
diff --git a/chrome/browser/chromeos/imageburner/burn_manager_unittest.cc b/chrome/browser/chromeos/imageburner/burn_manager_unittest.cc
index 12b6043..b00bf73 100644
--- a/chrome/browser/chromeos/imageburner/burn_manager_unittest.cc
+++ b/chrome/browser/chromeos/imageburner/burn_manager_unittest.cc
@@ -156,15 +156,6 @@ TEST(BurnManagerTest, StateMachineNormalWorkflow) {
.Times(1)
.RetiresOnSaturation();
- EXPECT_FALSE(state_machine->image_download_requested());
- EXPECT_FALSE(state_machine->download_started());
- EXPECT_FALSE(state_machine->download_finished());
- EXPECT_TRUE(state_machine->new_burn_posible());
-
- state_machine->OnImageDownloadRequested();
-
- EXPECT_EQ(StateMachine::INITIAL, state_machine->state());
- EXPECT_TRUE(state_machine->image_download_requested());
EXPECT_FALSE(state_machine->download_started());
EXPECT_FALSE(state_machine->download_finished());
EXPECT_TRUE(state_machine->new_burn_posible());
@@ -172,7 +163,6 @@ TEST(BurnManagerTest, StateMachineNormalWorkflow) {
state_machine->OnDownloadStarted();
EXPECT_EQ(StateMachine::DOWNLOADING, state_machine->state());
- EXPECT_TRUE(state_machine->image_download_requested());
EXPECT_TRUE(state_machine->download_started());
EXPECT_FALSE(state_machine->download_finished());
EXPECT_FALSE(state_machine->new_burn_posible());
@@ -181,7 +171,6 @@ TEST(BurnManagerTest, StateMachineNormalWorkflow) {
// TODO(tbarzic): make this pass.
// EXPECT_EQ(StateMachine::INITIAL, state_machine->state());
- EXPECT_TRUE(state_machine->image_download_requested());
EXPECT_TRUE(state_machine->download_started());
EXPECT_TRUE(state_machine->download_finished());
EXPECT_FALSE(state_machine->new_burn_posible());
@@ -189,7 +178,6 @@ TEST(BurnManagerTest, StateMachineNormalWorkflow) {
state_machine->OnBurnStarted();
EXPECT_EQ(StateMachine::BURNING, state_machine->state());
- EXPECT_TRUE(state_machine->image_download_requested());
EXPECT_TRUE(state_machine->download_started());
EXPECT_TRUE(state_machine->download_finished());
EXPECT_FALSE(state_machine->new_burn_posible());
@@ -197,7 +185,6 @@ TEST(BurnManagerTest, StateMachineNormalWorkflow) {
state_machine->OnSuccess();
EXPECT_EQ(StateMachine::INITIAL, state_machine->state());
- EXPECT_TRUE(state_machine->image_download_requested());
EXPECT_TRUE(state_machine->download_started());
EXPECT_TRUE(state_machine->download_finished());
EXPECT_TRUE(state_machine->new_burn_posible());
@@ -224,25 +211,21 @@ TEST(BurnManagerTest, StateMachineError) {
}
state_machine->AddObserver(&observer);
- state_machine->OnImageDownloadRequested();
state_machine->OnDownloadStarted();
state_machine->OnError(1234);
// If called before download finished, download flags should be reset.
- EXPECT_FALSE(state_machine->image_download_requested());
EXPECT_FALSE(state_machine->download_started());
EXPECT_EQ(state_machine->state(), StateMachine::INITIAL);
EXPECT_TRUE(state_machine->new_burn_posible());
- state_machine->OnImageDownloadRequested();
state_machine->OnDownloadStarted();
state_machine->OnDownloadFinished();
state_machine->OnError(4321);
// If called after download finished, download flags should not be changed.
- EXPECT_TRUE(state_machine->image_download_requested());
EXPECT_TRUE(state_machine->download_started());
EXPECT_TRUE(state_machine->download_finished());
EXPECT_EQ(state_machine->state(), StateMachine::INITIAL);