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

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

Issue 7605018: Simplify channel creation callbacks in remoting::Session interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | 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/protobuf_video_writer.h" 5 #include "remoting/protocol/protobuf_video_writer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "net/socket/stream_socket.h" 9 #include "net/socket/stream_socket.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
(...skipping 11 matching lines...) Expand all
22 22
23 void ProtobufVideoWriter::Init(protocol::Session* session, 23 void ProtobufVideoWriter::Init(protocol::Session* session,
24 const InitializedCallback& callback) { 24 const InitializedCallback& callback) {
25 initialized_callback_ = callback; 25 initialized_callback_ = callback;
26 26
27 session->CreateStreamChannel( 27 session->CreateStreamChannel(
28 kVideoChannelName, 28 kVideoChannelName,
29 base::Bind(&ProtobufVideoWriter::OnChannelReady, base::Unretained(this))); 29 base::Bind(&ProtobufVideoWriter::OnChannelReady, base::Unretained(this)));
30 } 30 }
31 31
32 void ProtobufVideoWriter::OnChannelReady(const std::string& name, 32 void ProtobufVideoWriter::OnChannelReady(net::StreamSocket* socket) {
33 net::StreamSocket* socket) {
34 DCHECK_EQ(name, std::string(kVideoChannelName));
35 if (!socket) { 33 if (!socket) {
36 initialized_callback_.Run(false); 34 initialized_callback_.Run(false);
37 return; 35 return;
38 } 36 }
39 37
40 DCHECK(!channel_.get()); 38 DCHECK(!channel_.get());
41 channel_.reset(socket); 39 channel_.reset(socket);
42 buffered_writer_ = new BufferedSocketWriter(); 40 buffered_writer_ = new BufferedSocketWriter();
43 // TODO(sergeyu): Provide WriteFailedCallback for the buffered writer. 41 // TODO(sergeyu): Provide WriteFailedCallback for the buffered writer.
44 buffered_writer_->Init(socket, NULL); 42 buffered_writer_->Init(socket, NULL);
(...skipping 10 matching lines...) Expand all
55 Task* done) { 53 Task* done) {
56 buffered_writer_->Write(SerializeAndFrameMessage(*packet), done); 54 buffered_writer_->Write(SerializeAndFrameMessage(*packet), done);
57 } 55 }
58 56
59 int ProtobufVideoWriter::GetPendingPackets() { 57 int ProtobufVideoWriter::GetPendingPackets() {
60 return buffered_writer_->GetBufferChunks(); 58 return buffered_writer_->GetBufferChunks();
61 } 59 }
62 60
63 } // namespace protocol 61 } // namespace protocol
64 } // namespace remoting 62 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698