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

Side by Side Diff: remoting/protocol/protobuf_video_reader.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_reader.h" 5 #include "remoting/protocol/protobuf_video_reader.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 14 matching lines...) Expand all
25 VideoStub* video_stub, 25 VideoStub* video_stub,
26 const InitializedCallback& callback) { 26 const InitializedCallback& callback) {
27 initialized_callback_ = callback; 27 initialized_callback_ = callback;
28 video_stub_ = video_stub; 28 video_stub_ = video_stub;
29 29
30 session->CreateStreamChannel( 30 session->CreateStreamChannel(
31 kVideoChannelName, 31 kVideoChannelName,
32 base::Bind(&ProtobufVideoReader::OnChannelReady, base::Unretained(this))); 32 base::Bind(&ProtobufVideoReader::OnChannelReady, base::Unretained(this)));
33 } 33 }
34 34
35 void ProtobufVideoReader::OnChannelReady(const std::string& name, 35 void ProtobufVideoReader::OnChannelReady(net::StreamSocket* socket) {
36 net::StreamSocket* socket) {
37 DCHECK_EQ(name, std::string(kVideoChannelName));
38 if (!socket) { 36 if (!socket) {
39 initialized_callback_.Run(false); 37 initialized_callback_.Run(false);
40 return; 38 return;
41 } 39 }
42 40
43 DCHECK(!channel_.get()); 41 DCHECK(!channel_.get());
44 channel_.reset(socket); 42 channel_.reset(socket);
45 reader_.Init(socket, NewCallback(this, &ProtobufVideoReader::OnNewData)); 43 reader_.Init(socket, NewCallback(this, &ProtobufVideoReader::OnNewData));
46 initialized_callback_.Run(true); 44 initialized_callback_.Run(true);
47 } 45 }
48 46
49 void ProtobufVideoReader::OnNewData(VideoPacket* packet, Task* done_task) { 47 void ProtobufVideoReader::OnNewData(VideoPacket* packet, Task* done_task) {
50 video_stub_->ProcessVideoPacket(packet, done_task); 48 video_stub_->ProcessVideoPacket(packet, done_task);
51 } 49 }
52 50
53 } // namespace protocol 51 } // namespace protocol
54 } // namespace remoting 52 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698