| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 6 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
| 7 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope
ration.h" | 7 #include "chrome/browser/extensions/api/image_writer_private/write_from_file_ope
ration.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 | 9 |
| 10 namespace extensions { | 10 namespace extensions { |
| 11 namespace image_writer { | 11 namespace image_writer { |
| 12 | 12 |
| 13 using content::BrowserThread; | 13 using content::BrowserThread; |
| 14 | 14 |
| 15 WriteFromFileOperation::WriteFromFileOperation( | 15 WriteFromFileOperation::WriteFromFileOperation( |
| 16 base::WeakPtr<OperationManager> manager, | 16 base::WeakPtr<OperationManager> manager, |
| 17 const ExtensionId& extension_id, | 17 const ExtensionId& extension_id, |
| 18 const base::FilePath& path, | 18 const base::FilePath& user_file_path, |
| 19 const std::string& storage_unit_id) | 19 const std::string& device_path) |
| 20 : Operation(manager, extension_id, storage_unit_id) { | 20 : Operation(manager, extension_id, device_path) { |
| 21 image_path_ = path; | 21 image_path_ = user_file_path; |
| 22 } | 22 } |
| 23 | 23 |
| 24 WriteFromFileOperation::~WriteFromFileOperation() { | 24 WriteFromFileOperation::~WriteFromFileOperation() {} |
| 25 } | |
| 26 | 25 |
| 27 void WriteFromFileOperation::Start() { | 26 void WriteFromFileOperation::StartImpl() { |
| 28 DVLOG(1) << "Starting file-to-usb write of " << image_path_.value() | |
| 29 << " to " << storage_unit_id_; | |
| 30 | |
| 31 if (!base::PathExists(image_path_) || base::DirectoryExists(image_path_)) { | 27 if (!base::PathExists(image_path_) || base::DirectoryExists(image_path_)) { |
| 28 DLOG(ERROR) << "Source must exist and not be a directory."; |
| 32 Error(error::kImageInvalid); | 29 Error(error::kImageInvalid); |
| 33 return; | 30 return; |
| 34 } | 31 } |
| 35 | 32 |
| 36 WriteStart(); | 33 Unzip(base::Bind( |
| 34 &WriteFromFileOperation::Write, |
| 35 this, |
| 36 base::Bind(&WriteFromFileOperation::VerifyWrite, |
| 37 this, |
| 38 base::Bind(&WriteFromFileOperation::Finish, this)))); |
| 37 } | 39 } |
| 38 | 40 |
| 39 } // namespace image_writer | 41 } // namespace image_writer |
| 40 } // namespace extensions | 42 } // namespace extensions |
| OLD | NEW |