Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: remoting/protocol/pairing_registry.cc

Issue 1534193004: Use std::move() instead of scoped_ptr<>::Pass(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/protocol/pairing_registry.h" 5 #include "remoting/protocol/pairing_registry.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return Pairing(); 72 return Pairing();
73 } 73 }
74 74
75 scoped_ptr<base::DictionaryValue> PairingRegistry::Pairing::ToValue() const { 75 scoped_ptr<base::DictionaryValue> PairingRegistry::Pairing::ToValue() const {
76 scoped_ptr<base::DictionaryValue> pairing(new base::DictionaryValue()); 76 scoped_ptr<base::DictionaryValue> pairing(new base::DictionaryValue());
77 pairing->SetDouble(kCreatedTimeKey, created_time().ToJsTime()); 77 pairing->SetDouble(kCreatedTimeKey, created_time().ToJsTime());
78 pairing->SetString(kClientNameKey, client_name()); 78 pairing->SetString(kClientNameKey, client_name());
79 pairing->SetString(kClientIdKey, client_id()); 79 pairing->SetString(kClientIdKey, client_id());
80 if (!shared_secret().empty()) 80 if (!shared_secret().empty())
81 pairing->SetString(kSharedSecretKey, shared_secret()); 81 pairing->SetString(kSharedSecretKey, shared_secret());
82 return pairing.Pass(); 82 return pairing;
83 } 83 }
84 84
85 bool PairingRegistry::Pairing::operator==(const Pairing& other) const { 85 bool PairingRegistry::Pairing::operator==(const Pairing& other) const {
86 return created_time_ == other.created_time_ && 86 return created_time_ == other.created_time_ &&
87 client_id_ == other.client_id_ && 87 client_id_ == other.client_id_ &&
88 client_name_ == other.client_name_ && 88 client_name_ == other.client_name_ &&
89 shared_secret_ == other.shared_secret_; 89 shared_secret_ == other.shared_secret_;
90 } 90 }
91 91
92 bool PairingRegistry::Pairing::is_valid() const { 92 bool PairingRegistry::Pairing::is_valid() const {
93 // |shared_secret_| is optional. It will be empty on Windows because the 93 // |shared_secret_| is optional. It will be empty on Windows because the
94 // privileged registry key can only be read in the elevated host process. 94 // privileged registry key can only be read in the elevated host process.
95 return !client_id_.empty(); 95 return !client_id_.empty();
96 } 96 }
97 97
98 PairingRegistry::PairingRegistry( 98 PairingRegistry::PairingRegistry(
99 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner, 99 scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner,
100 scoped_ptr<Delegate> delegate) 100 scoped_ptr<Delegate> delegate)
101 : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), 101 : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()),
102 delegate_task_runner_(delegate_task_runner), 102 delegate_task_runner_(delegate_task_runner),
103 delegate_(delegate.Pass()) { 103 delegate_(std::move(delegate)) {
104 DCHECK(delegate_); 104 DCHECK(delegate_);
105 } 105 }
106 106
107 PairingRegistry::Pairing PairingRegistry::CreatePairing( 107 PairingRegistry::Pairing PairingRegistry::CreatePairing(
108 const std::string& client_name) { 108 const std::string& client_name) {
109 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 109 DCHECK(caller_task_runner_->BelongsToCurrentThread());
110 110
111 Pairing result = Pairing::Create(client_name); 111 Pairing result = Pairing::Create(client_name);
112 AddPairing(result); 112 AddPairing(result);
113 return result; 113 return result;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 void PairingRegistry::InvokeGetPairingCallbackAndScheduleNext( 240 void PairingRegistry::InvokeGetPairingCallbackAndScheduleNext(
241 const GetPairingCallback& callback, Pairing pairing) { 241 const GetPairingCallback& callback, Pairing pairing) {
242 callback.Run(pairing); 242 callback.Run(pairing);
243 pending_requests_.pop(); 243 pending_requests_.pop();
244 ServiceNextRequest(); 244 ServiceNextRequest();
245 } 245 }
246 246
247 void PairingRegistry::InvokeGetAllPairingsCallbackAndScheduleNext( 247 void PairingRegistry::InvokeGetAllPairingsCallbackAndScheduleNext(
248 const GetAllPairingsCallback& callback, 248 const GetAllPairingsCallback& callback,
249 scoped_ptr<base::ListValue> pairings) { 249 scoped_ptr<base::ListValue> pairings) {
250 callback.Run(pairings.Pass()); 250 callback.Run(std::move(pairings));
251 pending_requests_.pop(); 251 pending_requests_.pop();
252 ServiceNextRequest(); 252 ServiceNextRequest();
253 } 253 }
254 254
255 void PairingRegistry::SanitizePairings(const GetAllPairingsCallback& callback, 255 void PairingRegistry::SanitizePairings(const GetAllPairingsCallback& callback,
256 scoped_ptr<base::ListValue> pairings) { 256 scoped_ptr<base::ListValue> pairings) {
257 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 257 DCHECK(caller_task_runner_->BelongsToCurrentThread());
258 258
259 scoped_ptr<base::ListValue> sanitized_pairings(new base::ListValue()); 259 scoped_ptr<base::ListValue> sanitized_pairings(new base::ListValue());
260 for (size_t i = 0; i < pairings->GetSize(); ++i) { 260 for (size_t i = 0; i < pairings->GetSize(); ++i) {
(...skipping 12 matching lines...) Expand all
273 273
274 // Clear the shared secrect and append the pairing data to the list. 274 // Clear the shared secrect and append the pairing data to the list.
275 Pairing sanitized_pairing( 275 Pairing sanitized_pairing(
276 pairing.created_time(), 276 pairing.created_time(),
277 pairing.client_name(), 277 pairing.client_name(),
278 pairing.client_id(), 278 pairing.client_id(),
279 ""); 279 "");
280 sanitized_pairings->Append(sanitized_pairing.ToValue().release()); 280 sanitized_pairings->Append(sanitized_pairing.ToValue().release());
281 } 281 }
282 282
283 callback.Run(sanitized_pairings.Pass()); 283 callback.Run(std::move(sanitized_pairings));
284 } 284 }
285 285
286 void PairingRegistry::ServiceOrQueueRequest(const base::Closure& request) { 286 void PairingRegistry::ServiceOrQueueRequest(const base::Closure& request) {
287 bool servicing_request = !pending_requests_.empty(); 287 bool servicing_request = !pending_requests_.empty();
288 pending_requests_.push(request); 288 pending_requests_.push(request);
289 if (!servicing_request) { 289 if (!servicing_request) {
290 ServiceNextRequest(); 290 ServiceNextRequest();
291 } 291 }
292 } 292 }
293 293
294 void PairingRegistry::ServiceNextRequest() { 294 void PairingRegistry::ServiceNextRequest() {
295 if (pending_requests_.empty()) 295 if (pending_requests_.empty())
296 return; 296 return;
297 297
298 PostTask(delegate_task_runner_, FROM_HERE, pending_requests_.front()); 298 PostTask(delegate_task_runner_, FROM_HERE, pending_requests_.front());
299 } 299 }
300 300
301 } // namespace protocol 301 } // namespace protocol
302 } // namespace remoting 302 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698