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

Side by Side Diff: chrome/browser/chromeos/cros/burn_library.cc

Issue 7891021: Use stub impl when libcros fails to load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix power manager stub impl Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/cros/burn_library.h" 5 #include "chrome/browser/chromeos/cros/burn_library.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 #include "base/memory/linked_ptr.h" 8 #include "base/memory/linked_ptr.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "chrome/common/zip.h" 10 #include "chrome/common/zip.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 friend class base::RefCountedThreadSafe<BurnLibraryTaskProxy>; 82 friend class base::RefCountedThreadSafe<BurnLibraryTaskProxy>;
83 83
84 DISALLOW_COPY_AND_ASSIGN(BurnLibraryTaskProxy); 84 DISALLOW_COPY_AND_ASSIGN(BurnLibraryTaskProxy);
85 }; 85 };
86 86
87 BurnLibraryImpl::BurnLibraryImpl() : unzipping_(false), 87 BurnLibraryImpl::BurnLibraryImpl() : unzipping_(false),
88 cancelled_(false), 88 cancelled_(false),
89 burning_(false), 89 burning_(false),
90 block_burn_signals_(false) { 90 block_burn_signals_(false) {
91 if (CrosLibrary::Get()->EnsureLoaded()) {
92 Init();
93 } else {
94 LOG(ERROR) << "Cros Library has not been loaded";
95 }
96 } 91 }
97 92
98 BurnLibraryImpl::~BurnLibraryImpl() { 93 BurnLibraryImpl::~BurnLibraryImpl() {
99 if (burn_status_connection_) { 94 if (burn_status_connection_) {
100 DisconnectBurnStatus(burn_status_connection_); 95 DisconnectBurnStatus(burn_status_connection_);
101 } 96 }
102 } 97 }
103 98
104 void BurnLibraryImpl::Init() { 99 void BurnLibraryImpl::Init() {
105 burn_status_connection_ = MonitorBurnStatus(&BurnStatusChangedHandler, this); 100 DCHECK(CrosLibrary::Get()->libcros_loaded());
101 burn_status_connection_ =
102 chromeos::MonitorBurnStatus(&BurnStatusChangedHandler, this);
106 } 103 }
107 104
108 void BurnLibraryImpl::AddObserver(Observer* observer) { 105 void BurnLibraryImpl::AddObserver(Observer* observer) {
109 observers_.AddObserver(observer); 106 observers_.AddObserver(observer);
110 if (unzipping_ && !cancelled_) 107 if (unzipping_ && !cancelled_)
111 UpdateBurnStatus(ImageBurnStatus(), UNZIP_STARTED); 108 UpdateBurnStatus(ImageBurnStatus(), UNZIP_STARTED);
112 } 109 }
113 110
114 void BurnLibraryImpl::RemoveObserver(Observer* observer) { 111 void BurnLibraryImpl::RemoveObserver(Observer* observer) {
115 observers_.RemoveObserver(observer); 112 observers_.RemoveObserver(observer);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 FOR_EACH_OBSERVER(Observer, observers_, 244 FOR_EACH_OBSERVER(Observer, observers_,
248 BurnProgressUpdated(this, evt, status)); 245 BurnProgressUpdated(this, evt, status));
249 } 246 }
250 247
251 class BurnLibraryStubImpl : public BurnLibrary { 248 class BurnLibraryStubImpl : public BurnLibrary {
252 public: 249 public:
253 BurnLibraryStubImpl() {} 250 BurnLibraryStubImpl() {}
254 virtual ~BurnLibraryStubImpl() {} 251 virtual ~BurnLibraryStubImpl() {}
255 252
256 // BurnLibrary overrides. 253 // BurnLibrary overrides.
254 virtual void Init() OVERRIDE {}
257 virtual void AddObserver(Observer* observer) OVERRIDE {} 255 virtual void AddObserver(Observer* observer) OVERRIDE {}
258 virtual void RemoveObserver(Observer* observer) OVERRIDE {} 256 virtual void RemoveObserver(Observer* observer) OVERRIDE {}
259 virtual void DoBurn(const FilePath& source_path, 257 virtual void DoBurn(const FilePath& source_path,
260 const std::string& image_name, 258 const std::string& image_name,
261 const FilePath& target_file_path, 259 const FilePath& target_file_path,
262 const FilePath& target_device_path) OVERRIDE { 260 const FilePath& target_device_path) OVERRIDE {
263 } 261 }
264 virtual void CancelBurnImage() OVERRIDE {} 262 virtual void CancelBurnImage() OVERRIDE {}
265 263
266 DISALLOW_COPY_AND_ASSIGN(BurnLibraryStubImpl); 264 DISALLOW_COPY_AND_ASSIGN(BurnLibraryStubImpl);
267 }; 265 };
268 266
269 // static 267 // static
270 BurnLibrary* BurnLibrary::GetImpl(bool stub) { 268 BurnLibrary* BurnLibrary::GetImpl(bool stub) {
269 BurnLibrary* impl;
271 if (stub) 270 if (stub)
272 return new BurnLibraryStubImpl(); 271 impl = new BurnLibraryStubImpl();
273 else 272 else
274 return new BurnLibraryImpl(); 273 impl = new BurnLibraryImpl();
274 impl->Init();
275 return impl;
275 } 276 }
276 277
277 } // namespace chromeos 278 } // namespace chromeos
278 279
279 // Allows InvokeLater without adding refcounting. This class is a Singleton and 280 // Allows InvokeLater without adding refcounting. This class is a Singleton and
280 // won't be deleted until it's last InvokeLater is run. 281 // won't be deleted until it's last InvokeLater is run.
281 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::BurnLibraryImpl); 282 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::BurnLibraryImpl);
282
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698