Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / remoting / protocol / clipboard_thread_proxy.h
blobbdb654d677de02ce5534297b6e04fa06f3eabc48
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.
5 // ClipboardThreadProxy is used to allow a Clipboard on the UI thread to invoke
6 // a ClipboardStub on the network thread.
8 #ifndef REMOTING_PROTOCOL_CLIPBOARD_THREAD_PROXY_H_
9 #define REMOTING_PROTOCOL_CLIPBOARD_THREAD_PROXY_H_
11 #include "base/memory/weak_ptr.h"
12 #include "base/task_runner.h"
13 #include "remoting/protocol/clipboard_stub.h"
15 namespace remoting {
16 namespace protocol {
18 class ClipboardThreadProxy : public ClipboardStub {
19 public:
20 ~ClipboardThreadProxy() override;
22 // Constructs a proxy for |clipboard_stub| which will trampoline invocations
23 // to |clipboard_stub_task_runner|.
24 ClipboardThreadProxy(
25 const base::WeakPtr<ClipboardStub>& clipboard_stub,
26 scoped_refptr<base::TaskRunner> clipboard_stub_task_runner);
28 // ClipboardStub implementation.
29 void InjectClipboardEvent(const ClipboardEvent& event) override;
31 private:
32 // Injects a clipboard event into a stub, if the given weak pointer to the
33 // stub is valid.
34 static void InjectClipboardEventStatic(
35 const base::WeakPtr<ClipboardStub>& clipboard_stub,
36 const ClipboardEvent& event);
38 base::WeakPtr<ClipboardStub> clipboard_stub_;
39 scoped_refptr<base::TaskRunner> clipboard_stub_task_runner_;
41 DISALLOW_COPY_AND_ASSIGN(ClipboardThreadProxy);
44 } // namespace protocol
45 } // namespace remoting
47 #endif // REMOTING_PROTOCOL_CLIPBOARD_THREAD_PROXY_H_