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

Side by Side Diff: jingle/notifier/base/xmpp_connection.cc

Issue 14307021: jingle: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
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 "jingle/notifier/base/xmpp_connection.h" 5 #include "jingle/notifier/base/xmpp_connection.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // buzz::XmppClient::Connect() should never fail. 73 // buzz::XmppClient::Connect() should never fail.
74 DCHECK_EQ(connect_status, buzz::XMPP_RETURN_OK); 74 DCHECK_EQ(connect_status, buzz::XMPP_RETURN_OK);
75 weak_xmpp_client->Start(); 75 weak_xmpp_client->Start();
76 weak_xmpp_client_ = weak_xmpp_client->AsWeakPtr(); 76 weak_xmpp_client_ = weak_xmpp_client->AsWeakPtr();
77 } 77 }
78 78
79 XmppConnection::~XmppConnection() { 79 XmppConnection::~XmppConnection() {
80 DCHECK(CalledOnValidThread()); 80 DCHECK(CalledOnValidThread());
81 ClearClient(); 81 ClearClient();
82 task_pump_->Stop(); 82 task_pump_->Stop();
83 MessageLoop* current_message_loop = MessageLoop::current(); 83 base::MessageLoop* current_message_loop = base::MessageLoop::current();
84 CHECK(current_message_loop); 84 CHECK(current_message_loop);
85 // We do this because XmppConnection may get destroyed as a result 85 // We do this because XmppConnection may get destroyed as a result
86 // of a signal from XmppClient. If we delete |task_pump_| here, bad 86 // of a signal from XmppClient. If we delete |task_pump_| here, bad
87 // things happen when the stack pops back up to the XmppClient's 87 // things happen when the stack pops back up to the XmppClient's
88 // (which is deleted by |task_pump_|) function. 88 // (which is deleted by |task_pump_|) function.
89 current_message_loop->DeleteSoon(FROM_HERE, task_pump_.release()); 89 current_message_loop->DeleteSoon(FROM_HERE, task_pump_.release());
90 } 90 }
91 91
92 void XmppConnection::OnStateChange(buzz::XmppEngine::State state) { 92 void XmppConnection::OnStateChange(buzz::XmppEngine::State state) {
93 DCHECK(CalledOnValidThread()); 93 DCHECK(CalledOnValidThread());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 139
140 void XmppConnection::ClearClient() { 140 void XmppConnection::ClearClient() {
141 if (weak_xmpp_client_.get()) { 141 if (weak_xmpp_client_.get()) {
142 weak_xmpp_client_->Invalidate(); 142 weak_xmpp_client_->Invalidate();
143 DCHECK(!weak_xmpp_client_.get()); 143 DCHECK(!weak_xmpp_client_.get());
144 } 144 }
145 } 145 }
146 146
147 } // namespace notifier 147 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698