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

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

Issue 4313001: Rename classes for Chromoting: (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Resolve merge conflicts Created 10 years, 1 month 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
« no previous file with comments | « remoting/protocol/host_message_dispatcher.h ('k') | remoting/protocol/jingle_session.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 "net/base/io_buffer.h" 5 #include "net/base/io_buffer.h"
6 #include "remoting/base/multiple_array_input_stream.h" 6 #include "remoting/base/multiple_array_input_stream.h"
7 #include "remoting/proto/control.pb.h" 7 #include "remoting/proto/control.pb.h"
8 #include "remoting/proto/event.pb.h" 8 #include "remoting/proto/event.pb.h"
9 #include "remoting/proto/video.pb.h"
10 #include "remoting/protocol/chromotocol_connection.h"
11 #include "remoting/protocol/host_message_dispatcher.h" 9 #include "remoting/protocol/host_message_dispatcher.h"
12 #include "remoting/protocol/host_stub.h" 10 #include "remoting/protocol/host_stub.h"
13 #include "remoting/protocol/input_stub.h" 11 #include "remoting/protocol/input_stub.h"
14 #include "remoting/protocol/message_reader.h" 12 #include "remoting/protocol/message_reader.h"
13 #include "remoting/protocol/session.h"
15 14
16 namespace { 15 namespace {
17 16
18 // A single protobuf can contain multiple messages that will be handled by 17 // A single protobuf can contain multiple messages that will be handled by
19 // different message handlers. We use this wrapper to ensure that the 18 // different message handlers. We use this wrapper to ensure that the
20 // protobuf is only deleted after all the handlers have finished executing. 19 // protobuf is only deleted after all the handlers have finished executing.
21 template <typename T> 20 template <typename T>
22 class RefCountedMessage : public base::RefCounted<RefCountedMessage<T> > { 21 class RefCountedMessage : public base::RefCounted<RefCountedMessage<T> > {
23 public: 22 public:
24 RefCountedMessage(T* message) : message_(message) { } 23 RefCountedMessage(T* message) : message_(message) { }
(...skipping 20 matching lines...) Expand all
45 44
46 HostMessageDispatcher::HostMessageDispatcher() : 45 HostMessageDispatcher::HostMessageDispatcher() :
47 host_stub_(NULL), 46 host_stub_(NULL),
48 input_stub_(NULL) { 47 input_stub_(NULL) {
49 } 48 }
50 49
51 HostMessageDispatcher::~HostMessageDispatcher() { 50 HostMessageDispatcher::~HostMessageDispatcher() {
52 } 51 }
53 52
54 bool HostMessageDispatcher::Initialize( 53 bool HostMessageDispatcher::Initialize(
55 ChromotocolConnection* connection, 54 protocol::Session* session,
56 HostStub* host_stub, InputStub* input_stub) { 55 HostStub* host_stub, InputStub* input_stub) {
57 if (!connection || !host_stub || !input_stub || 56 if (!session || !host_stub || !input_stub ||
58 !connection->event_channel() || !connection->control_channel()) { 57 !session->event_channel() || !session->control_channel()) {
59 return false; 58 return false;
60 } 59 }
61 60
62 control_message_reader_.reset(new MessageReader()); 61 control_message_reader_.reset(new MessageReader());
63 event_message_reader_.reset(new MessageReader()); 62 event_message_reader_.reset(new MessageReader());
64 host_stub_ = host_stub; 63 host_stub_ = host_stub;
65 input_stub_ = input_stub; 64 input_stub_ = input_stub;
66 65
67 // Initialize the readers on the sockets provided by channels. 66 // Initialize the readers on the sockets provided by channels.
68 event_message_reader_->Init<EventMessage>( 67 event_message_reader_->Init<EventMessage>(
69 connection->event_channel(), 68 session->event_channel(),
70 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived)); 69 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived));
71 control_message_reader_->Init<ControlMessage>( 70 control_message_reader_->Init<ControlMessage>(
72 connection->control_channel(), 71 session->control_channel(),
73 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived)); 72 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived));
74 return true; 73 return true;
75 } 74 }
76 75
77 void HostMessageDispatcher::OnControlMessageReceived(ControlMessage* message) { 76 void HostMessageDispatcher::OnControlMessageReceived(ControlMessage* message) {
78 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg = 77 scoped_refptr<RefCountedMessage<ControlMessage> > ref_msg =
79 new RefCountedMessage<ControlMessage>(message); 78 new RefCountedMessage<ControlMessage>(message);
80 if (message->has_suggest_resolution()) { 79 if (message->has_suggest_resolution()) {
81 host_stub_->SuggestResolution( 80 host_stub_->SuggestResolution(
82 message->suggest_resolution(), NewDeleteTask(ref_msg)); 81 message->suggest_resolution(), NewDeleteTask(ref_msg));
83 } 82 }
84 } 83 }
85 84
86 void HostMessageDispatcher::OnEventMessageReceived( 85 void HostMessageDispatcher::OnEventMessageReceived(
87 EventMessage* message) { 86 EventMessage* message) {
88 // TODO(hclam): Implement. 87 // TODO(hclam): Implement.
89 } 88 }
90 89
91 } // namespace protocol 90 } // namespace protocol
92 } // namespace remoting 91 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/host_message_dispatcher.h ('k') | remoting/protocol/jingle_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698