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

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

Issue 1649063003: Add MessagePipe interface. Use it in ChannelDispatcherBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@simple_parser
Patch Set: Created 4 years, 10 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/host_control_dispatcher.h" 5 #include "remoting/protocol/host_control_dispatcher.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "net/socket/stream_socket.h" 8 #include "net/socket/stream_socket.h"
9 #include "remoting/base/constants.h" 9 #include "remoting/base/constants.h"
10 #include "remoting/proto/control.pb.h" 10 #include "remoting/proto/control.pb.h"
11 #include "remoting/proto/internal.pb.h" 11 #include "remoting/proto/internal.pb.h"
12 #include "remoting/protocol/clipboard_stub.h" 12 #include "remoting/protocol/clipboard_stub.h"
13 #include "remoting/protocol/host_stub.h" 13 #include "remoting/protocol/host_stub.h"
14 #include "remoting/protocol/message_serialization.h" 14 #include "remoting/protocol/message_serialization.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 namespace protocol { 17 namespace protocol {
18 18
19 HostControlDispatcher::HostControlDispatcher() 19 HostControlDispatcher::HostControlDispatcher()
20 : ChannelDispatcherBase(kControlChannelName) {} 20 : ChannelDispatcherBase(kControlChannelName) {}
21 HostControlDispatcher::~HostControlDispatcher() {} 21 HostControlDispatcher::~HostControlDispatcher() {}
22 22
23 void HostControlDispatcher::SetCapabilities( 23 void HostControlDispatcher::SetCapabilities(
24 const Capabilities& capabilities) { 24 const Capabilities& capabilities) {
25 ControlMessage message; 25 ControlMessage message;
26 message.mutable_capabilities()->CopyFrom(capabilities); 26 message.mutable_capabilities()->CopyFrom(capabilities);
27 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); 27 message_pipe()->Send(&message, base::Closure());
28 } 28 }
29 29
30 void HostControlDispatcher::SetPairingResponse( 30 void HostControlDispatcher::SetPairingResponse(
31 const PairingResponse& pairing_response) { 31 const PairingResponse& pairing_response) {
32 ControlMessage message; 32 ControlMessage message;
33 message.mutable_pairing_response()->CopyFrom(pairing_response); 33 message.mutable_pairing_response()->CopyFrom(pairing_response);
34 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); 34 message_pipe()->Send(&message, base::Closure());
35 } 35 }
36 36
37 void HostControlDispatcher::DeliverHostMessage( 37 void HostControlDispatcher::DeliverHostMessage(
38 const ExtensionMessage& message) { 38 const ExtensionMessage& message) {
39 ControlMessage control_message; 39 ControlMessage control_message;
40 control_message.mutable_extension_message()->CopyFrom(message); 40 control_message.mutable_extension_message()->CopyFrom(message);
41 writer()->Write(SerializeAndFrameMessage(control_message), base::Closure()); 41 message_pipe()->Send(&control_message, base::Closure());
42 } 42 }
43 43
44 void HostControlDispatcher::InjectClipboardEvent(const ClipboardEvent& event) { 44 void HostControlDispatcher::InjectClipboardEvent(const ClipboardEvent& event) {
45 ControlMessage message; 45 ControlMessage message;
46 message.mutable_clipboard_event()->CopyFrom(event); 46 message.mutable_clipboard_event()->CopyFrom(event);
47 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); 47 message_pipe()->Send(&message, base::Closure());
48 } 48 }
49 49
50 void HostControlDispatcher::SetCursorShape( 50 void HostControlDispatcher::SetCursorShape(
51 const CursorShapeInfo& cursor_shape) { 51 const CursorShapeInfo& cursor_shape) {
52 ControlMessage message; 52 ControlMessage message;
53 message.mutable_cursor_shape()->CopyFrom(cursor_shape); 53 message.mutable_cursor_shape()->CopyFrom(cursor_shape);
54 writer()->Write(SerializeAndFrameMessage(message), base::Closure()); 54 message_pipe()->Send(&message, base::Closure());
55 } 55 }
56 56
57 void HostControlDispatcher::OnIncomingMessage( 57 void HostControlDispatcher::OnIncomingMessage(
58 scoped_ptr<CompoundBuffer> buffer) { 58 scoped_ptr<CompoundBuffer> buffer) {
59 DCHECK(clipboard_stub_); 59 DCHECK(clipboard_stub_);
60 DCHECK(host_stub_); 60 DCHECK(host_stub_);
61 61
62 scoped_ptr<ControlMessage> message = 62 scoped_ptr<ControlMessage> message =
63 ParseMessage<ControlMessage>(buffer.get()); 63 ParseMessage<ControlMessage>(buffer.get());
64 if (!message) 64 if (!message)
(...skipping 13 matching lines...) Expand all
78 host_stub_->RequestPairing(message->pairing_request()); 78 host_stub_->RequestPairing(message->pairing_request());
79 } else if (message->has_extension_message()) { 79 } else if (message->has_extension_message()) {
80 host_stub_->DeliverClientMessage(message->extension_message()); 80 host_stub_->DeliverClientMessage(message->extension_message());
81 } else { 81 } else {
82 LOG(WARNING) << "Unknown control message received."; 82 LOG(WARNING) << "Unknown control message received.";
83 } 83 }
84 } 84 }
85 85
86 } // namespace protocol 86 } // namespace protocol
87 } // namespace remoting 87 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698