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

Unified Diff: chrome/browser/extensions/api/image_writer_private/operation_chromeos.cc

Issue 149313003: Significantly cleans up the ImageWriter Operation class and subclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes cross-compilation and test issues. Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/image_writer_private/operation_chromeos.cc
diff --git a/chrome/browser/extensions/api/image_writer_private/operation_chromeos.cc b/chrome/browser/extensions/api/image_writer_private/operation_chromeos.cc
index d05ef9b1e368a2b71c89b7a8405f2183a9e811e8..d7fe5ecc5be3453efb22132365bbfdf8d18f382b 100644
--- a/chrome/browser/extensions/api/image_writer_private/operation_chromeos.cc
+++ b/chrome/browser/extensions/api/image_writer_private/operation_chromeos.cc
@@ -31,49 +31,56 @@ void ClearImageBurner() {
} // namespace
-void Operation::WriteStart() {
+void Operation::Write(const base::Closure& continuation) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
SetStage(image_writer_api::STAGE_WRITE);
- BrowserThread::PostTask(BrowserThread::UI,
- FROM_HERE,
- base::Bind(&Operation::StartWriteOnUIThread, this));
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&Operation::StartWriteOnUIThread, this, continuation));
AddCleanUpFunction(base::Bind(&ClearImageBurner));
}
-void Operation::StartWriteOnUIThread() {
+void Operation::VerifyWrite(const base::Closure& continuation) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+
+ // No verification is available in Chrome OS currently.
+ continuation.Run();
+}
+
+void Operation::StartWriteOnUIThread(const base::Closure& continuation) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DVLOG(1) << "Starting burn.";
ImageBurnerClient* burner =
chromeos::DBusThreadManager::Get()->GetImageBurnerClient();
burner->SetEventHandlers(
- base::Bind(&Operation::OnBurnFinished, this),
+ base::Bind(&Operation::OnBurnFinished, this, continuation),
base::Bind(&Operation::OnBurnProgress, this));
burner->BurnImage(image_path_.value(),
- storage_unit_id_,
+ device_path_.value(),
base::Bind(&Operation::OnBurnError, this));
}
-void Operation::OnBurnFinished(const std::string& target_path,
- bool success,
- const std::string& error) {
- DVLOG(1) << "Burn finished: " << success;
-
+void Operation::OnBurnFinished(const base::Closure& continuation,
+ const std::string& target_path,
+ bool success,
+ const std::string& error) {
if (success) {
SetProgress(kProgressComplete);
- Finish();
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, continuation);
} else {
- Error(error);
+ DLOG(ERROR) << "Error encountered while burning: " << error;
+ Error(error::kChromeOSImageBurnerError);
}
}
void Operation::OnBurnProgress(const std::string& target_path,
- int64 num_bytes_burnt,
- int64 total_size) {
+ int64 num_bytes_burnt,
+ int64 total_size) {
int progress = kProgressComplete * num_bytes_burnt / total_size;
SetProgress(progress);
}

Powered by Google App Engine
This is Rietveld 408576698