| 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" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "chromeos/chromeos_switches.h" | 12 #include "chromeos/chromeos_switches.h" |
| 13 #include "dbus/bus.h" | 13 #include "dbus/bus.h" |
| 14 #include "dbus/message.h" | 14 #include "dbus/message.h" |
| 15 #include "dbus/object_path.h" | 15 #include "dbus/object_path.h" |
| 16 #include "dbus/object_proxy.h" | 16 #include "dbus/object_proxy.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 const std::string UpdateEngineClient::kReleaseChannelDev = "dev-channel"; |
| 22 const std::string UpdateEngineClient::kReleaseChannelBeta = "beta-channel"; |
| 23 const std::string UpdateEngineClient::kReleaseChannelStable = "stable-channel"; |
| 24 |
| 21 namespace { | 25 namespace { |
| 22 | 26 |
| 23 const char kReleaseChannelDev[] = "dev-channel"; | 27 const std::string kRawReleaseChannelsList[] = { |
| 24 const char kReleaseChannelBeta[] = "beta-channel"; | 28 UpdateEngineClient::kReleaseChannelDev, |
| 25 const char kReleaseChannelStable[] = "stable-channel"; | 29 UpdateEngineClient::kReleaseChannelBeta, |
| 30 UpdateEngineClient::kReleaseChannelStable}; |
| 31 |
| 32 } // namespace |
| 33 |
| 34 const std::vector<std::string> UpdateEngineClient::kReleaseChannelsList( |
| 35 kRawReleaseChannelsList, |
| 36 kRawReleaseChannelsList + arraysize(kRawReleaseChannelsList)); |
| 37 |
| 38 namespace { |
| 26 | 39 |
| 27 // Delay between successive state transitions during AU. | 40 // Delay between successive state transitions during AU. |
| 28 const int kStateTransitionDefaultDelayMs = 3000; | 41 const int kStateTransitionDefaultDelayMs = 3000; |
| 29 | 42 |
| 30 // Delay between successive notifications about downloading progress | 43 // Delay between successive notifications about downloading progress |
| 31 // during fake AU. | 44 // during fake AU. |
| 32 const int kStateTransitionDownloadingDelayMs = 250; | 45 const int kStateTransitionDownloadingDelayMs = 250; |
| 33 | 46 |
| 34 // Size of parts of a "new" image which are downloaded each | 47 // Size of parts of a "new" image which are downloaded each |
| 35 // |kStateTransitionDownloadingDelayMs| during fake AU. | 48 // |kStateTransitionDownloadingDelayMs| during fake AU. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 59 return UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK; | 72 return UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK; |
| 60 return UpdateEngineClient::UPDATE_STATUS_ERROR; | 73 return UpdateEngineClient::UPDATE_STATUS_ERROR; |
| 61 } | 74 } |
| 62 | 75 |
| 63 // Used in UpdateEngineClient::EmptyUpdateCheckCallback(). | 76 // Used in UpdateEngineClient::EmptyUpdateCheckCallback(). |
| 64 void EmptyUpdateCheckCallbackBody( | 77 void EmptyUpdateCheckCallbackBody( |
| 65 UpdateEngineClient::UpdateCheckResult unused_result) { | 78 UpdateEngineClient::UpdateCheckResult unused_result) { |
| 66 } | 79 } |
| 67 | 80 |
| 68 bool IsValidChannel(const std::string& channel) { | 81 bool IsValidChannel(const std::string& channel) { |
| 69 return channel == kReleaseChannelDev || | 82 return channel == UpdateEngineClient::kReleaseChannelDev || |
| 70 channel == kReleaseChannelBeta || | 83 channel == UpdateEngineClient::kReleaseChannelBeta || |
| 71 channel == kReleaseChannelStable; | 84 channel == UpdateEngineClient::kReleaseChannelStable; |
| 72 } | 85 } |
| 73 | 86 |
| 74 } // namespace | 87 } // namespace |
| 75 | 88 |
| 76 // The UpdateEngineClient implementation used in production. | 89 // The UpdateEngineClient implementation used in production. |
| 77 class UpdateEngineClientImpl : public UpdateEngineClient { | 90 class UpdateEngineClientImpl : public UpdateEngineClient { |
| 78 public: | 91 public: |
| 79 UpdateEngineClientImpl() | 92 UpdateEngineClientImpl() |
| 80 : update_engine_proxy_(NULL), last_status_(), weak_ptr_factory_(this) {} | 93 : update_engine_proxy_(NULL), last_status_(), weak_ptr_factory_(this) {} |
| 81 | 94 |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 568 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 556 return new UpdateEngineClientImpl(); | 569 return new UpdateEngineClientImpl(); |
| 557 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 570 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 558 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestAutoUpdateUI)) | 571 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestAutoUpdateUI)) |
| 559 return new UpdateEngineClientFakeImpl(); | 572 return new UpdateEngineClientFakeImpl(); |
| 560 else | 573 else |
| 561 return new UpdateEngineClientStubImpl(); | 574 return new UpdateEngineClientStubImpl(); |
| 562 } | 575 } |
| 563 | 576 |
| 564 } // namespace chromeos | 577 } // namespace chromeos |
| OLD | NEW |