OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // TODO(ajwong): We assign and read from a few of the member variables on | 5 // TODO(ajwong): We assign and read from a few of the member variables on |
6 // two threads. We need to audit this for thread safety. | 6 // two threads. We need to audit this for thread safety. |
7 | 7 |
8 #include "remoting/jingle_glue/jingle_client.h" | 8 #include "remoting/jingle_glue/jingle_client.h" |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 DCHECK_EQ(message_loop(), MessageLoop::current()); | 69 DCHECK_EQ(message_loop(), MessageLoop::current()); |
70 | 70 |
71 talk_base::StreamInterface* stream = | 71 talk_base::StreamInterface* stream = |
72 tunnel_session_client_->CreateTunnel(buzz::Jid(host_jid), ""); | 72 tunnel_session_client_->CreateTunnel(buzz::Jid(host_jid), ""); |
73 DCHECK(stream != NULL); | 73 DCHECK(stream != NULL); |
74 | 74 |
75 channel->Init(thread_, stream, host_jid); | 75 channel->Init(thread_, stream, host_jid); |
76 } | 76 } |
77 | 77 |
78 void JingleClient::Close() { | 78 void JingleClient::Close() { |
79 // Once we are closed we really shouldn't talk to the callback again. In the | |
80 // case when JingleClient outlives the owner access the callback is not safe. | |
81 // TODO(hclam): We need to lock to reset callback. | |
82 callback_ = NULL; | |
83 | |
84 message_loop()->PostTask( | 79 message_loop()->PostTask( |
85 FROM_HERE, NewRunnableMethod(this, &JingleClient::DoClose)); | 80 FROM_HERE, NewRunnableMethod(this, &JingleClient::DoClose)); |
86 } | 81 } |
87 | 82 |
88 void JingleClient::DoClose() { | 83 void JingleClient::DoClose() { |
89 DCHECK_EQ(message_loop(), MessageLoop::current()); | 84 DCHECK_EQ(message_loop(), MessageLoop::current()); |
90 | 85 |
91 // If we have not yet initialized and the client is already closed then | 86 // If we have not yet initialized and the client is already closed then |
92 // don't close again. | 87 // don't close again. |
93 if (state_ == CLOSED) | 88 if (!callback_ || state_ == CLOSED) |
94 return; | 89 return; |
95 | 90 |
96 if (client_) { | 91 client_->Disconnect(); |
97 client_->Disconnect(); | 92 // Client is deleted by TaskRunner. |
98 // Client is deleted by TaskRunner. | 93 client_ = NULL; |
99 client_ = NULL; | |
100 } | |
101 tunnel_session_client_.reset(); | 94 tunnel_session_client_.reset(); |
102 port_allocator_.reset(); | 95 port_allocator_.reset(); |
103 session_manager_.reset(); | 96 session_manager_.reset(); |
104 network_manager_.reset(); | 97 network_manager_.reset(); |
105 UpdateState(CLOSED); | 98 UpdateState(CLOSED); |
106 } | 99 } |
107 | 100 |
108 void JingleClient::DoInitialize(const std::string& username, | 101 void JingleClient::DoInitialize(const std::string& username, |
109 const std::string& auth_token, | 102 const std::string& auth_token, |
110 const std::string& auth_token_service) { | 103 const std::string& auth_token_service) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 220 } |
228 | 221 |
229 buzz::PreXmppAuth* JingleClient::CreatePreXmppAuth( | 222 buzz::PreXmppAuth* JingleClient::CreatePreXmppAuth( |
230 const buzz::XmppClientSettings& settings) { | 223 const buzz::XmppClientSettings& settings) { |
231 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); | 224 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); |
232 return new GaiaTokenPreXmppAuth(jid.Str(), settings.auth_cookie(), | 225 return new GaiaTokenPreXmppAuth(jid.Str(), settings.auth_cookie(), |
233 settings.token_service()); | 226 settings.token_service()); |
234 } | 227 } |
235 | 228 |
236 } // namespace remoting | 229 } // namespace remoting |
OLD | NEW |