OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef REMOTING_HOST_CLIPBOARD_AURA_H_ | 5 #ifndef REMOTING_HOST_CLIPBOARD_AURA_H_ |
6 #define REMOTING_HOST_CLIPBOARD_AURA_H_ | 6 #define REMOTING_HOST_CLIPBOARD_AURA_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/threading/thread_checker.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/timer/timer.h" | |
11 #include "remoting/host/clipboard.h" | 10 #include "remoting/host/clipboard.h" |
12 | 11 |
13 namespace remoting { | 12 namespace remoting { |
14 | 13 |
15 namespace protocol { | 14 namespace protocol { |
16 class ClipboardStub; | 15 class ClipboardStub; |
17 } // namespace protocol | 16 } // namespace protocol |
18 | 17 |
19 // On Chrome OS, the clipboard is managed by aura instead of the underlying | 18 // On Chrome OS, the clipboard is managed by aura instead of the underlying |
20 // native platform (e.g. x11, ozone, etc). | 19 // native platform (e.g. x11, ozone, etc). |
21 // | 20 // |
22 // This class (1) monitors the aura clipboard for changes and notifies the | 21 // This class (1) monitors the aura clipboard for changes and notifies the |
23 // |client_clipboard|, and (2) provides an interface to inject clipboard event | 22 // |client_clipboard|, and (2) provides an interface to inject clipboard event |
24 // into aura. | 23 // into aura. |
25 // | 24 // |
26 // The public API of this class can be called in any thread as internally it | 25 // The public API of this class can be called in any thread as internally it |
27 // always posts the call to the |ui_task_runner|. On ChromeOS, that should | 26 // always posts the call to the |ui_task_runner|. On ChromeOS, that should |
28 // be the UI thread of the browser process. | 27 // be the UI thread of the browser process. |
| 28 // |
29 class ClipboardAura : public Clipboard { | 29 class ClipboardAura : public Clipboard { |
30 public: | 30 public: |
31 explicit ClipboardAura(); | 31 explicit ClipboardAura( |
| 32 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
32 ~ClipboardAura() override; | 33 ~ClipboardAura() override; |
33 | 34 |
34 // Clipboard interface. | 35 // Clipboard interface. |
35 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; | 36 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; |
36 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; | 37 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; |
37 void Stop() override; | 38 void Stop() override; |
38 | 39 |
39 // Overrides the clipboard polling interval for unit test. | 40 // Overrides the clipboard polling interval for unit test. |
40 void SetPollingIntervalForTesting(base::TimeDelta polling_interval); | 41 void SetPollingIntervalForTesting(base::TimeDelta polling_interval); |
41 | 42 |
42 private: | 43 private: |
43 void CheckClipboardForChanges(); | 44 class Core; |
44 | 45 |
45 base::ThreadChecker thread_checker_; | 46 scoped_ptr<Core> core_; |
46 scoped_ptr<protocol::ClipboardStub> client_clipboard_; | 47 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
47 base::RepeatingTimer<ClipboardAura> clipboard_polling_timer_; | |
48 uint64 current_change_count_; | |
49 base::TimeDelta polling_interval_; | |
50 | 48 |
51 DISALLOW_COPY_AND_ASSIGN(ClipboardAura); | 49 DISALLOW_COPY_AND_ASSIGN(ClipboardAura); |
52 }; | 50 }; |
53 | 51 |
54 } // namespace remoting | 52 } // namespace remoting |
55 | 53 |
56 #endif // REMOTING_HOST_CLIPBOARD_AURA_H_ | 54 #endif // REMOTING_HOST_CLIPBOARD_AURA_H_ |
OLD | NEW |