OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/pepper_stream_channel.h" | 5 #include "remoting/protocol/pepper_stream_channel.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "crypto/hmac.h" | 8 #include "crypto/hmac.h" |
9 #include "jingle/glue/utils.h" | 9 #include "jingle/glue/utils.h" |
10 #include "net/base/cert_status_flags.h" | 10 #include "net/base/cert_status_flags.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 PepperStreamChannel::PepperStreamChannel( | 40 PepperStreamChannel::PepperStreamChannel( |
41 PepperSession* session, | 41 PepperSession* session, |
42 const std::string& name, | 42 const std::string& name, |
43 const Session::StreamChannelCallback& callback) | 43 const Session::StreamChannelCallback& callback) |
44 : session_(session), | 44 : session_(session), |
45 name_(name), | 45 name_(name), |
46 callback_(callback), | 46 callback_(callback), |
47 channel_(NULL), | 47 channel_(NULL), |
48 connected_(false), | 48 connected_(false) { |
49 ALLOW_THIS_IN_INITIALIZER_LIST(p2p_connect_callback_( | |
50 this, &PepperStreamChannel::OnP2PConnect)) { | |
51 } | 49 } |
52 | 50 |
53 PepperStreamChannel::~PepperStreamChannel() { | 51 PepperStreamChannel::~PepperStreamChannel() { |
54 session_->OnDeleteChannel(this); | 52 session_->OnDeleteChannel(this); |
55 // Verify that the |channel_| is ether destroyed or we own it. | 53 // Verify that the |channel_| is ether destroyed or we own it. |
56 DCHECK_EQ(channel_, owned_channel_.get()); | 54 DCHECK_EQ(channel_, owned_channel_.get()); |
57 // Channel should be already destroyed if we were connected. | 55 // Channel should be already destroyed if we were connected. |
58 DCHECK(!connected_ || channel_ == NULL); | 56 DCHECK(!connected_ || channel_ == NULL); |
59 } | 57 } |
60 | 58 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 113 } |
116 | 114 |
117 if (transport->SetProperty(PP_TRANSPORTPROPERTY_DISABLE_TCP_TRANSPORT, | 115 if (transport->SetProperty(PP_TRANSPORTPROPERTY_DISABLE_TCP_TRANSPORT, |
118 pp::Var(true)) != PP_OK) { | 116 pp::Var(true)) != PP_OK) { |
119 LOG(ERROR) << "Failed to set DISABLE_TCP_TRANSPORT flag."; | 117 LOG(ERROR) << "Failed to set DISABLE_TCP_TRANSPORT flag."; |
120 } | 118 } |
121 | 119 |
122 channel_ = new PepperTransportSocketAdapter(transport, name_, this); | 120 channel_ = new PepperTransportSocketAdapter(transport, name_, this); |
123 owned_channel_.reset(channel_); | 121 owned_channel_.reset(channel_); |
124 | 122 |
125 int result = channel_->Connect(&p2p_connect_callback_); | 123 int result = channel_->Connect(base::Bind(&PepperStreamChannel::OnP2PConnect, |
| 124 base::Unretained(this))); |
126 if (result != net::ERR_IO_PENDING) | 125 if (result != net::ERR_IO_PENDING) |
127 OnP2PConnect(result); | 126 OnP2PConnect(result); |
128 } | 127 } |
129 | 128 |
130 void PepperStreamChannel::AddRemoveCandidate( | 129 void PepperStreamChannel::AddRemoveCandidate( |
131 const cricket::Candidate& candidate) { | 130 const cricket::Candidate& candidate) { |
132 DCHECK(CalledOnValidThread()); | 131 DCHECK(CalledOnValidThread()); |
133 if (channel_) | 132 if (channel_) |
134 channel_->AddRemoteCandidate(jingle_glue::SerializeP2PCandidate(candidate)); | 133 channel_->AddRemoteCandidate(jingle_glue::SerializeP2PCandidate(candidate)); |
135 } | 134 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 void PepperStreamChannel::NotifyConnectFailed() { | 194 void PepperStreamChannel::NotifyConnectFailed() { |
196 channel_ = NULL; | 195 channel_ = NULL; |
197 owned_channel_.reset(); | 196 owned_channel_.reset(); |
198 authenticator_.reset(); | 197 authenticator_.reset(); |
199 | 198 |
200 NotifyConnected(NULL); | 199 NotifyConnected(NULL); |
201 } | 200 } |
202 | 201 |
203 } // namespace protocol | 202 } // namespace protocol |
204 } // namespace remoting | 203 } // namespace remoting |
OLD | NEW |