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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
9 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
10 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
11 #include "net/socket/stream_socket.h" | 12 #include "net/socket/stream_socket.h" |
12 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 15 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
15 | 16 |
16 namespace remoting { | 17 namespace remoting { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 76 |
76 void FakeChannelAuthenticator::OnAuthBytesRead(int result) { | 77 void FakeChannelAuthenticator::OnAuthBytesRead(int result) { |
77 EXPECT_EQ(1, result); | 78 EXPECT_EQ(1, result); |
78 EXPECT_FALSE(did_read_bytes_); | 79 EXPECT_FALSE(did_read_bytes_); |
79 did_read_bytes_ = true; | 80 did_read_bytes_ = true; |
80 if (did_write_bytes_) | 81 if (did_write_bytes_) |
81 CallDoneCallback(); | 82 CallDoneCallback(); |
82 } | 83 } |
83 | 84 |
84 void FakeChannelAuthenticator::CallDoneCallback() { | 85 void FakeChannelAuthenticator::CallDoneCallback() { |
85 DoneCallback callback = done_callback_; | |
86 done_callback_.Reset(); | |
87 if (result_ != net::OK) | 86 if (result_ != net::OK) |
88 socket_.reset(); | 87 socket_.reset(); |
89 callback.Run(result_, socket_.Pass()); | 88 base::ResetAndReturn(&done_callback_).Run(result_, socket_.Pass()); |
90 } | 89 } |
91 | 90 |
92 FakeAuthenticator::FakeAuthenticator( | 91 FakeAuthenticator::FakeAuthenticator( |
93 Type type, int round_trips, Action action, bool async) | 92 Type type, int round_trips, Action action, bool async) |
94 : type_(type), | 93 : type_(type), |
95 round_trips_(round_trips), | 94 round_trips_(round_trips), |
96 action_(action), | 95 action_(action), |
97 async_(async), | 96 async_(async), |
98 messages_(0), | 97 messages_(0), |
99 messages_till_started_(0) { | 98 messages_till_started_(0) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 FakeAuthenticator* authenticator = new FakeAuthenticator( | 189 FakeAuthenticator* authenticator = new FakeAuthenticator( |
191 FakeAuthenticator::HOST, round_trips_, action_, async_); | 190 FakeAuthenticator::HOST, round_trips_, action_, async_); |
192 authenticator->set_messages_till_started(messages_till_started_); | 191 authenticator->set_messages_till_started(messages_till_started_); |
193 | 192 |
194 scoped_ptr<Authenticator> result(authenticator); | 193 scoped_ptr<Authenticator> result(authenticator); |
195 return result.Pass(); | 194 return result.Pass(); |
196 } | 195 } |
197 | 196 |
198 } // namespace protocol | 197 } // namespace protocol |
199 } // namespace remoting | 198 } // namespace remoting |
OLD | NEW |