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

Side by Side Diff: remoting/signaling/iq_sender.cc

Issue 1545723002: Use std::move() instead of .Pass() in remoting/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass_host
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
« no previous file with comments | « remoting/signaling/fake_signal_strategy.cc ('k') | remoting/signaling/iq_sender_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/signaling/iq_sender.h" 5 #include "remoting/signaling/iq_sender.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
9 #include "base/location.h" 11 #include "base/location.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
14 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
15 #include "base/time/time.h" 17 #include "base/time/time.h"
16 #include "remoting/signaling/jid_util.h" 18 #include "remoting/signaling/jid_util.h"
17 #include "remoting/signaling/signal_strategy.h" 19 #include "remoting/signaling/signal_strategy.h"
18 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" 20 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
19 #include "third_party/webrtc/libjingle/xmpp/constants.h" 21 #include "third_party/webrtc/libjingle/xmpp/constants.h"
20 22
21 namespace remoting { 23 namespace remoting {
22 24
23 // static 25 // static
24 scoped_ptr<buzz::XmlElement> IqSender::MakeIqStanza( 26 scoped_ptr<buzz::XmlElement> IqSender::MakeIqStanza(
25 const std::string& type, 27 const std::string& type,
26 const std::string& addressee, 28 const std::string& addressee,
27 scoped_ptr<buzz::XmlElement> iq_body) { 29 scoped_ptr<buzz::XmlElement> iq_body) {
28 scoped_ptr<buzz::XmlElement> stanza(new buzz::XmlElement(buzz::QN_IQ)); 30 scoped_ptr<buzz::XmlElement> stanza(new buzz::XmlElement(buzz::QN_IQ));
29 stanza->AddAttr(buzz::QN_TYPE, type); 31 stanza->AddAttr(buzz::QN_TYPE, type);
30 if (!addressee.empty()) 32 if (!addressee.empty())
31 stanza->AddAttr(buzz::QN_TO, addressee); 33 stanza->AddAttr(buzz::QN_TO, addressee);
32 stanza->AddElement(iq_body.release()); 34 stanza->AddElement(iq_body.release());
33 return stanza.Pass(); 35 return stanza;
34 } 36 }
35 37
36 IqSender::IqSender(SignalStrategy* signal_strategy) 38 IqSender::IqSender(SignalStrategy* signal_strategy)
37 : signal_strategy_(signal_strategy) { 39 : signal_strategy_(signal_strategy) {
38 signal_strategy_->AddListener(this); 40 signal_strategy_->AddListener(this);
39 } 41 }
40 42
41 IqSender::~IqSender() { 43 IqSender::~IqSender() {
42 signal_strategy_->RemoveListener(this); 44 signal_strategy_->RemoveListener(this);
43 } 45 }
44 46
45 scoped_ptr<IqRequest> IqSender::SendIq(scoped_ptr<buzz::XmlElement> stanza, 47 scoped_ptr<IqRequest> IqSender::SendIq(scoped_ptr<buzz::XmlElement> stanza,
46 const ReplyCallback& callback) { 48 const ReplyCallback& callback) {
47 std::string addressee = stanza->Attr(buzz::QN_TO); 49 std::string addressee = stanza->Attr(buzz::QN_TO);
48 std::string id = signal_strategy_->GetNextId(); 50 std::string id = signal_strategy_->GetNextId();
49 stanza->AddAttr(buzz::QN_ID, id); 51 stanza->AddAttr(buzz::QN_ID, id);
50 if (!signal_strategy_->SendStanza(stanza.Pass())) { 52 if (!signal_strategy_->SendStanza(std::move(stanza))) {
51 return nullptr; 53 return nullptr;
52 } 54 }
53 DCHECK(requests_.find(id) == requests_.end()); 55 DCHECK(requests_.find(id) == requests_.end());
54 scoped_ptr<IqRequest> request(new IqRequest(this, callback, addressee)); 56 scoped_ptr<IqRequest> request(new IqRequest(this, callback, addressee));
55 if (!callback.is_null()) 57 if (!callback.is_null())
56 requests_[id] = request.get(); 58 requests_[id] = request.get();
57 return request.Pass(); 59 return request;
58 } 60 }
59 61
60 scoped_ptr<IqRequest> IqSender::SendIq(const std::string& type, 62 scoped_ptr<IqRequest> IqSender::SendIq(const std::string& type,
61 const std::string& addressee, 63 const std::string& addressee,
62 scoped_ptr<buzz::XmlElement> iq_body, 64 scoped_ptr<buzz::XmlElement> iq_body,
63 const ReplyCallback& callback) { 65 const ReplyCallback& callback) {
64 return SendIq(MakeIqStanza(type, addressee, iq_body.Pass()), callback); 66 return SendIq(MakeIqStanza(type, addressee, std::move(iq_body)), callback);
65 } 67 }
66 68
67 void IqSender::RemoveRequest(IqRequest* request) { 69 void IqSender::RemoveRequest(IqRequest* request) {
68 IqRequestMap::iterator it = requests_.begin(); 70 IqRequestMap::iterator it = requests_.begin();
69 while (it != requests_.end()) { 71 while (it != requests_.end()) {
70 IqRequestMap::iterator cur = it; 72 IqRequestMap::iterator cur = it;
71 ++it; 73 ++it;
72 if (cur->second == request) { 74 if (cur->second == request) {
73 requests_.erase(cur); 75 requests_.erase(cur);
74 break; 76 break;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 base::ThreadTaskRunnerHandle::Get()->PostTask( 157 base::ThreadTaskRunnerHandle::Get()->PostTask(
156 FROM_HERE, base::Bind(&IqRequest::DeliverResponse, AsWeakPtr(), 158 FROM_HERE, base::Bind(&IqRequest::DeliverResponse, AsWeakPtr(),
157 base::Passed(&stanza_copy))); 159 base::Passed(&stanza_copy)));
158 } 160 }
159 161
160 void IqRequest::DeliverResponse(scoped_ptr<buzz::XmlElement> stanza) { 162 void IqRequest::DeliverResponse(scoped_ptr<buzz::XmlElement> stanza) {
161 CallCallback(stanza.get()); 163 CallCallback(stanza.get());
162 } 164 }
163 165
164 } // namespace remoting 166 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/signaling/fake_signal_strategy.cc ('k') | remoting/signaling/iq_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698