Chromium Code Reviews| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 216 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 217 base::Bind(&UpdateEngineClientImpl::OnGetEolStatus, | 217 base::Bind(&UpdateEngineClientImpl::OnGetEolStatus, |
| 218 weak_ptr_factory_.GetWeakPtr(), callback)); | 218 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 protected: | 221 protected: |
| 222 void Init(dbus::Bus* bus) override { | 222 void Init(dbus::Bus* bus) override { |
| 223 update_engine_proxy_ = bus->GetObjectProxy( | 223 update_engine_proxy_ = bus->GetObjectProxy( |
| 224 update_engine::kUpdateEngineServiceName, | 224 update_engine::kUpdateEngineServiceName, |
| 225 dbus::ObjectPath(update_engine::kUpdateEngineServicePath)); | 225 dbus::ObjectPath(update_engine::kUpdateEngineServicePath)); |
| 226 | |
| 227 // Monitor the D-Bus signal for brightness changes. Only the power | |
| 228 // manager knows the actual brightness level. We don't cache the | |
| 229 // brightness level in Chrome as it will make things less reliable. | |
|
Daniel Erat
2016/08/10 21:56:18
hmm, i wonder where this code was copy-and-pasted
stevenjb
2016/08/10 22:24:21
Heh.
| |
| 230 update_engine_proxy_->ConnectToSignal( | 226 update_engine_proxy_->ConnectToSignal( |
| 231 update_engine::kUpdateEngineInterface, | 227 update_engine::kUpdateEngineInterface, |
| 232 update_engine::kStatusUpdate, | 228 update_engine::kStatusUpdate, |
| 233 base::Bind(&UpdateEngineClientImpl::StatusUpdateReceived, | 229 base::Bind(&UpdateEngineClientImpl::StatusUpdateReceived, |
| 234 weak_ptr_factory_.GetWeakPtr()), | 230 weak_ptr_factory_.GetWeakPtr()), |
| 235 base::Bind(&UpdateEngineClientImpl::StatusUpdateConnected, | 231 base::Bind(&UpdateEngineClientImpl::StatusUpdateConnected, |
| 236 weak_ptr_factory_.GetWeakPtr())); | 232 weak_ptr_factory_.GetWeakPtr())); |
| 237 | 233 update_engine_proxy_->WaitForServiceToBeAvailable( |
| 238 // Get update engine status for the initial status. Update engine won't | 234 base::Bind(&UpdateEngineClientImpl::OnProxyAvailabilityChanged, |
| 239 // send StatusUpdate signal unless there is a status change. If chrome | 235 weak_ptr_factory_.GetWeakPtr())); |
| 240 // crashes after UPDATE_STATUS_UPDATED_NEED_REBOOT status is set, | |
| 241 // restarted chrome would not get this status. See crbug.com/154104. | |
| 242 GetUpdateEngineStatus(); | |
| 243 } | 236 } |
| 244 | 237 |
| 245 private: | 238 private: |
| 239 void OnProxyAvailabilityChanged(bool service_is_available) { | |
|
Daniel Erat
2016/08/11 01:13:50
i misunderstood how WaitForServiceToBeAvailable ac
| |
| 240 if (service_is_available) { | |
| 241 // Get update engine status for the initial status. Update engine won't | |
| 242 // send StatusUpdate signal unless there is a status change. If chrome | |
| 243 // crashes after UPDATE_STATUS_UPDATED_NEED_REBOOT status is set, | |
| 244 // restarted chrome would not get this status. See crbug.com/154104. | |
| 245 GetUpdateEngineStatus(); | |
| 246 } | |
| 247 } | |
| 248 | |
| 246 void GetUpdateEngineStatus() { | 249 void GetUpdateEngineStatus() { |
| 247 dbus::MethodCall method_call( | 250 dbus::MethodCall method_call( |
| 248 update_engine::kUpdateEngineInterface, | 251 update_engine::kUpdateEngineInterface, |
| 249 update_engine::kGetStatus); | 252 update_engine::kGetStatus); |
| 250 update_engine_proxy_->CallMethodWithErrorCallback( | 253 update_engine_proxy_->CallMethodWithErrorCallback( |
| 251 &method_call, | 254 &method_call, |
| 252 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 255 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 253 base::Bind(&UpdateEngineClientImpl::OnGetStatus, | 256 base::Bind(&UpdateEngineClientImpl::OnGetStatus, |
| 254 weak_ptr_factory_.GetWeakPtr()), | 257 weak_ptr_factory_.GetWeakPtr()), |
| 255 base::Bind(&UpdateEngineClientImpl::OnGetStatusError, | 258 base::Bind(&UpdateEngineClientImpl::OnGetStatusError, |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 const char** cix = std::find( | 613 const char** cix = std::find( |
| 611 kReleaseChannelsList, | 614 kReleaseChannelsList, |
| 612 kReleaseChannelsList + arraysize(kReleaseChannelsList), current_channel); | 615 kReleaseChannelsList + arraysize(kReleaseChannelsList), current_channel); |
| 613 const char** tix = std::find( | 616 const char** tix = std::find( |
| 614 kReleaseChannelsList, | 617 kReleaseChannelsList, |
| 615 kReleaseChannelsList + arraysize(kReleaseChannelsList), target_channel); | 618 kReleaseChannelsList + arraysize(kReleaseChannelsList), target_channel); |
| 616 return tix > cix; | 619 return tix > cix; |
| 617 } | 620 } |
| 618 | 621 |
| 619 } // namespace chromeos | 622 } // namespace chromeos |
| OLD | NEW |