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

Unified Diff: remoting/jingle_glue/jingle_client.cc

Issue 3087003: Added HostKeyPair class, signatures for heartbeat messages. (Closed)
Patch Set: - Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/jingle_glue/jingle_client.h ('k') | remoting/jingle_glue/jingle_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/jingle_glue/jingle_client.cc
diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc
index 5287d774057dd7298f67a7e87a85e4525b82538c..a50ba71801f179af8fa5e1810091c647236c7593 100644
--- a/remoting/jingle_glue/jingle_client.cc
+++ b/remoting/jingle_glue/jingle_client.cc
@@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// TODO(ajwong): Check the initialization sentinels. Can we base it off of
-// state_ instead of a member variable? Also, we assign and read from a few of
-// the member variables on two threads. We need to audit this for thread
-// safety.
+// TODO(ajwong): We assign and read from a few of the member variables on
+// two threads. We need to audit this for thread safety.
#include "remoting/jingle_glue/jingle_client.h"
@@ -13,6 +11,7 @@
#include "base/waitable_event.h"
#include "base/message_loop.h"
#include "remoting/jingle_glue/gaia_token_pre_xmpp_auth.h"
+#include "remoting/jingle_glue/iq_request.h"
#include "remoting/jingle_glue/jingle_thread.h"
#include "remoting/jingle_glue/relay_port_allocator.h"
#include "remoting/jingle_glue/xmpp_socket_adapter.h"
@@ -32,13 +31,13 @@ namespace remoting {
JingleClient::JingleClient(JingleThread* thread)
: client_(NULL),
thread_(thread),
- state_(START),
+ state_(CREATED),
callback_(NULL) {
}
JingleClient::~JingleClient() {
// JingleClient can be destroyed only after it's closed.
- DCHECK(state_ == CLOSED);
+ DCHECK(state_ == CLOSED || state_ == CREATED);
}
void JingleClient::Init(
@@ -46,13 +45,13 @@ void JingleClient::Init(
const std::string& auth_token_service, Callback* callback) {
DCHECK_NE(username, "");
DCHECK(callback != NULL);
- DCHECK(callback_ == NULL); // Init() can be called only once.
+ DCHECK(state_ == CREATED);
callback_ = callback;
-
message_loop()->PostTask(
FROM_HERE, NewRunnableMethod(this, &JingleClient::DoInitialize,
username, auth_token, auth_token_service));
+ state_ = INITIALIZED;
}
JingleChannel* JingleClient::Connect(const std::string& host_jid,
@@ -160,6 +159,10 @@ std::string JingleClient::GetFullJid() {
return full_jid_;
}
+IqRequest* JingleClient::CreateIqRequest() {
+ return new IqRequest(this);
+}
+
MessageLoop* JingleClient::message_loop() {
return thread_->message_loop();
}
@@ -167,7 +170,7 @@ MessageLoop* JingleClient::message_loop() {
void JingleClient::OnConnectionStateChanged(buzz::XmppEngine::State state) {
switch (state) {
case buzz::XmppEngine::STATE_START:
- UpdateState(START);
+ UpdateState(INITIALIZED);
break;
case buzz::XmppEngine::STATE_OPENING:
UpdateState(CONNECTING);
« no previous file with comments | « remoting/jingle_glue/jingle_client.h ('k') | remoting/jingle_glue/jingle_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698