| 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 "chrome/browser/extensions/api/image_writer_private/error_messages.h" | 5 #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" |
| 6 #include "chrome/browser/extensions/api/image_writer_private/operation.h" | 6 #include "chrome/browser/extensions/api/image_writer_private/operation.h" |
| 7 #include "chromeos/dbus/dbus_thread_manager.h" | 7 #include "chromeos/dbus/dbus_thread_manager.h" |
| 8 #include "chromeos/dbus/image_burner_client.h" | 8 #include "chromeos/dbus/image_burner_client.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 chromeos::DBusThreadManager::Get()-> | 27 chromeos::DBusThreadManager::Get()-> |
| 28 GetImageBurnerClient()-> | 28 GetImageBurnerClient()-> |
| 29 ResetEventHandlers(); | 29 ResetEventHandlers(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 void Operation::Write(const base::Closure& continuation) { | 34 void Operation::Write(const base::Closure& continuation) { |
| 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 35 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 36 SetStage(image_writer_api::STAGE_WRITE); | 36 SetStage(image_writer_api::STAGE_WRITE); |
| 37 | 37 |
| 38 BrowserThread::PostTask( | 38 BrowserThread::PostTask( |
| 39 BrowserThread::UI, | 39 BrowserThread::UI, |
| 40 FROM_HERE, | 40 FROM_HERE, |
| 41 base::Bind(&Operation::StartWriteOnUIThread, this, continuation)); | 41 base::Bind(&Operation::StartWriteOnUIThread, this, continuation)); |
| 42 | 42 |
| 43 AddCleanUpFunction(base::Bind(&ClearImageBurner)); | 43 AddCleanUpFunction(base::Bind(&ClearImageBurner)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void Operation::VerifyWrite(const base::Closure& continuation) { | 46 void Operation::VerifyWrite(const base::Closure& continuation) { |
| 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 47 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 48 | 48 |
| 49 // No verification is available in Chrome OS currently. | 49 // No verification is available in Chrome OS currently. |
| 50 continuation.Run(); | 50 continuation.Run(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void Operation::StartWriteOnUIThread(const base::Closure& continuation) { | 53 void Operation::StartWriteOnUIThread(const base::Closure& continuation) { |
| 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 55 | 55 |
| 56 ImageBurnerClient* burner = | 56 ImageBurnerClient* burner = |
| 57 chromeos::DBusThreadManager::Get()->GetImageBurnerClient(); | 57 chromeos::DBusThreadManager::Get()->GetImageBurnerClient(); |
| 58 | 58 |
| 59 burner->SetEventHandlers( | 59 burner->SetEventHandlers( |
| 60 base::Bind(&Operation::OnBurnFinished, this, continuation), | 60 base::Bind(&Operation::OnBurnFinished, this, continuation), |
| 61 base::Bind(&Operation::OnBurnProgress, this)); | 61 base::Bind(&Operation::OnBurnProgress, this)); |
| 62 | 62 |
| 63 burner->BurnImage(image_path_.value(), | 63 burner->BurnImage(image_path_.value(), |
| 64 device_path_.value(), | 64 device_path_.value(), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 84 int progress = kProgressComplete * num_bytes_burnt / total_size; | 84 int progress = kProgressComplete * num_bytes_burnt / total_size; |
| 85 SetProgress(progress); | 85 SetProgress(progress); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void Operation::OnBurnError() { | 88 void Operation::OnBurnError() { |
| 89 Error(error::kChromeOSImageBurnerError); | 89 Error(error::kChromeOSImageBurnerError); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace image_writer | 92 } // namespace image_writer |
| 93 } // namespace extensions | 93 } // namespace extensions |
| OLD | NEW |