Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: chrome/browser/extensions/api/image_writer_private/operation_chromeos.cc

Issue 170123002: Revert of Significantly cleans up the ImageWriter Operation class and subclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 return; 24 return;
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::WriteStart() {
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
36 SetStage(image_writer_api::STAGE_WRITE); 36 SetStage(image_writer_api::STAGE_WRITE);
37 37
38 BrowserThread::PostTask( 38 BrowserThread::PostTask(BrowserThread::UI,
39 BrowserThread::UI, 39 FROM_HERE,
40 FROM_HERE, 40 base::Bind(&Operation::StartWriteOnUIThread, this));
41 base::Bind(&Operation::StartWriteOnUIThread, this, continuation));
42 41
43 AddCleanUpFunction(base::Bind(&ClearImageBurner)); 42 AddCleanUpFunction(base::Bind(&ClearImageBurner));
44 } 43 }
45 44
46 void Operation::VerifyWrite(const base::Closure& continuation) { 45 void Operation::StartWriteOnUIThread() {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
48
49 // No verification is available in Chrome OS currently.
50 continuation.Run();
51 }
52
53 void Operation::StartWriteOnUIThread(const base::Closure& continuation) {
54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
47 DVLOG(1) << "Starting burn.";
55 48
56 ImageBurnerClient* burner = 49 ImageBurnerClient* burner =
57 chromeos::DBusThreadManager::Get()->GetImageBurnerClient(); 50 chromeos::DBusThreadManager::Get()->GetImageBurnerClient();
58 51
59 burner->SetEventHandlers( 52 burner->SetEventHandlers(
60 base::Bind(&Operation::OnBurnFinished, this, continuation), 53 base::Bind(&Operation::OnBurnFinished, this),
61 base::Bind(&Operation::OnBurnProgress, this)); 54 base::Bind(&Operation::OnBurnProgress, this));
62 55
63 burner->BurnImage(image_path_.value(), 56 burner->BurnImage(image_path_.value(),
64 device_path_.value(), 57 storage_unit_id_,
65 base::Bind(&Operation::OnBurnError, this)); 58 base::Bind(&Operation::OnBurnError, this));
66 } 59 }
67 60
68 void Operation::OnBurnFinished(const base::Closure& continuation, 61 void Operation::OnBurnFinished(const std::string& target_path,
69 const std::string& target_path, 62 bool success,
70 bool success, 63 const std::string& error) {
71 const std::string& error) { 64 DVLOG(1) << "Burn finished: " << success;
65
72 if (success) { 66 if (success) {
73 SetProgress(kProgressComplete); 67 SetProgress(kProgressComplete);
74 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, continuation); 68 Finish();
75 } else { 69 } else {
76 DLOG(ERROR) << "Error encountered while burning: " << error; 70 Error(error);
77 Error(error::kChromeOSImageBurnerError);
78 } 71 }
79 } 72 }
80 73
81 void Operation::OnBurnProgress(const std::string& target_path, 74 void Operation::OnBurnProgress(const std::string& target_path,
82 int64 num_bytes_burnt, 75 int64 num_bytes_burnt,
83 int64 total_size) { 76 int64 total_size) {
84 int progress = kProgressComplete * num_bytes_burnt / total_size; 77 int progress = kProgressComplete * num_bytes_burnt / total_size;
85 SetProgress(progress); 78 SetProgress(progress);
86 } 79 }
87 80
88 void Operation::OnBurnError() { 81 void Operation::OnBurnError() {
89 Error(error::kChromeOSImageBurnerError); 82 Error(error::kChromeOSImageBurnerError);
90 } 83 }
91 84
92 } // namespace image_writer 85 } // namespace image_writer
93 } // namespace extensions 86 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698