Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(815)

Side by Side Diff: remoting/protocol/connection_to_client.cc

Issue 9433027: Delete Session and SessionManager object synchronously. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/protocol/fake_authenticator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/connection_to_client.h" 5 #include "remoting/protocol/connection_to_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "google/protobuf/message.h" 10 #include "google/protobuf/message.h"
(...skipping 13 matching lines...) Expand all
24 session_(session) { 24 session_(session) {
25 session_->SetStateChangeCallback( 25 session_->SetStateChangeCallback(
26 base::Bind(&ConnectionToClient::OnSessionStateChange, 26 base::Bind(&ConnectionToClient::OnSessionStateChange,
27 base::Unretained(this))); 27 base::Unretained(this)));
28 session_->SetRouteChangeCallback( 28 session_->SetRouteChangeCallback(
29 base::Bind(&ConnectionToClient::OnSessionRouteChange, 29 base::Bind(&ConnectionToClient::OnSessionRouteChange,
30 base::Unretained(this))); 30 base::Unretained(this)));
31 } 31 }
32 32
33 ConnectionToClient::~ConnectionToClient() { 33 ConnectionToClient::~ConnectionToClient() {
34 if (session_.get()) {
35 base::MessageLoopProxy::current()->DeleteSoon(
36 FROM_HERE, session_.release());
37 }
38 } 34 }
39 35
40 void ConnectionToClient::SetEventHandler(EventHandler* event_handler) { 36 void ConnectionToClient::SetEventHandler(EventHandler* event_handler) {
41 DCHECK(CalledOnValidThread()); 37 DCHECK(CalledOnValidThread());
42 handler_ = event_handler; 38 handler_ = event_handler;
43 } 39 }
44 40
45 protocol::Session* ConnectionToClient::session() { 41 protocol::Session* ConnectionToClient::session() {
46 DCHECK(CalledOnValidThread()); 42 DCHECK(CalledOnValidThread());
47 return session_.get(); 43 return session_.get();
48 } 44 }
49 45
50 void ConnectionToClient::Disconnect() { 46 void ConnectionToClient::Disconnect() {
51 DCHECK(CalledOnValidThread()); 47 DCHECK(CalledOnValidThread());
52 48
53 CloseChannels(); 49 CloseChannels();
54 50
55 DCHECK(session_.get()); 51 DCHECK(session_.get());
56 Session* session = session_.release(); 52 scoped_ptr<Session> session = session_.Pass();
57
58 // It may not be safe to delete |session_| here becase this method
59 // may be invoked in resonse to a libjingle event and libjingle's
60 // sigslot doesn't handle it properly, so postpone the deletion.
61 base::MessageLoopProxy::current()->DeleteSoon(FROM_HERE, session);
62 53
63 // This should trigger OnConnectionClosed() event and this object 54 // This should trigger OnConnectionClosed() event and this object
64 // may be destroyed as the result. 55 // may be destroyed as the result.
65 session->Close(); 56 session->Close();
66 } 57 }
67 58
68 void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) { 59 void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) {
69 DCHECK(CalledOnValidThread()); 60 DCHECK(CalledOnValidThread());
70 handler_->OnSequenceNumberUpdated(this, sequence_number); 61 handler_->OnSequenceNumberUpdated(this, sequence_number);
71 } 62 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 161 }
171 162
172 void ConnectionToClient::CloseChannels() { 163 void ConnectionToClient::CloseChannels() {
173 control_dispatcher_.reset(); 164 control_dispatcher_.reset();
174 event_dispatcher_.reset(); 165 event_dispatcher_.reset();
175 video_writer_.reset(); 166 video_writer_.reset();
176 } 167 }
177 168
178 } // namespace protocol 169 } // namespace protocol
179 } // namespace remoting 170 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/protocol/fake_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698