Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/lazy_instance.h" | 5 #include "base/lazy_instance.h" |
| 6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/api/image_writer_private/destroy_partitions_ operation.h" | |
| 8 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 9 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
| 9 #include "chrome/browser/extensions/api/image_writer_private/operation.h" | 10 #include "chrome/browser/extensions/api/image_writer_private/operation.h" |
| 10 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h " | 11 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h " |
| 11 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope ration.h" | 12 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope ration.h" |
| 12 #include "chrome/browser/extensions/api/image_writer_private/write_from_url_oper ation.h" | 13 #include "chrome/browser/extensions/api/image_writer_private/write_from_url_oper ation.h" |
| 13 #include "chrome/browser/extensions/event_router_forwarder.h" | 14 #include "chrome/browser/extensions/event_router_forwarder.h" |
| 14 #include "chrome/browser/extensions/extension_host.h" | 15 #include "chrome/browser/extensions/extension_host.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_system.h" | 17 #include "chrome/browser/extensions/extension_system.h" |
| 17 #include "chrome/browser/extensions/extension_system_factory.h" | 18 #include "chrome/browser/extensions/extension_system_factory.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 callback.Run(false, error::kNoOperationInProgress); | 126 callback.Run(false, error::kNoOperationInProgress); |
| 126 } else { | 127 } else { |
| 127 BrowserThread::PostTask(BrowserThread::FILE, | 128 BrowserThread::PostTask(BrowserThread::FILE, |
| 128 FROM_HERE, | 129 FROM_HERE, |
| 129 base::Bind(&Operation::Cancel, existing_operation)); | 130 base::Bind(&Operation::Cancel, existing_operation)); |
| 130 DeleteOperation(extension_id); | 131 DeleteOperation(extension_id); |
| 131 callback.Run(true, ""); | 132 callback.Run(true, ""); |
| 132 } | 133 } |
| 133 } | 134 } |
| 134 | 135 |
| 136 void OperationManager::DestroyPartitions( | |
| 137 const ExtensionId& extension_id, | |
| 138 const std::string& storage_unit_id, | |
| 139 const Operation::StartWriteCallback& callback) { | |
| 140 | |
|
tbarzic
2013/12/14 01:01:04
nuke the empty line
Drew Haven
2013/12/16 20:15:33
And I nuked a few others.
| |
| 141 OperationMap::iterator existing_operation = operations_.find(extension_id); | |
| 142 | |
| 143 if (existing_operation != operations_.end()) { | |
| 144 return callback.Run(false, error::kOperationAlreadyInProgress); | |
| 145 } | |
| 146 | |
| 147 scoped_refptr<Operation> operation( | |
| 148 new DestroyPartitionsOperation(weak_factory_.GetWeakPtr(), | |
| 149 extension_id, | |
| 150 storage_unit_id)); | |
| 151 operations_[extension_id] = operation; | |
| 152 | |
| 153 BrowserThread::PostTask(BrowserThread::FILE, | |
| 154 FROM_HERE, | |
| 155 base::Bind(&Operation::Start, | |
| 156 operation.get())); | |
|
tbarzic
2013/12/14 01:01:04
I don't think you need get()
Drew Haven
2013/12/16 20:15:33
Indeed. I also fixed the other places this patter
| |
| 157 | |
| 158 callback.Run(true, ""); | |
| 159 } | |
| 160 | |
| 135 void OperationManager::OnProgress(const ExtensionId& extension_id, | 161 void OperationManager::OnProgress(const ExtensionId& extension_id, |
| 136 image_writer_api::Stage stage, | 162 image_writer_api::Stage stage, |
| 137 int progress) { | 163 int progress) { |
| 138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 164 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 139 DVLOG(2) << "progress - " << stage << " at " << progress << "%"; | 165 DVLOG(2) << "progress - " << stage << " at " << progress << "%"; |
| 140 | 166 |
| 141 image_writer_api::ProgressInfo info; | 167 image_writer_api::ProgressInfo info; |
| 142 info.stage = stage; | 168 info.stage = stage; |
| 143 info.percent_complete = progress; | 169 info.percent_complete = progress; |
| 144 | 170 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 g_factory = LAZY_INSTANCE_INITIALIZER; | 271 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 246 | 272 |
| 247 ProfileKeyedAPIFactory<OperationManager>* | 273 ProfileKeyedAPIFactory<OperationManager>* |
| 248 OperationManager::GetFactoryInstance() { | 274 OperationManager::GetFactoryInstance() { |
| 249 return &g_factory.Get(); | 275 return &g_factory.Get(); |
| 250 } | 276 } |
| 251 | 277 |
| 252 | 278 |
| 253 } // namespace image_writer | 279 } // namespace image_writer |
| 254 } // namespace extensions | 280 } // namespace extensions |
| OLD | NEW |