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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 const int64_t kTimerIntervalMinMs = 1000; | 22 const int64_t kTimerIntervalMinMs = 1000; |
23 const int64_t kTimerIntervalMaxMs = 5 * 60 * 1000; // 5 minutes | 23 const int64_t kTimerIntervalMaxMs = 5 * 60 * 1000; // 5 minutes |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 GcdStateUpdater::GcdStateUpdater( | 27 GcdStateUpdater::GcdStateUpdater( |
28 const base::Closure& on_update_successful_callback, | 28 const base::Closure& on_update_successful_callback, |
29 const base::Closure& on_unknown_host_id_error, | 29 const base::Closure& on_unknown_host_id_error, |
30 SignalStrategy* signal_strategy, | 30 SignalStrategy* signal_strategy, |
31 scoped_ptr<GcdRestClient> gcd_rest_client) | 31 std::unique_ptr<GcdRestClient> gcd_rest_client) |
32 : on_update_successful_callback_(on_update_successful_callback), | 32 : on_update_successful_callback_(on_update_successful_callback), |
33 on_unknown_host_id_error_(on_unknown_host_id_error), | 33 on_unknown_host_id_error_(on_unknown_host_id_error), |
34 signal_strategy_(signal_strategy), | 34 signal_strategy_(signal_strategy), |
35 gcd_rest_client_(std::move(gcd_rest_client)) { | 35 gcd_rest_client_(std::move(gcd_rest_client)) { |
36 DCHECK(signal_strategy_); | 36 DCHECK(signal_strategy_); |
37 DCHECK(thread_checker_.CalledOnValidThread()); | 37 DCHECK(thread_checker_.CalledOnValidThread()); |
38 | 38 |
39 signal_strategy_->AddListener(this); | 39 signal_strategy_->AddListener(this); |
40 | 40 |
41 // Update state if the |signal_strategy_| is already connected. | 41 // Update state if the |signal_strategy_| is already connected. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 // Don't send a request if there is already another request pending. | 107 // Don't send a request if there is already another request pending. |
108 // This avoids having multiple outstanding requests, which would be | 108 // This avoids having multiple outstanding requests, which would be |
109 // a problem since there's no guarantee that the reqests will | 109 // a problem since there's no guarantee that the reqests will |
110 // complete in order. | 110 // complete in order. |
111 if (gcd_rest_client_->HasPendingRequest()) { | 111 if (gcd_rest_client_->HasPendingRequest()) { |
112 return; | 112 return; |
113 } | 113 } |
114 | 114 |
115 // Construct an update to the remote state. | 115 // Construct an update to the remote state. |
116 scoped_ptr<base::DictionaryValue> patch(new base::DictionaryValue); | 116 std::unique_ptr<base::DictionaryValue> patch(new base::DictionaryValue); |
117 scoped_ptr<base::DictionaryValue> base_state(new base::DictionaryValue); | 117 std::unique_ptr<base::DictionaryValue> base_state(new base::DictionaryValue); |
118 pending_request_jid_ = signal_strategy_->GetLocalJid(); | 118 pending_request_jid_ = signal_strategy_->GetLocalJid(); |
119 base_state->SetString("_jabberId", pending_request_jid_); | 119 base_state->SetString("_jabberId", pending_request_jid_); |
120 base_state->SetString("_hostVersion", STRINGIZE(VERSION)); | 120 base_state->SetString("_hostVersion", STRINGIZE(VERSION)); |
121 patch->Set("base", std::move(base_state)); | 121 patch->Set("base", std::move(base_state)); |
122 | 122 |
123 // Send the update to GCD. | 123 // Send the update to GCD. |
124 gcd_rest_client_->PatchState( | 124 gcd_rest_client_->PatchState( |
125 std::move(patch), | 125 std::move(patch), |
126 base::Bind(&GcdStateUpdater::OnPatchStateResult, base::Unretained(this))); | 126 base::Bind(&GcdStateUpdater::OnPatchStateResult, base::Unretained(this))); |
127 } | 127 } |
128 | 128 |
129 } // namespace remoting | 129 } // namespace remoting |
OLD | NEW |