| 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 "chrome/utility/image_writer/image_writer_handler.h" |
| 6 |
| 5 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 6 #include "chrome/common/chrome_utility_messages.h" | 8 #include "chrome/common/chrome_utility_messages.h" |
| 7 #include "chrome/utility/image_writer/error_messages.h" | 9 #include "chrome/utility/image_writer/error_messages.h" |
| 8 #include "chrome/utility/image_writer/image_writer_handler.h" | |
| 9 #include "content/public/utility/utility_thread.h" | 10 #include "content/public/utility/utility_thread.h" |
| 10 | 11 |
| 11 namespace image_writer { | 12 namespace image_writer { |
| 12 | 13 |
| 13 ImageWriterHandler::ImageWriterHandler() {} | 14 ImageWriterHandler::ImageWriterHandler() {} |
| 14 ImageWriterHandler::~ImageWriterHandler() {} | 15 ImageWriterHandler::~ImageWriterHandler() {} |
| 15 | 16 |
| 16 void ImageWriterHandler::SendSucceeded() { | 17 void ImageWriterHandler::SendSucceeded() { |
| 17 Send(new ChromeUtilityHostMsg_ImageWriter_Succeeded()); | 18 Send(new ChromeUtilityHostMsg_ImageWriter_Succeeded()); |
| 18 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | 19 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if (image_writer_->IsRunning()) { | 58 if (image_writer_->IsRunning()) { |
| 58 SendFailed(error::kOperationAlreadyInProgress); | 59 SendFailed(error::kOperationAlreadyInProgress); |
| 59 return; | 60 return; |
| 60 } | 61 } |
| 61 | 62 |
| 62 if (!image_writer_->IsValidDevice()) { | 63 if (!image_writer_->IsValidDevice()) { |
| 63 SendFailed(error::kInvalidDevice); | 64 SendFailed(error::kInvalidDevice); |
| 64 return; | 65 return; |
| 65 } | 66 } |
| 66 | 67 |
| 67 if (!image_writer_->UnmountVolumes()) { | 68 image_writer_->UnmountVolumes( |
| 68 SendFailed(error::kUnmountVolumes); | 69 base::Bind(&ImageWriter::Write, image_writer_->AsWeakPtr())); |
| 69 return; | |
| 70 } | |
| 71 | |
| 72 image_writer_->Write(); | |
| 73 } | 70 } |
| 74 | 71 |
| 75 void ImageWriterHandler::OnVerifyStart(const base::FilePath& image, | 72 void ImageWriterHandler::OnVerifyStart(const base::FilePath& image, |
| 76 const base::FilePath& device) { | 73 const base::FilePath& device) { |
| 77 if (!image_writer_.get() || image != image_writer_->GetImagePath() || | 74 if (!image_writer_.get() || image != image_writer_->GetImagePath() || |
| 78 device != image_writer_->GetDevicePath()) { | 75 device != image_writer_->GetDevicePath()) { |
| 79 image_writer_.reset(new ImageWriter(this, image, device)); | 76 image_writer_.reset(new ImageWriter(this, image, device)); |
| 80 } | 77 } |
| 81 | 78 |
| 82 if (image_writer_->IsRunning()) { | 79 if (image_writer_->IsRunning()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 94 | 91 |
| 95 void ImageWriterHandler::OnCancel() { | 92 void ImageWriterHandler::OnCancel() { |
| 96 if (image_writer_.get()) { | 93 if (image_writer_.get()) { |
| 97 image_writer_->Cancel(); | 94 image_writer_->Cancel(); |
| 98 } else { | 95 } else { |
| 99 SendCancelled(); | 96 SendCancelled(); |
| 100 } | 97 } |
| 101 } | 98 } |
| 102 | 99 |
| 103 } // namespace image_writer | 100 } // namespace image_writer |
| OLD | NEW |