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

Side by Side Diff: remoting/jingle_glue/jingle_channel.cc

Issue 3087003: Added HostKeyPair class, signatures for heartbeat messages. (Closed)
Patch Set: - Created 10 years, 4 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
« no previous file with comments | « remoting/jingle_glue/iq_request.h ('k') | remoting/jingle_glue/jingle_client.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) 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 #include "remoting/jingle_glue/jingle_channel.h" 5 #include "remoting/jingle_glue/jingle_channel.h"
6 6
7 #include "base/lock.h" 7 #include "base/lock.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/waitable_event.h" 10 #include "base/waitable_event.h"
(...skipping 27 matching lines...) Expand all
38 JingleChannel::~JingleChannel() { 38 JingleChannel::~JingleChannel() {
39 DCHECK_EQ(CLOSED, state_); 39 DCHECK_EQ(CLOSED, state_);
40 } 40 }
41 41
42 void JingleChannel::Init(JingleThread* thread, 42 void JingleChannel::Init(JingleThread* thread,
43 talk_base::StreamInterface* stream, 43 talk_base::StreamInterface* stream,
44 const std::string& jid) { 44 const std::string& jid) {
45 thread_ = thread; 45 thread_ = thread;
46 stream_.reset(stream); 46 stream_.reset(stream);
47 stream_->SignalEvent.connect(&event_handler_, &EventHandler::OnStreamEvent); 47 stream_->SignalEvent.connect(&event_handler_, &EventHandler::OnStreamEvent);
48 jid_ = jid;
48 49
49 // Initialize |state_|. 50 // Initialize |state_|.
50 switch (stream->GetState()) { 51 switch (stream->GetState()) {
51 case talk_base::SS_CLOSED: 52 case talk_base::SS_CLOSED:
52 SetState(CLOSED); 53 SetState(CLOSED);
53 break; 54 break;
54 case talk_base::SS_OPENING: 55 case talk_base::SS_OPENING:
55 SetState(CONNECTING); 56 SetState(CONNECTING);
56 break; 57 break;
57 case talk_base::SS_OPEN: 58 case talk_base::SS_OPEN:
58 SetState(OPEN); 59 SetState(OPEN);
59 // Try to read in case there is something in the stream. 60 // Try to read in case there is something in the stream.
60 thread_->message_loop()->PostTask( 61 thread_->message_loop()->PostTask(
61 FROM_HERE, NewRunnableMethod(this, &JingleChannel::DoRead)); 62 FROM_HERE, NewRunnableMethod(this, &JingleChannel::DoRead));
62 break; 63 break;
63 default: 64 default:
64 NOTREACHED(); 65 NOTREACHED();
65 } 66 }
66
67 jid_ = jid;
68 } 67 }
69 68
70 void JingleChannel::Write(scoped_refptr<DataBuffer> data) { 69 void JingleChannel::Write(scoped_refptr<DataBuffer> data) {
71 // Discard empty packets. 70 // Discard empty packets.
72 if (data->GetDataSize() != 0) { 71 if (data->GetDataSize() != 0) {
73 AutoLock auto_lock(write_lock_); 72 AutoLock auto_lock(write_lock_);
74 write_queue_.push_back(data); 73 write_queue_.push_back(data);
75 write_buffer_size_ += data->GetDataSize(); 74 write_buffer_size_ += data->GetDataSize();
76 // Post event so that the data gets written in the tunnel thread. 75 // Post event so that the data gets written in the tunnel thread.
77 thread_->message_loop()->PostTask( 76 thread_->message_loop()->PostTask(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 SetState(CLOSED); 197 SetState(CLOSED);
199 done_event->Signal(); 198 done_event->Signal();
200 } 199 }
201 200
202 size_t JingleChannel::write_buffer_size() { 201 size_t JingleChannel::write_buffer_size() {
203 AutoLock auto_lock(write_lock_); 202 AutoLock auto_lock(write_lock_);
204 return write_buffer_size_; 203 return write_buffer_size_;
205 } 204 }
206 205
207 } // namespace remoting 206 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/jingle_glue/iq_request.h ('k') | remoting/jingle_glue/jingle_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698