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

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

Issue 850983002: Implement video frame acknowledgements in the chromoting protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/channel_dispatcher_base.h" 5 #include "remoting/protocol/channel_dispatcher_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "net/socket/stream_socket.h" 8 #include "net/socket/stream_socket.h"
9 #include "remoting/protocol/session.h" 9 #include "remoting/protocol/session.h"
10 #include "remoting/protocol/session_config.h" 10 #include "remoting/protocol/session_config.h"
(...skipping 11 matching lines...) Expand all
22 ChannelDispatcherBase::~ChannelDispatcherBase() { 22 ChannelDispatcherBase::~ChannelDispatcherBase() {
23 writer()->Close(); 23 writer()->Close();
24 if (channel_factory_) 24 if (channel_factory_)
25 channel_factory_->CancelChannelCreation(channel_name_); 25 channel_factory_->CancelChannelCreation(channel_name_);
26 } 26 }
27 27
28 void ChannelDispatcherBase::Init(Session* session, 28 void ChannelDispatcherBase::Init(Session* session,
29 const ChannelConfig& config, 29 const ChannelConfig& config,
30 EventHandler* event_handler) { 30 EventHandler* event_handler) {
31 DCHECK(session); 31 DCHECK(session);
32 switch (config.transport) { 32 channel_config_ = config;
33 switch (channel_config_.transport) {
33 case ChannelConfig::TRANSPORT_MUX_STREAM: 34 case ChannelConfig::TRANSPORT_MUX_STREAM:
34 channel_factory_ = session->GetMultiplexedChannelFactory(); 35 channel_factory_ = session->GetMultiplexedChannelFactory();
35 break; 36 break;
36 37
37 case ChannelConfig::TRANSPORT_STREAM: 38 case ChannelConfig::TRANSPORT_STREAM:
38 channel_factory_ = session->GetTransportChannelFactory(); 39 channel_factory_ = session->GetTransportChannelFactory();
39 break; 40 break;
40 41
41 default: 42 default:
42 LOG(FATAL) << "Unknown transport type: " << config.transport; 43 LOG(FATAL) << "Unknown transport type: " << channel_config_.transport;
43 } 44 }
44 45
45 event_handler_ = event_handler; 46 event_handler_ = event_handler;
46 47
47 channel_factory_->CreateChannel(channel_name_, base::Bind( 48 channel_factory_->CreateChannel(channel_name_, base::Bind(
48 &ChannelDispatcherBase::OnChannelReady, base::Unretained(this))); 49 &ChannelDispatcherBase::OnChannelReady, base::Unretained(this)));
49 } 50 }
50 51
52 void ChannelDispatcherBase::NotifyError(ErrorCode error) {
53 event_handler_->OnChannelError(this, error);
54 }
55
51 void ChannelDispatcherBase::OnChannelReady( 56 void ChannelDispatcherBase::OnChannelReady(
52 scoped_ptr<net::StreamSocket> socket) { 57 scoped_ptr<net::StreamSocket> socket) {
53 if (!socket.get()) { 58 if (!socket.get()) {
54 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); 59 NotifyError(CHANNEL_CONNECTION_ERROR);
55 return; 60 return;
56 } 61 }
57 62
58 channel_factory_ = nullptr; 63 channel_factory_ = nullptr;
59 channel_ = socket.Pass(); 64 channel_ = socket.Pass();
60 writer_.Init(channel_.get(), base::Bind(&ChannelDispatcherBase::OnWriteFailed, 65 writer_.Init(channel_.get(), base::Bind(&ChannelDispatcherBase::OnWriteFailed,
61 base::Unretained(this))); 66 base::Unretained(this)));
62 reader_.StartReading(channel_.get()); 67 reader_.StartReading(channel_.get());
63 68
64 event_handler_->OnChannelInitialized(this); 69 event_handler_->OnChannelInitialized(this);
65 } 70 }
66 71
67 void ChannelDispatcherBase::OnWriteFailed(int error) { 72 void ChannelDispatcherBase::OnWriteFailed(int error) {
68 event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR); 73 NotifyError(CHANNEL_CONNECTION_ERROR);
69 } 74 }
70 75
71 } // namespace protocol 76 } // namespace protocol
72 } // namespace remoting 77 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698