| 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) {
|
|
|