OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/dbus/update_engine_client.h" | 5 #include "chromeos/dbus/update_engine_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 // Note: This should remain the last member so it'll be destroyed and | 389 // Note: This should remain the last member so it'll be destroyed and |
390 // invalidate its weak pointers before any other members are destroyed. | 390 // invalidate its weak pointers before any other members are destroyed. |
391 base::WeakPtrFactory<UpdateEngineClientImpl> weak_ptr_factory_; | 391 base::WeakPtrFactory<UpdateEngineClientImpl> weak_ptr_factory_; |
392 | 392 |
393 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClientImpl); | 393 DISALLOW_COPY_AND_ASSIGN(UpdateEngineClientImpl); |
394 }; | 394 }; |
395 | 395 |
396 // The UpdateEngineClient implementation used on Linux desktop, | 396 // The UpdateEngineClient implementation used on Linux desktop, |
397 // which does nothing. | 397 // which does nothing. |
398 class UpdateEngineClientStubImpl : public UpdateEngineClient { | 398 class UpdateEngineClientStubImpl : public UpdateEngineClient { |
| 399 public: |
| 400 UpdateEngineClientStubImpl() |
| 401 : current_channel_(kReleaseChannelBeta), |
| 402 target_channel_(kReleaseChannelBeta) {} |
| 403 |
399 // UpdateEngineClient implementation: | 404 // UpdateEngineClient implementation: |
400 virtual void Init(dbus::Bus* bus) OVERRIDE {} | 405 virtual void Init(dbus::Bus* bus) OVERRIDE {} |
401 virtual void AddObserver(Observer* observer) OVERRIDE {} | 406 virtual void AddObserver(Observer* observer) OVERRIDE {} |
402 virtual void RemoveObserver(Observer* observer) OVERRIDE {} | 407 virtual void RemoveObserver(Observer* observer) OVERRIDE {} |
403 virtual bool HasObserver(Observer* observer) OVERRIDE { return false; } | 408 virtual bool HasObserver(Observer* observer) OVERRIDE { return false; } |
404 | 409 |
405 virtual void RequestUpdateCheck( | 410 virtual void RequestUpdateCheck( |
406 const UpdateCheckCallback& callback) OVERRIDE { | 411 const UpdateCheckCallback& callback) OVERRIDE { |
407 callback.Run(UPDATE_RESULT_NOTIMPLEMENTED); | 412 callback.Run(UPDATE_RESULT_NOTIMPLEMENTED); |
408 } | 413 } |
409 virtual void RebootAfterUpdate() OVERRIDE {} | 414 virtual void RebootAfterUpdate() OVERRIDE {} |
410 virtual void Rollback() OVERRIDE {} | 415 virtual void Rollback() OVERRIDE {} |
411 virtual void CanRollbackCheck( | 416 virtual void CanRollbackCheck( |
412 const RollbackCheckCallback& callback) OVERRIDE { | 417 const RollbackCheckCallback& callback) OVERRIDE { |
413 callback.Run(true); | 418 callback.Run(true); |
414 } | 419 } |
415 virtual Status GetLastStatus() OVERRIDE { return Status(); } | 420 virtual Status GetLastStatus() OVERRIDE { return Status(); } |
416 virtual void SetChannel(const std::string& target_channel, | 421 virtual void SetChannel(const std::string& target_channel, |
417 bool is_powerwash_allowed) OVERRIDE { | 422 bool is_powerwash_allowed) OVERRIDE { |
418 VLOG(1) << "Requesting to set channel: " | 423 VLOG(1) << "Requesting to set channel: " |
419 << "target_channel=" << target_channel << ", " | 424 << "target_channel=" << target_channel << ", " |
420 << "is_powerwash_allowed=" << is_powerwash_allowed; | 425 << "is_powerwash_allowed=" << is_powerwash_allowed; |
| 426 target_channel_ = target_channel; |
421 } | 427 } |
422 virtual void GetChannel(bool get_current_channel, | 428 virtual void GetChannel(bool get_current_channel, |
423 const GetChannelCallback& callback) OVERRIDE { | 429 const GetChannelCallback& callback) OVERRIDE { |
424 VLOG(1) << "Requesting to get channel, get_current_channel=" | 430 VLOG(1) << "Requesting to get channel, get_current_channel=" |
425 << get_current_channel; | 431 << get_current_channel; |
426 callback.Run(kReleaseChannelBeta); | 432 if (get_current_channel) |
| 433 callback.Run(current_channel_); |
| 434 else |
| 435 callback.Run(target_channel_); |
427 } | 436 } |
| 437 |
| 438 std::string current_channel_; |
| 439 std::string target_channel_; |
428 }; | 440 }; |
429 | 441 |
430 // The UpdateEngineClient implementation used on Linux desktop, which | 442 // The UpdateEngineClient implementation used on Linux desktop, which |
431 // tries to emulate real update engine client. | 443 // tries to emulate real update engine client. |
432 class UpdateEngineClientFakeImpl : public UpdateEngineClientStubImpl { | 444 class UpdateEngineClientFakeImpl : public UpdateEngineClientStubImpl { |
433 public: | 445 public: |
434 UpdateEngineClientFakeImpl() : weak_factory_(this) { | 446 UpdateEngineClientFakeImpl() : weak_factory_(this) { |
435 } | 447 } |
436 | 448 |
437 virtual ~UpdateEngineClientFakeImpl() { | 449 virtual ~UpdateEngineClientFakeImpl() { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 555 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
544 return new UpdateEngineClientImpl(); | 556 return new UpdateEngineClientImpl(); |
545 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 557 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
546 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestAutoUpdateUI)) | 558 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestAutoUpdateUI)) |
547 return new UpdateEngineClientFakeImpl(); | 559 return new UpdateEngineClientFakeImpl(); |
548 else | 560 else |
549 return new UpdateEngineClientStubImpl(); | 561 return new UpdateEngineClientStubImpl(); |
550 } | 562 } |
551 | 563 |
552 } // namespace chromeos | 564 } // namespace chromeos |
OLD | NEW |