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

Unified Diff: trunk/src/chrome/browser/extensions/api/image_writer_private/operation.cc

Issue 175423004: Revert 252466 "In order to support writing on windows we need to..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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: trunk/src/chrome/browser/extensions/api/image_writer_private/operation.cc
===================================================================
--- trunk/src/chrome/browser/extensions/api/image_writer_private/operation.cc (revision 252593)
+++ trunk/src/chrome/browser/extensions/api/image_writer_private/operation.cc (working copy)
@@ -33,6 +33,10 @@
#else
device_path_(device_path),
#endif
+#if defined(OS_LINUX) && !defined(CHROMEOS)
+ image_file_(base::kInvalidPlatformFileValue),
+ device_file_(base::kInvalidPlatformFileValue),
+#endif
stage_(image_writer_api::STAGE_UNKNOWN),
progress_(0) {
}
@@ -59,13 +63,6 @@
return stage_;
}
-#if !defined(OS_CHROMEOS)
-void Operation::SetUtilityClientForTesting(
- scoped_refptr<ImageWriterUtilityClient> client) {
- image_writer_client_ = client;
-}
-#endif
-
void Operation::Start() {
#if defined(OS_CHROMEOS)
if (!temp_dir_.CreateUniqueTempDirUnderPath(
@@ -120,7 +117,7 @@
zip_reader_.ExtractCurrentEntryToFilePathAsync(
image_path_,
- base::Bind(&Operation::CompleteAndContinue, this, continuation),
+ base::Bind(&Operation::OnUnzipSuccess, this, continuation),
base::Bind(&Operation::OnUnzipFailure, this),
base::Bind(&Operation::OnUnzipProgress,
this,
@@ -184,13 +181,14 @@
progress_ = progress;
- BrowserThread::PostTask(BrowserThread::UI,
- FROM_HERE,
- base::Bind(&OperationManager::OnProgress,
- manager_,
- extension_id_,
- stage_,
- progress_));
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&OperationManager::OnProgress,
+ manager_,
+ extension_id_,
+ stage_,
+ progress_));
}
void Operation::SetStage(image_writer_api::Stage stage) {
@@ -232,43 +230,6 @@
cleanup_functions_.push_back(callback);
}
-void Operation::CompleteAndContinue(const base::Closure& continuation) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- SetProgress(kProgressComplete);
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, continuation);
-}
-
-#if !defined(OS_CHROMEOS)
-void Operation::StartUtilityClient() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- if (!image_writer_client_) {
- image_writer_client_ = new ImageWriterUtilityClient();
- AddCleanUpFunction(base::Bind(&Operation::StopUtilityClient, this));
- }
-}
-
-void Operation::StopUtilityClient() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(&ImageWriterUtilityClient::Shutdown, image_writer_client_));
-}
-
-void Operation::WriteImageProgress(int64 total_bytes, int64 curr_bytes) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- if (IsCancelled()) {
- return;
- }
-
- int progress = kProgressComplete * curr_bytes / total_bytes;
-
- if (progress > GetProgress()) {
- SetProgress(progress);
- }
-}
-#endif
-
void Operation::GetMD5SumOfFile(
const base::FilePath& file_path,
int64 file_size,
@@ -365,6 +326,12 @@
base::ClosePlatformFile(file);
}
+void Operation::OnUnzipSuccess(const base::Closure& continuation) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ SetProgress(kProgressComplete);
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, continuation);
+}
+
void Operation::OnUnzipFailure() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
Error(error::kUnzipGenericError);
@@ -373,7 +340,7 @@
void Operation::OnUnzipProgress(int64 total_bytes, int64 progress_bytes) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- int progress_percent = kProgressComplete * progress_bytes / total_bytes;
+ int progress_percent = 100 * progress_bytes / total_bytes;
SetProgress(progress_percent);
}

Powered by Google App Engine
This is Rietveld 408576698