Chromium Code Reviews| Index: chromeos/dbus/debug_daemon_client.cc |
| diff --git a/chromeos/dbus/debug_daemon_client.cc b/chromeos/dbus/debug_daemon_client.cc |
| index a101518c25c9f8b63de30690151ec216eaaaf844..10ab9bf7e09a0c1c0ffccd689957915c9f0d50bd 100644 |
| --- a/chromeos/dbus/debug_daemon_client.cc |
| +++ b/chromeos/dbus/debug_daemon_client.cc |
| @@ -460,6 +460,31 @@ class DebugDaemonClientImpl : public DebugDaemonClient { |
| debugdaemon_proxy_->WaitForServiceToBeAvailable(callback); |
| } |
| + void SetOomScoreAdj(const std::map<int, int>& scores, |
| + const SetOomScoreAdjCallback& callback) override { |
| + dbus::MethodCall method_call(debugd::kDebugdInterface, |
| + debugd::kSetOomScoreAdj); |
| + dbus::MessageWriter writer(&method_call); |
| + dbus::MessageWriter sub_writer(NULL); |
|
hashimoto
2016/08/15 03:54:23
Please declare this variable in as local a scope a
cylee1
2016/08/16 19:47:10
Done.
|
| + dbus::MessageWriter elem_writer(NULL); |
|
hashimoto
2016/08/15 03:54:23
ditto.
cylee1
2016/08/16 19:47:10
Done.
|
| + |
| + writer.OpenArray("{ii}", &sub_writer); |
| + for (const auto& entry : scores) { |
| + sub_writer.OpenDictEntry(&elem_writer); |
| + elem_writer.AppendInt32(entry.first); |
| + elem_writer.AppendInt32(entry.second); |
| + sub_writer.CloseContainer(&elem_writer); |
| + } |
| + writer.CloseContainer(&sub_writer); |
| + |
| + debugdaemon_proxy_->CallMethod( |
| + &method_call, |
| + dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| + base::Bind(&DebugDaemonClientImpl::OnSetOomScoreAdj, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + callback)); |
| + } |
| + |
| protected: |
| void Init(dbus::Bus* bus) override { |
| debugdaemon_proxy_ = |
| @@ -720,6 +745,18 @@ class DebugDaemonClientImpl : public DebugDaemonClient { |
| pipe_reader_.reset(); |
| } |
| + void OnSetOomScoreAdj(const SetOomScoreAdjCallback& callback, |
| + dbus::Response* response) { |
| + if (callback.is_null()) |
|
hashimoto
2016/08/15 03:54:23
Is there any strong reason to allow null callbacks
cylee1
2016/08/16 19:47:10
Done.
|
| + return; |
| + |
| + std::string output; |
| + if (response && dbus::MessageReader(response).PopString(&output)) |
| + callback.Run(true, output); |
| + else |
| + callback.Run(false, ""); |
| + } |
| + |
| dbus::ObjectProxy* debugdaemon_proxy_; |
| std::unique_ptr<PipeReaderForString> pipe_reader_; |
| StopAgentTracingCallback callback_; |