As discussed offline, we'll have this class suppress local echos, but
not duplicates.
> I considered using "local/remote" rather than "host/client", but (i)
we won't
> use this class on the client, as the filter is already implemented in
the
> webapp, where it can be changed more easily if needed, and (ii) I
think "host"
> and "client" are less likely to be confused than "local" and "remote".
This helper's not intrinsically tied to being a host-side component - we
could equally well use it in the client plugin, except that we already
have code in the JS to do this work. It suppresses echos of content you
inject locally from being re-transmitted remotely, so I think local &
remote are more appropriate names.
That said, since we will use it only in hosts initially, client & host
are valid and we can agree to disagree. ;)
> An echo is a duplicate, so I'm not sure there's much to be gained by
renaming
> ClipboardDuplicateFilter to ClipboardEchoFilter.
ClipboardEchoFilter makes sense if all we do is filter echos, and is
shorter. ;) I'm fine with duplicate, too, but consider renaming to
DuplicateClipboardFilter (i.e. word ordering more akin to spoken
English).
> > Is there no way to filter echos in the per-platform implementations,
e.g. by
> > putting a custom clipboard format alongside the real data, so that
we can
> > distinguish local vs echo changes?
> I expect there is. But is there a good reason to implement the
functionality
> separately on each platform, instead of using platform-independent
code, as in
> this CL?
As discussed offline, the benefit is in being able to disambiguate echos
of injected content from host-side copy operations without actually
comparing the content. The comparing scheme should be fine, but we can
revisit other options if we hit problems.
http://codereview.chromium.org/10399052/diff/1/remoting/protocol/clipboard_duplicate_filter.h#newcode18
remoting/protocol/clipboard_duplicate_filter.h:18: // client, if it
knows that the client already has that item on its clipboard.
On 2012/05/16 20:51:43, Wez wrote:
> I don't think the filter behaviour actually needs to differ between
client->host
> and host->client, in which case I think you can simplify this class,
e.g:
> .h:
> class ClipboardDeduplicator {
> ...
> ClipboardFilter* host_filter();
> ClipboardFilter* client_filter();
Please consider this change to derived the filter implementations from
ClipboardFilter, so that you don't then need a separate
set_client_stub() on ClipboardDuplicateFilter.
> Is there no way to filter echos in the per-platform implementations,
e.g. by
> putting a custom clipboard format alongside the real data, so that we
can
> distinguish local vs echo changes?
http://codereview.chromium.org/10399052/diff/1/remoting/protocol/clipboard_duplicate_filter.h#newcode57
remoting/protocol/clipboard_duplicate_filter.h:57: void
InjectClipboardEventToClient(const ClipboardEvent& event);
nit: If we're moving to just have this class suppress echos then you
could replace these with StoreClipboardFromClient() and
IsEchoOfClientClipboard(), for the InjectClipboard() methods on the
filters to use.
http://codereview.chromium.org/10399052/diff/5001/remoting/protocol/clipboard_duplicate_filter.cc
File remoting/protocol/clipboard_duplicate_filter.cc (right):
http://codereview.chromium.org/10399052/diff/5001/remoting/protocol/clipboard_duplicate_filter.cc#newcode1
remoting/protocol/clipboard_duplicate_filter.cc:1: #include
"remoting/protocol/clipboard_duplicate_filter.h"
Copyright notice?
http://codereview.chromium.org/10399052/diff/5001/remoting/protocol/clipboard_duplicate_filter.h
File remoting/protocol/clipboard_duplicate_filter.h (right):
http://codereview.chromium.org/10399052/diff/5001/remoting/protocol/clipboard_duplicate_filter.h#newcode62
remoting/protocol/clipboard_duplicate_filter.h:62: HostFilter
host_filter_;
If you make these scoped_ptr<Client/HostFilter>, or
scoped_ptr<ClipboardFilter>, then you can move the filter class
definitions into the .cc.
http://codereview.chromium.org/10399052/diff/5001/remoting/protocol/clipboard_duplicate_filter.h#newcode66
remoting/protocol/clipboard_duplicate_filter.h:66: std::string
recent_data_;
nit: Since these will now reflect the most recent clipboard from the
client, consider |client_[latest_]mime_type_| and
|client_[latest_]data_|
http://codereview.chromium.org/10399052/diff/5001/remoting/protocol/clipboard_duplicate_filter_unittest.cc
File remoting/protocol/clipboard_duplicate_filter_unittest.cc (right):
http://codereview.chromium.org/10399052/diff/5001/remoting/protocol/clipboard_duplicate_filter_unittest.cc#newcode32
remoting/protocol/clipboard_duplicate_filter_unittest.cc:32:
TEST(ClipboardDuplicateFilterTest,
FromClientBlocksIdenticalEventToClient) {
I'll review the unit-tests after you've update the implementation to
remove the host-duplicate suppression.
http://codereview.chromium.org/10399052/