OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/host/gcd_state_updater.h" | 5 #include "remoting/host/gcd_state_updater.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/strings/stringize_macros.h" | 8 #include "base/strings/stringize_macros.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 GcdStateUpdater::GcdStateUpdater( | 23 GcdStateUpdater::GcdStateUpdater( |
24 const base::Closure& on_update_successful_callback, | 24 const base::Closure& on_update_successful_callback, |
25 const base::Closure& on_unknown_host_id_error, | 25 const base::Closure& on_unknown_host_id_error, |
26 SignalStrategy* signal_strategy, | 26 SignalStrategy* signal_strategy, |
27 scoped_ptr<GcdRestClient> gcd_rest_client) | 27 scoped_ptr<GcdRestClient> gcd_rest_client) |
28 : on_update_successful_callback_(on_update_successful_callback), | 28 : on_update_successful_callback_(on_update_successful_callback), |
29 on_unknown_host_id_error_(on_unknown_host_id_error), | 29 on_unknown_host_id_error_(on_unknown_host_id_error), |
30 signal_strategy_(signal_strategy), | 30 signal_strategy_(signal_strategy), |
31 gcd_rest_client_(gcd_rest_client.Pass()) { | 31 gcd_rest_client_(std::move(gcd_rest_client)) { |
32 DCHECK(signal_strategy_); | 32 DCHECK(signal_strategy_); |
33 DCHECK(thread_checker_.CalledOnValidThread()); | 33 DCHECK(thread_checker_.CalledOnValidThread()); |
34 | 34 |
35 signal_strategy_->AddListener(this); | 35 signal_strategy_->AddListener(this); |
36 | 36 |
37 // Update state if the |signal_strategy_| is already connected. | 37 // Update state if the |signal_strategy_| is already connected. |
38 OnSignalStrategyStateChange(signal_strategy_->GetState()); | 38 OnSignalStrategyStateChange(signal_strategy_->GetState()); |
39 } | 39 } |
40 | 40 |
41 GcdStateUpdater::~GcdStateUpdater() { | 41 GcdStateUpdater::~GcdStateUpdater() { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 if (gcd_rest_client_->HasPendingRequest()) { | 107 if (gcd_rest_client_->HasPendingRequest()) { |
108 return; | 108 return; |
109 } | 109 } |
110 | 110 |
111 // Construct an update to the remote state. | 111 // Construct an update to the remote state. |
112 scoped_ptr<base::DictionaryValue> patch(new base::DictionaryValue); | 112 scoped_ptr<base::DictionaryValue> patch(new base::DictionaryValue); |
113 scoped_ptr<base::DictionaryValue> base_state(new base::DictionaryValue); | 113 scoped_ptr<base::DictionaryValue> base_state(new base::DictionaryValue); |
114 pending_request_jid_ = signal_strategy_->GetLocalJid(); | 114 pending_request_jid_ = signal_strategy_->GetLocalJid(); |
115 base_state->SetString("_jabberId", pending_request_jid_); | 115 base_state->SetString("_jabberId", pending_request_jid_); |
116 base_state->SetString("_hostVersion", STRINGIZE(VERSION)); | 116 base_state->SetString("_hostVersion", STRINGIZE(VERSION)); |
117 patch->Set("base", base_state.Pass()); | 117 patch->Set("base", std::move(base_state)); |
118 | 118 |
119 // Send the update to GCD. | 119 // Send the update to GCD. |
120 gcd_rest_client_->PatchState( | 120 gcd_rest_client_->PatchState( |
121 patch.Pass(), | 121 std::move(patch), |
122 base::Bind(&GcdStateUpdater::OnPatchStateResult, base::Unretained(this))); | 122 base::Bind(&GcdStateUpdater::OnPatchStateResult, base::Unretained(this))); |
123 } | 123 } |
124 | 124 |
125 } // namespace remoting | 125 } // namespace remoting |
OLD | NEW |