Chromium Code Reviews| Index: chromeos/dbus/update_engine_client.cc |
| diff --git a/chromeos/dbus/update_engine_client.cc b/chromeos/dbus/update_engine_client.cc |
| index d13ddcaeb46dfa48a75efa249b1d8c1df0ab9032..c658ac6c5d7fe6d327fab409262f6cf4eaf6344f 100644 |
| --- a/chromeos/dbus/update_engine_client.cc |
| +++ b/chromeos/dbus/update_engine_client.cc |
| @@ -162,6 +162,44 @@ class UpdateEngineClientImpl : public UpdateEngineClient { |
| return last_status_; |
| } |
| + // UpdateEngineClient override. |
| + virtual void SetChannel(const std::string& target_channel, |
| + bool is_powerwash_allowed) OVERRIDE { |
| + dbus::MethodCall method_call( |
|
Nikita (slow)
2013/06/21 12:21:33
Check somewhere that target_channel value is valid
ygorshenin1
2013/06/21 17:24:58
Done, enum constants will be added in a separate C
|
| + update_engine::kUpdateEngineInterface, |
| + update_engine::kSetChannel); |
| + dbus::MessageWriter writer(&method_call); |
| + writer.AppendString(target_channel); |
| + writer.AppendBool(is_powerwash_allowed); |
| + VLOG(1) << "Requesting to set channel: " |
| + << "target_channel=" << target_channel << ", " |
| + << "is_powerwash_allowed=" << is_powerwash_allowed; |
| + update_engine_proxy_->CallMethod( |
| + &method_call, |
| + dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| + base::Bind(&UpdateEngineClientImpl::OnSetChannel, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| + |
| + // UpdateEngineClient override. |
| + virtual void GetChannel(bool get_current_channel, |
| + const GetChannelCallback& callback) OVERRIDE { |
| + dbus::MethodCall method_call( |
| + update_engine::kUpdateEngineInterface, |
| + update_engine::kGetChannel); |
| + dbus::MessageWriter writer(&method_call); |
| + writer.AppendBool(get_current_channel); |
| + |
|
Nikita (slow)
2013/06/21 12:21:33
nit: drop empty line
ygorshenin1
2013/06/21 17:24:58
All other methods in this file have an empty line
|
| + VLOG(1) << "Requesting to get channel, get_current_channel=" |
| + << get_current_channel; |
| + update_engine_proxy_->CallMethod( |
| + &method_call, |
| + dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| + base::Bind(&UpdateEngineClientImpl::OnGetChannel, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + callback)); |
| + } |
| + |
| private: |
| void GetUpdateEngineStatus() { |
| dbus::MethodCall method_call( |
| @@ -251,6 +289,34 @@ class UpdateEngineClientImpl : public UpdateEngineClient { |
| LOG(ERROR) << "GetStatus request failed with error: " << error->ToString(); |
| } |
| + // Called when a response for SetReleaseTrack() is received. |
| + void OnSetChannel(dbus::Response* response) { |
| + if (!response) { |
| + LOG(ERROR) << "Failed to request setting channel"; |
| + return; |
| + } |
| + LOG(ERROR) << "Succeeded to set channel"; |
| + } |
| + |
| + // Called when a response for GetChannel() is received. |
| + void OnGetChannel(const GetReleaseTrackCallback& callback, |
| + dbus::Response* response) { |
| + if (!response) { |
| + LOG(ERROR) << "Failed to request getting channel"; |
| + callback.Run(""); |
| + return; |
| + } |
| + dbus::MessageReader reader(response); |
| + std::string channel; |
| + if (!reader.PopString(&channel)) { |
| + LOG(ERROR) << "Incorrect response: " << response->ToString(); |
| + callback.Run(""); |
| + return; |
| + } |
| + VLOG(1) << "The channel received: " << channel; |
| + callback.Run(channel); |
| + } |
| + |
| // Called when a status update signal is received. |
| void StatusUpdateReceived(dbus::Signal* signal) { |
| VLOG(1) << "Status update signal received: " << signal->ToString(); |
| @@ -318,6 +384,18 @@ class UpdateEngineClientStubImpl : public UpdateEngineClient { |
| callback.Run("beta-channel"); |
| } |
| virtual Status GetLastStatus() OVERRIDE { return Status(); } |
| + virtual void SetChannel(const std::string& target_channel, |
| + bool is_powerwash_allowed) OVERRIDE { |
| + LOG(ERROR) << "Requesting to set channel: " |
|
Nikita (slow)
2013/06/21 12:21:33
LOG(INFO)?
ygorshenin1
2013/06/21 17:24:59
Done.
|
| + << "target_channel=" << target_channel << ", " |
| + << "is_powerwash_allowed=" << is_powerwash_allowed; |
| + } |
| + virtual void GetChannel(bool get_current_channel, |
| + const GetChannelCallback& callback) OVERRIDE { |
| + LOG(ERROR) << "Requesting to get channel, get_current_channel=" |
|
Nikita (slow)
2013/06/21 12:21:33
LOG(INFO)?
ygorshenin1
2013/06/21 17:24:59
Done.
|
| + << get_current_channel; |
| + callback.Run("beta-channel"); |
| + } |
| }; |
| UpdateEngineClient::UpdateEngineClient() { |