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

Side by Side Diff: remoting/host/clipboard_x11.cc

Issue 930403002: Remove remoting::Clipboard::Stop(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/clipboard_win.cc ('k') | remoting/host/input_injector_mac.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 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "remoting/host/linux/x_server_clipboard.h" 12 #include "remoting/host/linux/x_server_clipboard.h"
13 #include "remoting/proto/event.pb.h" 13 #include "remoting/proto/event.pb.h"
14 #include "remoting/protocol/clipboard_stub.h" 14 #include "remoting/protocol/clipboard_stub.h"
15 15
16 namespace remoting { 16 namespace remoting {
17 17
18 // This code is expected to be called on the desktop thread only. 18 // This code is expected to be called on the desktop thread only.
19 class ClipboardX11 : public Clipboard, 19 class ClipboardX11 : public Clipboard,
20 public base::MessageLoopForIO::Watcher { 20 public base::MessageLoopForIO::Watcher {
21 public: 21 public:
22 ClipboardX11(); 22 ClipboardX11();
23 ~ClipboardX11() override; 23 ~ClipboardX11() override;
24 24
25 // Clipboard interface. 25 // Clipboard interface.
26 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; 26 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override;
27 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override; 27 void InjectClipboardEvent(const protocol::ClipboardEvent& event) override;
28 void Stop() override;
29 28
30 // MessageLoopForIO::Watcher interface. 29 // MessageLoopForIO::Watcher interface.
31 void OnFileCanReadWithoutBlocking(int fd) override; 30 void OnFileCanReadWithoutBlocking(int fd) override;
32 void OnFileCanWriteWithoutBlocking(int fd) override; 31 void OnFileCanWriteWithoutBlocking(int fd) override;
33 32
34 private: 33 private:
35 void OnClipboardChanged(const std::string& mime_type, 34 void OnClipboardChanged(const std::string& mime_type,
36 const std::string& data); 35 const std::string& data);
37 void PumpXEvents(); 36 void PumpXEvents();
38 37
(...skipping 10 matching lines...) Expand all
49 base::MessageLoopForIO::FileDescriptorWatcher x_connection_watcher_; 48 base::MessageLoopForIO::FileDescriptorWatcher x_connection_watcher_;
50 49
51 DISALLOW_COPY_AND_ASSIGN(ClipboardX11); 50 DISALLOW_COPY_AND_ASSIGN(ClipboardX11);
52 }; 51 };
53 52
54 ClipboardX11::ClipboardX11() 53 ClipboardX11::ClipboardX11()
55 : display_(nullptr) { 54 : display_(nullptr) {
56 } 55 }
57 56
58 ClipboardX11::~ClipboardX11() { 57 ClipboardX11::~ClipboardX11() {
59 Stop(); 58 if (display_)
59 XCloseDisplay(display_);
60 } 60 }
61 61
62 void ClipboardX11::Start( 62 void ClipboardX11::Start(
63 scoped_ptr<protocol::ClipboardStub> client_clipboard) { 63 scoped_ptr<protocol::ClipboardStub> client_clipboard) {
64 // TODO(lambroslambrou): Share the X connection with InputInjector. 64 // TODO(lambroslambrou): Share the X connection with InputInjector.
65 display_ = XOpenDisplay(nullptr); 65 display_ = XOpenDisplay(nullptr);
66 if (!display_) { 66 if (!display_) {
67 LOG(ERROR) << "Couldn't open X display"; 67 LOG(ERROR) << "Couldn't open X display";
68 return; 68 return;
69 } 69 }
(...skipping 10 matching lines...) Expand all
80 &x_connection_watcher_, 80 &x_connection_watcher_,
81 this); 81 this);
82 PumpXEvents(); 82 PumpXEvents();
83 } 83 }
84 84
85 void ClipboardX11::InjectClipboardEvent( 85 void ClipboardX11::InjectClipboardEvent(
86 const protocol::ClipboardEvent& event) { 86 const protocol::ClipboardEvent& event) {
87 x_server_clipboard_.SetClipboard(event.mime_type(), event.data()); 87 x_server_clipboard_.SetClipboard(event.mime_type(), event.data());
88 } 88 }
89 89
90 void ClipboardX11::Stop() {
91 client_clipboard_.reset();
92 x_connection_watcher_.StopWatchingFileDescriptor();
93
94 if (display_) {
95 XCloseDisplay(display_);
96 display_ = nullptr;
97 }
98 }
99
100 void ClipboardX11::OnFileCanReadWithoutBlocking(int fd) { 90 void ClipboardX11::OnFileCanReadWithoutBlocking(int fd) {
101 PumpXEvents(); 91 PumpXEvents();
102 } 92 }
103 93
104 void ClipboardX11::OnFileCanWriteWithoutBlocking(int fd) { 94 void ClipboardX11::OnFileCanWriteWithoutBlocking(int fd) {
105 } 95 }
106 96
107 void ClipboardX11::OnClipboardChanged(const std::string& mime_type, 97 void ClipboardX11::OnClipboardChanged(const std::string& mime_type,
108 const std::string& data) { 98 const std::string& data) {
109 protocol::ClipboardEvent event; 99 protocol::ClipboardEvent event;
(...skipping 13 matching lines...) Expand all
123 XNextEvent(display_, &event); 113 XNextEvent(display_, &event);
124 x_server_clipboard_.ProcessXEvent(&event); 114 x_server_clipboard_.ProcessXEvent(&event);
125 } 115 }
126 } 116 }
127 117
128 scoped_ptr<Clipboard> Clipboard::Create() { 118 scoped_ptr<Clipboard> Clipboard::Create() {
129 return make_scoped_ptr(new ClipboardX11()); 119 return make_scoped_ptr(new ClipboardX11());
130 } 120 }
131 121
132 } // namespace remoting 122 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/clipboard_win.cc ('k') | remoting/host/input_injector_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698