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

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

Issue 109793006: Adds ImageWriterPrivate.destroyPartitions operation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes up DBusThreadManager initialization. Created 7 years 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_manager.cc
diff --git a/chrome/browser/extensions/api/image_writer_private/operation_manager.cc b/chrome/browser/extensions/api/image_writer_private/operation_manager.cc
index b1b1c44d06112f44ad2c78676829f1652b1c911c..2b525e56389cd718d3a4e58f531ecf068e90ab7f 100644
--- a/chrome/browser/extensions/api/image_writer_private/operation_manager.cc
+++ b/chrome/browser/extensions/api/image_writer_private/operation_manager.cc
@@ -5,6 +5,7 @@
#include "base/lazy_instance.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_operation.h"
#include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
#include "chrome/browser/extensions/api/image_writer_private/operation.h"
#include "chrome/browser/extensions/api/image_writer_private/operation_manager.h"
@@ -63,7 +64,6 @@ void OperationManager::StartWriteFromUrl(
bool saveImageAsDownload,
const std::string& storage_unit_id,
const Operation::StartWriteCallback& callback) {
-
OperationMap::iterator existing_operation = operations_.find(extension_id);
if (existing_operation != operations_.end()) {
@@ -78,14 +78,10 @@ void OperationManager::StartWriteFromUrl(
hash,
saveImageAsDownload,
storage_unit_id));
-
operations_[extension_id] = operation;
-
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
- base::Bind(&Operation::Start,
- operation.get()));
-
+ base::Bind(&Operation::Start, operation));
callback.Run(true, "");
}
@@ -105,14 +101,10 @@ void OperationManager::StartWriteFromFile(
extension_id,
path,
storage_unit_id));
-
operations_[extension_id] = operation;
-
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
- base::Bind(&Operation::Start,
- operation.get()));
-
+ base::Bind(&Operation::Start, operation));
callback.Run(true, "");
}
@@ -132,6 +124,27 @@ void OperationManager::CancelWrite(
}
}
+void OperationManager::DestroyPartitions(
+ const ExtensionId& extension_id,
+ const std::string& storage_unit_id,
+ const Operation::StartWriteCallback& callback) {
+ OperationMap::iterator existing_operation = operations_.find(extension_id);
+
+ if (existing_operation != operations_.end()) {
+ return callback.Run(false, error::kOperationAlreadyInProgress);
+ }
+
+ scoped_refptr<Operation> operation(
+ new DestroyPartitionsOperation(weak_factory_.GetWeakPtr(),
+ extension_id,
+ storage_unit_id));
+ operations_[extension_id] = operation;
+ BrowserThread::PostTask(BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&Operation::Start, operation));
+ callback.Run(true, "");
+}
+
void OperationManager::OnProgress(const ExtensionId& extension_id,
image_writer_api::Stage stage,
int progress) {

Powered by Google App Engine
This is Rietveld 408576698