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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
8 extern "C" { | 8 extern "C" { |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 } | 10 } |
11 #endif // !defined(OS_WIN) | 11 #endif // !defined(OS_WIN) |
12 | 12 |
13 #include <iostream> | 13 #include <iostream> |
14 #include <list> | 14 #include <list> |
15 | 15 |
16 #include "base/at_exit.h" | 16 #include "base/at_exit.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/message_loop_proxy.h" | |
20 #include "base/synchronization/waitable_event.h" | |
19 #include "base/test/mock_chrome_application_mac.h" | 21 #include "base/test/mock_chrome_application_mac.h" |
20 #include "base/time.h" | 22 #include "base/time.h" |
21 #include "crypto/nss_util.h" | 23 #include "crypto/nss_util.h" |
22 #include "net/base/completion_callback.h" | 24 #include "net/base/completion_callback.h" |
23 #include "net/base/io_buffer.h" | 25 #include "net/base/io_buffer.h" |
24 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
25 #include "net/socket/socket.h" | 27 #include "net/socket/socket.h" |
26 #include "remoting/base/constants.h" | 28 #include "remoting/base/constants.h" |
27 #include "remoting/jingle_glue/jingle_thread.h" | 29 #include "remoting/jingle_glue/jingle_thread.h" |
28 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 30 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
29 #include "remoting/protocol/jingle_session_manager.h" | 31 #include "remoting/protocol/jingle_session_manager.h" |
30 | 32 |
31 namespace remoting { | 33 namespace remoting { |
32 namespace protocol { | 34 namespace protocol { |
33 | 35 |
34 namespace { | 36 namespace { |
37 | |
35 const int kBufferSize = 4096; | 38 const int kBufferSize = 4096; |
36 const char kDummyAuthToken[] = ""; | 39 const char kDummyAuthToken[] = ""; |
40 | |
41 void InitializeMessageLoopProxy( | |
42 scoped_refptr<base::MessageLoopProxy>* proxy, | |
43 base::WaitableEvent* done) { | |
44 *proxy = base::MessageLoopProxy::CreateForCurrentThread(); | |
45 done->Signal(); | |
46 } | |
47 | |
37 } // namespace | 48 } // namespace |
38 | 49 |
39 class ProtocolTestClient; | 50 class ProtocolTestClient; |
40 | 51 |
41 class ProtocolTestConnection | 52 class ProtocolTestConnection |
42 : public base::RefCountedThreadSafe<ProtocolTestConnection> { | 53 : public base::RefCountedThreadSafe<ProtocolTestConnection> { |
43 public: | 54 public: |
44 ProtocolTestConnection(ProtocolTestClient* client) | 55 ProtocolTestConnection(ProtocolTestClient* client) |
45 : client_(client), | 56 : client_(client), |
46 message_loop_(MessageLoop::current()), | 57 message_loop_(MessageLoop::current()), |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 } | 222 } |
212 } | 223 } |
213 | 224 |
214 void ProtocolTestClient::Run(const std::string& username, | 225 void ProtocolTestClient::Run(const std::string& username, |
215 const std::string& auth_token, | 226 const std::string& auth_token, |
216 const std::string& auth_service, | 227 const std::string& auth_service, |
217 const std::string& host_jid) { | 228 const std::string& host_jid) { |
218 remoting::JingleThread jingle_thread; | 229 remoting::JingleThread jingle_thread; |
219 jingle_thread.Start(); | 230 jingle_thread.Start(); |
220 | 231 |
232 scoped_refptr<base::MessageLoopProxy> network_message_loop; | |
233 base::WaitableEvent proxy_event(true, false); | |
234 jingle_thread.message_loop()->PostTask(FROM_HERE, base::Bind( | |
235 &InitializeMessageLoopProxy, &network_message_loop, &proxy_event)); | |
236 proxy_event.Wait(); | |
Wez
2011/08/12 21:11:20
Thread::message_loop_proxy() again.
Sergey Ulanov
2011/08/12 21:24:18
Done.
| |
237 | |
221 signal_strategy_.reset( | 238 signal_strategy_.reset( |
222 new XmppSignalStrategy(&jingle_thread, username, auth_token, | 239 new XmppSignalStrategy(&jingle_thread, username, auth_token, |
223 auth_service)); | 240 auth_service)); |
224 signal_strategy_->Init(this); | 241 signal_strategy_->Init(this); |
225 session_manager_.reset(JingleSessionManager::CreateNotSandboxed()); | 242 session_manager_.reset( |
243 JingleSessionManager::CreateNotSandboxed(network_message_loop)); | |
226 | 244 |
227 host_jid_ = host_jid; | 245 host_jid_ = host_jid; |
228 | 246 |
229 while (true) { | 247 while (true) { |
230 std::string line; | 248 std::string line; |
231 std::getline(std::cin, line); | 249 std::getline(std::cin, line); |
232 | 250 |
233 { | 251 { |
234 base::AutoLock auto_lock(connections_lock_); | 252 base::AutoLock auto_lock(connections_lock_); |
235 | 253 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 std::string auth_service("oauth2"); | 375 std::string auth_service("oauth2"); |
358 if (cmd_line->HasSwitch("auth_service")) | 376 if (cmd_line->HasSwitch("auth_service")) |
359 auth_service = cmd_line->GetSwitchValueASCII("auth_service"); | 377 auth_service = cmd_line->GetSwitchValueASCII("auth_service"); |
360 | 378 |
361 scoped_refptr<ProtocolTestClient> client(new ProtocolTestClient()); | 379 scoped_refptr<ProtocolTestClient> client(new ProtocolTestClient()); |
362 | 380 |
363 client->Run(username, auth_token, host_jid, auth_service); | 381 client->Run(username, auth_token, host_jid, auth_service); |
364 | 382 |
365 return 0; | 383 return 0; |
366 } | 384 } |
OLD | NEW |