| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/threading/worker_pool.h" | 9 #include "base/threading/worker_pool.h" |
| 10 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 10 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 SetStage(image_writer_api::STAGE_WRITE); | 26 SetStage(image_writer_api::STAGE_WRITE); |
| 27 StartUtilityClient(); | 27 StartUtilityClient(); |
| 28 | 28 |
| 29 int64_t file_size; | 29 int64_t file_size; |
| 30 if (!base::GetFileSize(image_path_, &file_size)) { | 30 if (!base::GetFileSize(image_path_, &file_size)) { |
| 31 Error(error::kImageReadError); | 31 Error(error::kImageReadError); |
| 32 return; | 32 return; |
| 33 } | 33 } |
| 34 | 34 |
| 35 BrowserThread::PostTask( | 35 image_writer_client_->Write( |
| 36 BrowserThread::IO, | 36 base::Bind(&Operation::WriteImageProgress, this, file_size), |
| 37 FROM_HERE, | 37 base::Bind(&Operation::CompleteAndContinue, this, continuation), |
| 38 base::Bind( | 38 base::Bind(&Operation::Error, this), image_path_, device_path_); |
| 39 &ImageWriterUtilityClient::Write, | |
| 40 image_writer_client_, | |
| 41 base::Bind(&Operation::WriteImageProgress, this, file_size), | |
| 42 base::Bind(&Operation::CompleteAndContinue, this, continuation), | |
| 43 base::Bind(&Operation::Error, this), | |
| 44 image_path_, | |
| 45 device_path_)); | |
| 46 } | 39 } |
| 47 | 40 |
| 48 void Operation::VerifyWrite(const base::Closure& continuation) { | 41 void Operation::VerifyWrite(const base::Closure& continuation) { |
| 49 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 42 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 50 | 43 |
| 51 if (IsCancelled()) { | 44 if (IsCancelled()) { |
| 52 return; | 45 return; |
| 53 } | 46 } |
| 54 | 47 |
| 55 SetStage(image_writer_api::STAGE_VERIFYWRITE); | 48 SetStage(image_writer_api::STAGE_VERIFYWRITE); |
| 56 StartUtilityClient(); | 49 StartUtilityClient(); |
| 57 | 50 |
| 58 int64_t file_size; | 51 int64_t file_size; |
| 59 if (!base::GetFileSize(image_path_, &file_size)) { | 52 if (!base::GetFileSize(image_path_, &file_size)) { |
| 60 Error(error::kImageReadError); | 53 Error(error::kImageReadError); |
| 61 return; | 54 return; |
| 62 } | 55 } |
| 63 | 56 |
| 64 BrowserThread::PostTask( | 57 image_writer_client_->Verify( |
| 65 BrowserThread::IO, | 58 base::Bind(&Operation::WriteImageProgress, this, file_size), |
| 66 FROM_HERE, | 59 base::Bind(&Operation::CompleteAndContinue, this, continuation), |
| 67 base::Bind( | 60 base::Bind(&Operation::Error, this), image_path_, device_path_); |
| 68 &ImageWriterUtilityClient::Verify, | |
| 69 image_writer_client_, | |
| 70 base::Bind(&Operation::WriteImageProgress, this, file_size), | |
| 71 base::Bind(&Operation::CompleteAndContinue, this, continuation), | |
| 72 base::Bind(&Operation::Error, this), | |
| 73 image_path_, | |
| 74 device_path_)); | |
| 75 } | 61 } |
| 76 | 62 |
| 77 } // namespace image_writer | 63 } // namespace image_writer |
| 78 } // namespace extensions | 64 } // namespace extensions |
| OLD | NEW |