OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/fake_authenticator.h" | 5 #include "remoting/protocol/fake_authenticator.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/socket/stream_socket.h" | |
13 #include "remoting/base/constants.h" | 12 #include "remoting/base/constants.h" |
| 13 #include "remoting/protocol/p2p_stream_socket.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 15 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 namespace protocol { | 18 namespace protocol { |
19 | 19 |
20 FakeChannelAuthenticator::FakeChannelAuthenticator(bool accept, bool async) | 20 FakeChannelAuthenticator::FakeChannelAuthenticator(bool accept, bool async) |
21 : result_(accept ? net::OK : net::ERR_FAILED), | 21 : result_(accept ? net::OK : net::ERR_FAILED), |
22 async_(async), | 22 async_(async), |
23 did_read_bytes_(false), | 23 did_read_bytes_(false), |
24 did_write_bytes_(false), | 24 did_write_bytes_(false), |
25 weak_factory_(this) { | 25 weak_factory_(this) { |
26 } | 26 } |
27 | 27 |
28 FakeChannelAuthenticator::~FakeChannelAuthenticator() { | 28 FakeChannelAuthenticator::~FakeChannelAuthenticator() { |
29 } | 29 } |
30 | 30 |
31 void FakeChannelAuthenticator::SecureAndAuthenticate( | 31 void FakeChannelAuthenticator::SecureAndAuthenticate( |
32 scoped_ptr<net::StreamSocket> socket, | 32 scoped_ptr<P2PStreamSocket> socket, |
33 const DoneCallback& done_callback) { | 33 const DoneCallback& done_callback) { |
34 socket_ = socket.Pass(); | 34 socket_ = socket.Pass(); |
35 | 35 |
36 if (async_) { | 36 if (async_) { |
37 done_callback_ = done_callback; | 37 done_callback_ = done_callback; |
38 | 38 |
39 if (result_ != net::OK) { | 39 if (result_ != net::OK) { |
40 // Don't write anything if we are going to reject auth to make test | 40 // Don't write anything if we are going to reject auth to make test |
41 // ordering deterministic. | 41 // ordering deterministic. |
42 did_write_bytes_ = true; | 42 did_write_bytes_ = true; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 FakeAuthenticator* authenticator = new FakeAuthenticator( | 189 FakeAuthenticator* authenticator = new FakeAuthenticator( |
190 FakeAuthenticator::HOST, round_trips_, action_, async_); | 190 FakeAuthenticator::HOST, round_trips_, action_, async_); |
191 authenticator->set_messages_till_started(messages_till_started_); | 191 authenticator->set_messages_till_started(messages_till_started_); |
192 | 192 |
193 scoped_ptr<Authenticator> result(authenticator); | 193 scoped_ptr<Authenticator> result(authenticator); |
194 return result.Pass(); | 194 return result.Pass(); |
195 } | 195 } |
196 | 196 |
197 } // namespace protocol | 197 } // namespace protocol |
198 } // namespace remoting | 198 } // namespace remoting |
OLD | NEW |