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

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

Issue 149313003: Significantly cleans up the ImageWriter Operation class and subclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback: Creates StartImpl function, updates platformfile lifetime to use passed ScopedPlat… Created 6 years, 10 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 "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 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #endif 43 #endif
44 44
45 std::string hash; 45 std::string hash;
46 if (params->options.get() && params->options->image_hash.get()) { 46 if (params->options.get() && params->options->image_hash.get()) {
47 hash = *params->options->image_hash; 47 hash = *params->options->image_hash;
48 } 48 }
49 49
50 image_writer::OperationManager::Get(GetProfile())->StartWriteFromUrl( 50 image_writer::OperationManager::Get(GetProfile())->StartWriteFromUrl(
51 extension_id(), 51 extension_id(),
52 url, 52 url,
53 render_view_host(),
54 hash, 53 hash,
55 save_image_as_download, 54 save_image_as_download,
56 params->storage_unit_id, 55 params->storage_unit_id,
57 base::Bind(&ImageWriterPrivateWriteFromUrlFunction::OnWriteStarted, 56 base::Bind(&ImageWriterPrivateWriteFromUrlFunction::OnWriteStarted,
58 this)); 57 this));
59 return true; 58 return true;
60 } 59 }
61 60
62 void ImageWriterPrivateWriteFromUrlFunction::OnWriteStarted( 61 void ImageWriterPrivateWriteFromUrlFunction::OnWriteStarted(
63 bool success, 62 bool success,
(...skipping 18 matching lines...) Expand all
82 std::string filesystem_path; 81 std::string filesystem_path;
83 std::string storage_unit_id; 82 std::string storage_unit_id;
84 83
85 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &storage_unit_id)); 84 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &storage_unit_id));
86 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_name)); 85 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_name));
87 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &filesystem_path)); 86 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &filesystem_path));
88 87
89 base::FilePath path; 88 base::FilePath path;
90 89
91 if (!extensions::app_file_handler_util::ValidateFileEntryAndGetPath( 90 if (!extensions::app_file_handler_util::ValidateFileEntryAndGetPath(
92 filesystem_name, 91 filesystem_name,
93 filesystem_path, 92 filesystem_path,
94 render_view_host_, 93 render_view_host(),
95 &path, 94 &path,
96 &error_)) 95 &error_))
97 return false; 96 return false;
98 97
99 image_writer::OperationManager::Get(GetProfile())->StartWriteFromFile( 98 image_writer::OperationManager::Get(GetProfile())->StartWriteFromFile(
100 extension_id(), 99 extension_id(),
101 path, 100 path,
102 storage_unit_id, 101 storage_unit_id,
103 base::Bind(&ImageWriterPrivateWriteFromFileFunction::OnWriteStarted, 102 base::Bind(&ImageWriterPrivateWriteFromFileFunction::OnWriteStarted,
104 this)); 103 this));
105 return true; 104 return true;
106 } 105 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 image_writer_api::ListRemovableStorageDevices::Results::Create( 193 image_writer_api::ListRemovableStorageDevices::Results::Create(
195 device_list.get()->data); 194 device_list.get()->data);
196 SendResponse(true); 195 SendResponse(true);
197 } else { 196 } else {
198 error_ = image_writer::error::kDeviceListError; 197 error_ = image_writer::error::kDeviceListError;
199 SendResponse(false); 198 SendResponse(false);
200 } 199 }
201 } 200 }
202 201
203 } // namespace extensions 202 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698