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

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

Issue 10399052: [Chromoting] Add a filter that will stop the host sending unnecessary clipboard events to the clien… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review. Created 8 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/protocol/clipboard_echo_filter.h"
6
7 #include "remoting/proto/event.pb.h"
8
9 namespace remoting {
10 namespace protocol {
11
12 ClipboardEchoFilter::ClipboardEchoFilter()
13 : host_stub_(NULL),
14 client_stub_(NULL),
15 client_filter_(this),
16 host_filter_(this) {
17 }
18
19 void ClipboardEchoFilter::set_client_stub(ClipboardStub* client_stub) {
20 client_stub_ = client_stub;
21 }
22
23 void ClipboardEchoFilter::set_host_stub(ClipboardStub* host_stub) {
24 host_stub_ = host_stub;
25 }
26
27 ClipboardStub* ClipboardEchoFilter::get_client_filter() {
28 return &client_filter_;
29 }
30
31 ClipboardStub* ClipboardEchoFilter::get_host_filter() {
32 return &host_filter_;
33 }
34
35 void ClipboardEchoFilter::InjectClipboardEventToClient(
36 const ClipboardEvent& event) {
37 if (!client_stub_) {
Wez 2012/05/21 22:33:15 nit: Move this test to the InjectClipboardEvent ca
simonmorris 2012/05/21 23:01:33 Then ClientFilter::InjectClipboardEvent would no l
38 return;
39 }
40 if (event.mime_type() == client_latest_mime_type_ &&
41 event.data() == client_latest_data_) {
42 return;
43 }
44 client_stub_->InjectClipboardEvent(event);
45 }
46
47 void ClipboardEchoFilter::InjectClipboardEventToHost(
48 const ClipboardEvent& event) {
49 client_latest_mime_type_ = event.mime_type();
50 client_latest_data_ = event.data();
51 if (host_stub_) {
52 host_stub_->InjectClipboardEvent(event);
53 }
54 }
55
56 ClipboardEchoFilter::ClientFilter::ClientFilter(
57 ClipboardEchoFilter* filter) : filter_(filter) {
58 }
59
60 void ClipboardEchoFilter::ClientFilter::InjectClipboardEvent(
61 const ClipboardEvent& event) {
62 filter_->InjectClipboardEventToClient(event);
63 }
64
65 ClipboardEchoFilter::HostFilter::HostFilter(
66 ClipboardEchoFilter* filter) : filter_(filter) {
67 }
68
69 void ClipboardEchoFilter::HostFilter::InjectClipboardEvent(
70 const ClipboardEvent& event) {
71 filter_->InjectClipboardEventToHost(event);
72 }
73
74 } // namespace protocol
75 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698