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