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

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

Issue 257333002: Drive extension functions from ExtensionFunction::Run. The (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 6 years, 7 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 | Annotate | Revision Log
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 6 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
7 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" 7 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h"
8 #include "chrome/browser/extensions/api/image_writer_private/image_writer_privat e_api.h" 8 #include "chrome/browser/extensions/api/image_writer_private/image_writer_privat e_api.h"
9 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h " 9 #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h "
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 11
12 namespace image_writer_api = extensions::api::image_writer_private; 12 namespace image_writer_api = extensions::api::image_writer_private;
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 ImageWriterPrivateWriteFromUrlFunction:: 16 ImageWriterPrivateWriteFromUrlFunction::
17 ImageWriterPrivateWriteFromUrlFunction() { 17 ImageWriterPrivateWriteFromUrlFunction() {
18 } 18 }
19 19
20 ImageWriterPrivateWriteFromUrlFunction:: 20 ImageWriterPrivateWriteFromUrlFunction::
21 ~ImageWriterPrivateWriteFromUrlFunction() { 21 ~ImageWriterPrivateWriteFromUrlFunction() {
22 } 22 }
23 23
24 bool ImageWriterPrivateWriteFromUrlFunction::RunImpl() { 24 bool ImageWriterPrivateWriteFromUrlFunction::RunAsync() {
25 scoped_ptr<image_writer_api::WriteFromUrl::Params> params( 25 scoped_ptr<image_writer_api::WriteFromUrl::Params> params(
26 image_writer_api::WriteFromUrl::Params::Create(*args_)); 26 image_writer_api::WriteFromUrl::Params::Create(*args_));
27 EXTENSION_FUNCTION_VALIDATE(params.get()); 27 EXTENSION_FUNCTION_VALIDATE(params.get());
28 28
29 GURL url(params->image_url); 29 GURL url(params->image_url);
30 if (!url.is_valid()) { 30 if (!url.is_valid()) {
31 error_ = image_writer::error::kUrlInvalid; 31 error_ = image_writer::error::kUrlInvalid;
32 return false; 32 return false;
33 } 33 }
34 34
(...skipping 23 matching lines...) Expand all
58 } 58 }
59 59
60 ImageWriterPrivateWriteFromFileFunction:: 60 ImageWriterPrivateWriteFromFileFunction::
61 ImageWriterPrivateWriteFromFileFunction() { 61 ImageWriterPrivateWriteFromFileFunction() {
62 } 62 }
63 63
64 ImageWriterPrivateWriteFromFileFunction:: 64 ImageWriterPrivateWriteFromFileFunction::
65 ~ImageWriterPrivateWriteFromFileFunction() { 65 ~ImageWriterPrivateWriteFromFileFunction() {
66 } 66 }
67 67
68 bool ImageWriterPrivateWriteFromFileFunction::RunImpl() { 68 bool ImageWriterPrivateWriteFromFileFunction::RunAsync() {
69 std::string filesystem_name; 69 std::string filesystem_name;
70 std::string filesystem_path; 70 std::string filesystem_path;
71 std::string storage_unit_id; 71 std::string storage_unit_id;
72 72
73 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &storage_unit_id)); 73 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &storage_unit_id));
74 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_name)); 74 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_name));
75 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &filesystem_path)); 75 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &filesystem_path));
76 76
77 base::FilePath path; 77 base::FilePath path;
78 78
(...skipping 23 matching lines...) Expand all
102 SendResponse(success); 102 SendResponse(success);
103 } 103 }
104 104
105 ImageWriterPrivateCancelWriteFunction::ImageWriterPrivateCancelWriteFunction() { 105 ImageWriterPrivateCancelWriteFunction::ImageWriterPrivateCancelWriteFunction() {
106 } 106 }
107 107
108 ImageWriterPrivateCancelWriteFunction:: 108 ImageWriterPrivateCancelWriteFunction::
109 ~ImageWriterPrivateCancelWriteFunction() { 109 ~ImageWriterPrivateCancelWriteFunction() {
110 } 110 }
111 111
112 bool ImageWriterPrivateCancelWriteFunction::RunImpl() { 112 bool ImageWriterPrivateCancelWriteFunction::RunAsync() {
113 image_writer::OperationManager::Get(GetProfile())->CancelWrite( 113 image_writer::OperationManager::Get(GetProfile())->CancelWrite(
114 extension_id(), 114 extension_id(),
115 base::Bind(&ImageWriterPrivateCancelWriteFunction::OnWriteCancelled, 115 base::Bind(&ImageWriterPrivateCancelWriteFunction::OnWriteCancelled,
116 this)); 116 this));
117 return true; 117 return true;
118 } 118 }
119 119
120 void ImageWriterPrivateCancelWriteFunction::OnWriteCancelled( 120 void ImageWriterPrivateCancelWriteFunction::OnWriteCancelled(
121 bool success, 121 bool success,
122 const std::string& error) { 122 const std::string& error) {
123 if (!success) { 123 if (!success) {
124 error_ = error; 124 error_ = error;
125 } 125 }
126 SendResponse(success); 126 SendResponse(success);
127 } 127 }
128 128
129 ImageWriterPrivateDestroyPartitionsFunction:: 129 ImageWriterPrivateDestroyPartitionsFunction::
130 ImageWriterPrivateDestroyPartitionsFunction() { 130 ImageWriterPrivateDestroyPartitionsFunction() {
131 } 131 }
132 132
133 ImageWriterPrivateDestroyPartitionsFunction:: 133 ImageWriterPrivateDestroyPartitionsFunction::
134 ~ImageWriterPrivateDestroyPartitionsFunction() { 134 ~ImageWriterPrivateDestroyPartitionsFunction() {
135 } 135 }
136 136
137 bool ImageWriterPrivateDestroyPartitionsFunction::RunImpl() { 137 bool ImageWriterPrivateDestroyPartitionsFunction::RunAsync() {
138 scoped_ptr<image_writer_api::DestroyPartitions::Params> params( 138 scoped_ptr<image_writer_api::DestroyPartitions::Params> params(
139 image_writer_api::DestroyPartitions::Params::Create(*args_)); 139 image_writer_api::DestroyPartitions::Params::Create(*args_));
140 EXTENSION_FUNCTION_VALIDATE(params.get()); 140 EXTENSION_FUNCTION_VALIDATE(params.get());
141 141
142 image_writer::OperationManager::Get(GetProfile())->DestroyPartitions( 142 image_writer::OperationManager::Get(GetProfile())->DestroyPartitions(
143 extension_id(), 143 extension_id(),
144 params->storage_unit_id, 144 params->storage_unit_id,
145 base::Bind( 145 base::Bind(
146 &ImageWriterPrivateDestroyPartitionsFunction::OnDestroyComplete, 146 &ImageWriterPrivateDestroyPartitionsFunction::OnDestroyComplete,
147 this)); 147 this));
(...skipping 11 matching lines...) Expand all
159 } 159 }
160 160
161 ImageWriterPrivateListRemovableStorageDevicesFunction:: 161 ImageWriterPrivateListRemovableStorageDevicesFunction::
162 ImageWriterPrivateListRemovableStorageDevicesFunction() { 162 ImageWriterPrivateListRemovableStorageDevicesFunction() {
163 } 163 }
164 164
165 ImageWriterPrivateListRemovableStorageDevicesFunction:: 165 ImageWriterPrivateListRemovableStorageDevicesFunction::
166 ~ImageWriterPrivateListRemovableStorageDevicesFunction() { 166 ~ImageWriterPrivateListRemovableStorageDevicesFunction() {
167 } 167 }
168 168
169 bool ImageWriterPrivateListRemovableStorageDevicesFunction::RunImpl() { 169 bool ImageWriterPrivateListRemovableStorageDevicesFunction::RunAsync() {
170 RemovableStorageProvider::GetAllDevices( 170 RemovableStorageProvider::GetAllDevices(
171 base::Bind( 171 base::Bind(
172 &ImageWriterPrivateListRemovableStorageDevicesFunction::OnDeviceListReady, 172 &ImageWriterPrivateListRemovableStorageDevicesFunction::OnDeviceListReady,
173 this)); 173 this));
174 return true; 174 return true;
175 } 175 }
176 176
177 void ImageWriterPrivateListRemovableStorageDevicesFunction::OnDeviceListReady( 177 void ImageWriterPrivateListRemovableStorageDevicesFunction::OnDeviceListReady(
178 scoped_refptr<StorageDeviceList> device_list, 178 scoped_refptr<StorageDeviceList> device_list,
179 bool success) { 179 bool success) {
180 if (success) { 180 if (success) {
181 results_ = 181 results_ =
182 image_writer_api::ListRemovableStorageDevices::Results::Create( 182 image_writer_api::ListRemovableStorageDevices::Results::Create(
183 device_list.get()->data); 183 device_list.get()->data);
184 SendResponse(true); 184 SendResponse(true);
185 } else { 185 } else {
186 error_ = image_writer::error::kDeviceListError; 186 error_ = image_writer::error::kDeviceListError;
187 SendResponse(false); 187 SendResponse(false);
188 } 188 }
189 } 189 }
190 190
191 } // namespace extensions 191 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698