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

Side by Side Diff: remoting/host/clipboard_mac.mm

Issue 1355063004: Template methods on Timer classes instead of the classes themselves. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: timer: fixcaller Created 5 years, 2 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
« no previous file with comments | « remoting/host/client_session.h ('k') | remoting/host/config_file_watcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "remoting/host/clipboard.h" 5 #include "remoting/host/clipboard.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 19 matching lines...) Expand all
30 ClipboardMac(); 30 ClipboardMac();
31 ~ClipboardMac() override; 31 ~ClipboardMac() override;
32 32
33 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; 33 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override;
34 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; 34 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override;
35 35
36 private: 36 private:
37 void CheckClipboardForChanges(); 37 void CheckClipboardForChanges();
38 38
39 scoped_ptr<protocol::ClipboardStub> client_clipboard_; 39 scoped_ptr<protocol::ClipboardStub> client_clipboard_;
40 scoped_ptr<base::RepeatingTimer<ClipboardMac> > clipboard_polling_timer_; 40 scoped_ptr<base::RepeatingTimer> clipboard_polling_timer_;
41 NSInteger current_change_count_; 41 NSInteger current_change_count_;
42 42
43 DISALLOW_COPY_AND_ASSIGN(ClipboardMac); 43 DISALLOW_COPY_AND_ASSIGN(ClipboardMac);
44 }; 44 };
45 45
46 ClipboardMac::ClipboardMac() : current_change_count_(0) {} 46 ClipboardMac::ClipboardMac() : current_change_count_(0) {}
47 47
48 ClipboardMac::~ClipboardMac() {} 48 ClipboardMac::~ClipboardMac() {}
49 49
50 void ClipboardMac::Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) { 50 void ClipboardMac::Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) {
51 client_clipboard_.reset(client_clipboard.release()); 51 client_clipboard_.reset(client_clipboard.release());
52 52
53 // Synchronize local change-count with the pasteboard's. The change-count is 53 // Synchronize local change-count with the pasteboard's. The change-count is
54 // used to detect clipboard changes. 54 // used to detect clipboard changes.
55 current_change_count_ = [[NSPasteboard generalPasteboard] changeCount]; 55 current_change_count_ = [[NSPasteboard generalPasteboard] changeCount];
56 56
57 // OS X doesn't provide a clipboard-changed notification. The only way to 57 // OS X doesn't provide a clipboard-changed notification. The only way to
58 // detect clipboard changes is by polling. 58 // detect clipboard changes is by polling.
59 clipboard_polling_timer_.reset(new base::RepeatingTimer<ClipboardMac>()); 59 clipboard_polling_timer_.reset(new base::RepeatingTimer());
60 clipboard_polling_timer_->Start(FROM_HERE, 60 clipboard_polling_timer_->Start(FROM_HERE,
61 base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs), 61 base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs),
62 this, &ClipboardMac::CheckClipboardForChanges); 62 this, &ClipboardMac::CheckClipboardForChanges);
63 } 63 }
64 64
65 void ClipboardMac::InjectClipboardEvent(const protocol::ClipboardEvent& event) { 65 void ClipboardMac::InjectClipboardEvent(const protocol::ClipboardEvent& event) {
66 // Currently we only handle UTF-8 text. 66 // Currently we only handle UTF-8 text.
67 if (event.mime_type().compare(kMimeTypeTextUtf8) != 0) 67 if (event.mime_type().compare(kMimeTypeTextUtf8) != 0)
68 return; 68 return;
69 if (!StringIsUtf8(event.data().c_str(), event.data().length())) { 69 if (!StringIsUtf8(event.data().c_str(), event.data().length())) {
(...skipping 30 matching lines...) Expand all
100 event.set_mime_type(kMimeTypeTextUtf8); 100 event.set_mime_type(kMimeTypeTextUtf8);
101 event.set_data(base::SysNSStringToUTF8(data)); 101 event.set_data(base::SysNSStringToUTF8(data));
102 client_clipboard_->InjectClipboardEvent(event); 102 client_clipboard_->InjectClipboardEvent(event);
103 } 103 }
104 104
105 scoped_ptr<Clipboard> Clipboard::Create() { 105 scoped_ptr<Clipboard> Clipboard::Create() {
106 return make_scoped_ptr(new ClipboardMac()); 106 return make_scoped_ptr(new ClipboardMac());
107 } 107 }
108 108
109 } // namespace remoting 109 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/client_session.h ('k') | remoting/host/config_file_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698