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