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

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/operation_manager.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/extensions/api/image_writer_private/operation_manager.h " 5 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h "
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 void OperationManager::OnProgress(const ExtensionId& extension_id, 156 void OperationManager::OnProgress(const ExtensionId& extension_id,
157 image_writer_api::Stage stage, 157 image_writer_api::Stage stage,
158 int progress) { 158 int progress) {
159 DCHECK_CURRENTLY_ON(BrowserThread::UI); 159 DCHECK_CURRENTLY_ON(BrowserThread::UI);
160 160
161 image_writer_api::ProgressInfo info; 161 image_writer_api::ProgressInfo info;
162 info.stage = stage; 162 info.stage = stage;
163 info.percent_complete = progress; 163 info.percent_complete = progress;
164 164
165 scoped_ptr<base::ListValue> args( 165 std::unique_ptr<base::ListValue> args(
166 image_writer_api::OnWriteProgress::Create(info)); 166 image_writer_api::OnWriteProgress::Create(info));
167 scoped_ptr<Event> event(new Event( 167 std::unique_ptr<Event> event(new Event(
168 events::IMAGE_WRITER_PRIVATE_ON_WRITE_PROGRESS, 168 events::IMAGE_WRITER_PRIVATE_ON_WRITE_PROGRESS,
169 image_writer_api::OnWriteProgress::kEventName, std::move(args))); 169 image_writer_api::OnWriteProgress::kEventName, std::move(args)));
170 170
171 EventRouter::Get(browser_context_) 171 EventRouter::Get(browser_context_)
172 ->DispatchEventToExtension(extension_id, std::move(event)); 172 ->DispatchEventToExtension(extension_id, std::move(event));
173 } 173 }
174 174
175 void OperationManager::OnComplete(const ExtensionId& extension_id) { 175 void OperationManager::OnComplete(const ExtensionId& extension_id) {
176 DCHECK_CURRENTLY_ON(BrowserThread::UI); 176 DCHECK_CURRENTLY_ON(BrowserThread::UI);
177 177
178 scoped_ptr<base::ListValue> args(image_writer_api::OnWriteComplete::Create()); 178 std::unique_ptr<base::ListValue> args(
179 scoped_ptr<Event> event(new Event( 179 image_writer_api::OnWriteComplete::Create());
180 std::unique_ptr<Event> event(new Event(
180 events::IMAGE_WRITER_PRIVATE_ON_WRITE_COMPLETE, 181 events::IMAGE_WRITER_PRIVATE_ON_WRITE_COMPLETE,
181 image_writer_api::OnWriteComplete::kEventName, std::move(args))); 182 image_writer_api::OnWriteComplete::kEventName, std::move(args)));
182 183
183 EventRouter::Get(browser_context_) 184 EventRouter::Get(browser_context_)
184 ->DispatchEventToExtension(extension_id, std::move(event)); 185 ->DispatchEventToExtension(extension_id, std::move(event));
185 186
186 DeleteOperation(extension_id); 187 DeleteOperation(extension_id);
187 } 188 }
188 189
189 void OperationManager::OnError(const ExtensionId& extension_id, 190 void OperationManager::OnError(const ExtensionId& extension_id,
190 image_writer_api::Stage stage, 191 image_writer_api::Stage stage,
191 int progress, 192 int progress,
192 const std::string& error_message) { 193 const std::string& error_message) {
193 DCHECK_CURRENTLY_ON(BrowserThread::UI); 194 DCHECK_CURRENTLY_ON(BrowserThread::UI);
194 image_writer_api::ProgressInfo info; 195 image_writer_api::ProgressInfo info;
195 196
196 DLOG(ERROR) << "ImageWriter error: " << error_message; 197 DLOG(ERROR) << "ImageWriter error: " << error_message;
197 198
198 info.stage = stage; 199 info.stage = stage;
199 info.percent_complete = progress; 200 info.percent_complete = progress;
200 201
201 scoped_ptr<base::ListValue> args( 202 std::unique_ptr<base::ListValue> args(
202 image_writer_api::OnWriteError::Create(info, error_message)); 203 image_writer_api::OnWriteError::Create(info, error_message));
203 scoped_ptr<Event> event(new Event(events::IMAGE_WRITER_PRIVATE_ON_WRITE_ERROR, 204 std::unique_ptr<Event> event(
204 image_writer_api::OnWriteError::kEventName, 205 new Event(events::IMAGE_WRITER_PRIVATE_ON_WRITE_ERROR,
205 std::move(args))); 206 image_writer_api::OnWriteError::kEventName, std::move(args)));
206 207
207 EventRouter::Get(browser_context_) 208 EventRouter::Get(browser_context_)
208 ->DispatchEventToExtension(extension_id, std::move(event)); 209 ->DispatchEventToExtension(extension_id, std::move(event));
209 210
210 DeleteOperation(extension_id); 211 DeleteOperation(extension_id);
211 } 212 }
212 213
213 Operation* OperationManager::GetOperation(const ExtensionId& extension_id) { 214 Operation* OperationManager::GetOperation(const ExtensionId& extension_id) {
214 OperationMap::iterator existing_operation = operations_.find(extension_id); 215 OperationMap::iterator existing_operation = operations_.find(extension_id);
215 216
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 g_factory = LAZY_INSTANCE_INITIALIZER; 266 g_factory = LAZY_INSTANCE_INITIALIZER;
266 267
267 BrowserContextKeyedAPIFactory<OperationManager>* 268 BrowserContextKeyedAPIFactory<OperationManager>*
268 OperationManager::GetFactoryInstance() { 269 OperationManager::GetFactoryInstance() {
269 return g_factory.Pointer(); 270 return g_factory.Pointer();
270 } 271 }
271 272
272 273
273 } // namespace image_writer 274 } // namespace image_writer
274 } // namespace extensions 275 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698