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& user_file_path, | 18 const base::FilePath& path, |
19 const std::string& device_path) | 19 const std::string& storage_unit_id) |
20 : Operation(manager, extension_id, device_path) { | 20 : Operation(manager, extension_id, storage_unit_id) { |
21 image_path_ = user_file_path; | 21 image_path_ = path; |
22 } | 22 } |
23 | 23 |
24 WriteFromFileOperation::~WriteFromFileOperation() {} | 24 WriteFromFileOperation::~WriteFromFileOperation() { |
| 25 } |
25 | 26 |
26 void WriteFromFileOperation::StartImpl() { | 27 void WriteFromFileOperation::Start() { |
| 28 DVLOG(1) << "Starting file-to-usb write of " << image_path_.value() |
| 29 << " to " << storage_unit_id_; |
| 30 |
27 if (!base::PathExists(image_path_) || base::DirectoryExists(image_path_)) { | 31 if (!base::PathExists(image_path_) || base::DirectoryExists(image_path_)) { |
28 DLOG(ERROR) << "Source must exist and not be a directory."; | |
29 Error(error::kImageInvalid); | 32 Error(error::kImageInvalid); |
30 return; | 33 return; |
31 } | 34 } |
32 | 35 |
33 Unzip(base::Bind( | 36 WriteStart(); |
34 &WriteFromFileOperation::Write, | |
35 this, | |
36 base::Bind(&WriteFromFileOperation::VerifyWrite, | |
37 this, | |
38 base::Bind(&WriteFromFileOperation::Finish, this)))); | |
39 } | 37 } |
40 | 38 |
41 } // namespace image_writer | 39 } // namespace image_writer |
42 } // namespace extensions | 40 } // namespace extensions |
OLD | NEW |