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

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
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 client_clipboard_.reset();
Lambros 2015/02/17 21:37:33 Don't need?
Sergey Ulanov 2015/02/17 23:51:42 Done.
59 x_connection_watcher_.StopWatchingFileDescriptor();
60
61 if (display_) {
62 XCloseDisplay(display_);
63 display_ = nullptr;
Lambros 2015/02/17 21:37:33 Don't need?
Sergey Ulanov 2015/02/17 23:51:42 Done.
64 }
60 } 65 }
61 66
62 void ClipboardX11::Start( 67 void ClipboardX11::Start(
63 scoped_ptr<protocol::ClipboardStub> client_clipboard) { 68 scoped_ptr<protocol::ClipboardStub> client_clipboard) {
64 // TODO(lambroslambrou): Share the X connection with InputInjector. 69 // TODO(lambroslambrou): Share the X connection with InputInjector.
65 display_ = XOpenDisplay(nullptr); 70 display_ = XOpenDisplay(nullptr);
66 if (!display_) { 71 if (!display_) {
67 LOG(ERROR) << "Couldn't open X display"; 72 LOG(ERROR) << "Couldn't open X display";
68 return; 73 return;
69 } 74 }
(...skipping 10 matching lines...) Expand all
80 &x_connection_watcher_, 85 &x_connection_watcher_,
81 this); 86 this);
82 PumpXEvents(); 87 PumpXEvents();
83 } 88 }
84 89
85 void ClipboardX11::InjectClipboardEvent( 90 void ClipboardX11::InjectClipboardEvent(
86 const protocol::ClipboardEvent& event) { 91 const protocol::ClipboardEvent& event) {
87 x_server_clipboard_.SetClipboard(event.mime_type(), event.data()); 92 x_server_clipboard_.SetClipboard(event.mime_type(), event.data());
88 } 93 }
89 94
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) { 95 void ClipboardX11::OnFileCanReadWithoutBlocking(int fd) {
101 PumpXEvents(); 96 PumpXEvents();
102 } 97 }
103 98
104 void ClipboardX11::OnFileCanWriteWithoutBlocking(int fd) { 99 void ClipboardX11::OnFileCanWriteWithoutBlocking(int fd) {
105 } 100 }
106 101
107 void ClipboardX11::OnClipboardChanged(const std::string& mime_type, 102 void ClipboardX11::OnClipboardChanged(const std::string& mime_type,
108 const std::string& data) { 103 const std::string& data) {
109 protocol::ClipboardEvent event; 104 protocol::ClipboardEvent event;
(...skipping 13 matching lines...) Expand all
123 XNextEvent(display_, &event); 118 XNextEvent(display_, &event);
124 x_server_clipboard_.ProcessXEvent(&event); 119 x_server_clipboard_.ProcessXEvent(&event);
125 } 120 }
126 } 121 }
127 122
128 scoped_ptr<Clipboard> Clipboard::Create() { 123 scoped_ptr<Clipboard> Clipboard::Create() {
129 return make_scoped_ptr(new ClipboardX11()); 124 return make_scoped_ptr(new ClipboardX11());
130 } 125 }
131 126
132 } // namespace remoting 127 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698