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

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

Issue 9005034: Refactor SignalStrategy so that it can be reused for multiple connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years 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) 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 "remoting/protocol/pepper_session.h" 5 #include "remoting/protocol/pepper_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 // Generate random session ID. There are usually not more than 1 72 // Generate random session ID. There are usually not more than 1
73 // concurrent session per host, so a random 64-bit integer provides 73 // concurrent session per host, so a random 64-bit integer provides
74 // enough entropy. In the worst case connection will fail when two 74 // enough entropy. In the worst case connection will fail when two
75 // clients generate the same session ID concurrently. 75 // clients generate the same session ID concurrently.
76 session_id_ = base::Int64ToString(base::RandGenerator(kint64max)); 76 session_id_ = base::Int64ToString(base::RandGenerator(kint64max));
77 77
78 // Send session-initiate message. 78 // Send session-initiate message.
79 JingleMessage message(peer_jid_, JingleMessage::SESSION_INITIATE, 79 JingleMessage message(peer_jid_, JingleMessage::SESSION_INITIATE,
80 session_id_); 80 session_id_);
81 message.from = session_manager_->local_jid_; 81 message.from = session_manager_->signal_strategy_->GetLocalJid();
82 message.description.reset( 82 message.description.reset(
83 new ContentDescription(candidate_config_->Clone(), 83 new ContentDescription(candidate_config_->Clone(),
84 authenticator_->GetNextMessage())); 84 authenticator_->GetNextMessage()));
85 initiate_request_.reset(session_manager_->iq_sender()->SendIq( 85 initiate_request_.reset(session_manager_->iq_sender()->SendIq(
86 message.ToXml(), 86 message.ToXml(),
87 base::Bind(&PepperSession::OnSessionInitiateResponse, 87 base::Bind(&PepperSession::OnSessionInitiateResponse,
88 base::Unretained(this)))); 88 base::Unretained(this))));
89 89
90 SetState(CONNECTING); 90 SetState(CONNECTING);
91 } 91 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 DCHECK_NE(state_, FAILED); 425 DCHECK_NE(state_, FAILED);
426 426
427 state_ = new_state; 427 state_ = new_state;
428 if (!state_change_callback_.is_null()) 428 if (!state_change_callback_.is_null())
429 state_change_callback_.Run(new_state); 429 state_change_callback_.Run(new_state);
430 } 430 }
431 } 431 }
432 432
433 } // namespace protocol 433 } // namespace protocol
434 } // namespace remoting 434 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698