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/fake_authenticator.h" | 5 #include "remoting/protocol/fake_authenticator.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "net/socket/stream_socket.h" | 9 #include "net/socket/stream_socket.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 void FakeAuthenticator::ProcessMessage(const buzz::XmlElement* message) { | 92 void FakeAuthenticator::ProcessMessage(const buzz::XmlElement* message) { |
93 EXPECT_EQ(WAITING_MESSAGE, state()); | 93 EXPECT_EQ(WAITING_MESSAGE, state()); |
94 std::string id = | 94 std::string id = |
95 message->TextNamed(buzz::QName(kChromotingXmlNamespace, "id")); | 95 message->TextNamed(buzz::QName(kChromotingXmlNamespace, "id")); |
96 EXPECT_EQ(id, base::IntToString(messages_)); | 96 EXPECT_EQ(id, base::IntToString(messages_)); |
97 ++messages_; | 97 ++messages_; |
98 } | 98 } |
99 | 99 |
100 buzz::XmlElement* FakeAuthenticator::GetNextMessage() { | 100 scoped_ptr<buzz::XmlElement> FakeAuthenticator::GetNextMessage() { |
101 EXPECT_EQ(MESSAGE_READY, state()); | 101 EXPECT_EQ(MESSAGE_READY, state()); |
102 | 102 |
103 buzz::XmlElement* result = new buzz::XmlElement( | 103 scoped_ptr<buzz::XmlElement> result(new buzz::XmlElement( |
104 buzz::QName(kChromotingXmlNamespace, "authentication")); | 104 buzz::QName(kChromotingXmlNamespace, "authentication"))); |
105 buzz::XmlElement* id = new buzz::XmlElement( | 105 buzz::XmlElement* id = new buzz::XmlElement( |
106 buzz::QName(kChromotingXmlNamespace, "id")); | 106 buzz::QName(kChromotingXmlNamespace, "id")); |
107 id->AddText(base::IntToString(messages_)); | 107 id->AddText(base::IntToString(messages_)); |
108 result->AddElement(id); | 108 result->AddElement(id); |
109 | 109 |
110 ++messages_; | 110 ++messages_; |
111 return result; | 111 return result.Pass(); |
112 } | 112 } |
113 | 113 |
114 ChannelAuthenticator* | 114 scoped_ptr<ChannelAuthenticator> |
115 FakeAuthenticator::CreateChannelAuthenticator() const { | 115 FakeAuthenticator::CreateChannelAuthenticator() const { |
116 EXPECT_EQ(ACCEPTED, state()); | 116 EXPECT_EQ(ACCEPTED, state()); |
117 return new FakeChannelAuthenticator(action_ != REJECT_CHANNEL, async_); | 117 return scoped_ptr<ChannelAuthenticator>( |
| 118 new FakeChannelAuthenticator(action_ != REJECT_CHANNEL, async_)); |
118 } | 119 } |
119 | 120 |
120 FakeHostAuthenticatorFactory::FakeHostAuthenticatorFactory( | 121 FakeHostAuthenticatorFactory::FakeHostAuthenticatorFactory( |
121 int round_trips, FakeAuthenticator::Action action, bool async) | 122 int round_trips, FakeAuthenticator::Action action, bool async) |
122 : round_trips_(round_trips), | 123 : round_trips_(round_trips), |
123 action_(action), async_(async) { | 124 action_(action), async_(async) { |
124 } | 125 } |
125 | 126 |
126 FakeHostAuthenticatorFactory::~FakeHostAuthenticatorFactory() { | 127 FakeHostAuthenticatorFactory::~FakeHostAuthenticatorFactory() { |
127 } | 128 } |
128 | 129 |
129 Authenticator* FakeHostAuthenticatorFactory::CreateAuthenticator( | 130 scoped_ptr<Authenticator> FakeHostAuthenticatorFactory::CreateAuthenticator( |
130 const std::string& remote_jid, | 131 const std::string& remote_jid, |
131 const buzz::XmlElement* first_message) { | 132 const buzz::XmlElement* first_message) { |
132 return new FakeAuthenticator(FakeAuthenticator::HOST, round_trips_, | 133 return scoped_ptr<Authenticator>(new FakeAuthenticator( |
133 action_, async_); | 134 FakeAuthenticator::HOST, round_trips_, action_, async_)); |
134 } | 135 } |
135 | 136 |
136 } // namespace protocol | 137 } // namespace protocol |
137 } // namespace remoting | 138 } // namespace remoting |
OLD | NEW |