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

Side by Side Diff: ui/ozone/platform/wayland/fake_server.h

Issue 2431123003: Revert of Use FileDescriptorWatcher in wl::FakeServer. (patchset #1 id:1 of https://codereview.chro… (Closed)
Patch Set: Created 4 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 | « no previous file | ui/ozone/platform/wayland/fake_server.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ 5 #ifndef UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_
6 #define UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ 6 #define UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_
7 7
8 #include <wayland-server-core.h> 8 #include <wayland-server-core.h>
9 9
10 #include <memory>
11
12 #include "base/bind.h" 10 #include "base/bind.h"
13 #include "base/files/file_descriptor_watcher_posix.h" 11 #include "base/message_loop/message_pump_libevent.h"
14 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
15 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
16 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
17 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
18 16
19 struct wl_client; 17 struct wl_client;
20 struct wl_display; 18 struct wl_display;
21 struct wl_event_loop; 19 struct wl_event_loop;
22 struct wl_global; 20 struct wl_global;
23 struct wl_resource; 21 struct wl_resource;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 MOCK_METHOD1(Pong, void(uint32_t serial)); 175 MOCK_METHOD1(Pong, void(uint32_t serial));
178 176
179 private: 177 private:
180 DISALLOW_COPY_AND_ASSIGN(MockXdgShell); 178 DISALLOW_COPY_AND_ASSIGN(MockXdgShell);
181 }; 179 };
182 180
183 struct DisplayDeleter { 181 struct DisplayDeleter {
184 void operator()(wl_display* display); 182 void operator()(wl_display* display);
185 }; 183 };
186 184
187 class FakeServer : public base::Thread { 185 class FakeServer : public base::Thread, base::MessagePumpLibevent::Watcher {
188 public: 186 public:
189 FakeServer(); 187 FakeServer();
190 ~FakeServer() override; 188 ~FakeServer() override;
191 189
192 // Start the fake Wayland server. If this succeeds, the WAYLAND_SOCKET 190 // Start the fake Wayland server. If this succeeds, the WAYLAND_SOCKET
193 // environment variable will be set to the string representation of a file 191 // environment variable will be set to the string representation of a file
194 // descriptor that a client can connect to. The caller is responsible for 192 // descriptor that a client can connect to. The caller is responsible for
195 // ensuring that this file descriptor gets closed (for example, by calling 193 // ensuring that this file descriptor gets closed (for example, by calling
196 // wl_display_connect). 194 // wl_display_connect).
197 bool Start(); 195 bool Start();
(...skipping 10 matching lines...) Expand all
208 return resource ? T::FromResource(resource) : nullptr; 206 return resource ? T::FromResource(resource) : nullptr;
209 } 207 }
210 208
211 MockSeat* seat() { return &seat_; } 209 MockSeat* seat() { return &seat_; }
212 MockXdgShell* xdg_shell() { return &xdg_shell_; } 210 MockXdgShell* xdg_shell() { return &xdg_shell_; }
213 MockOutput* output() { return &output_; } 211 MockOutput* output() { return &output_; }
214 212
215 private: 213 private:
216 void DoPause(); 214 void DoPause();
217 215
218 void StartWatchingFileDescriptor(); 216 std::unique_ptr<base::MessagePump> CreateMessagePump();
219 217
220 void OnFileCanReadWithoutBlocking(); 218 // base::MessagePumpLibevent::Watcher
219 void OnFileCanReadWithoutBlocking(int fd) override;
220 void OnFileCanWriteWithoutBlocking(int fd) override;
221 221
222 std::unique_ptr<wl_display, DisplayDeleter> display_; 222 std::unique_ptr<wl_display, DisplayDeleter> display_;
223 wl_client* client_ = nullptr; 223 wl_client* client_ = nullptr;
224 wl_event_loop* event_loop_ = nullptr; 224 wl_event_loop* event_loop_ = nullptr;
225 225
226 base::WaitableEvent pause_event_; 226 base::WaitableEvent pause_event_;
227 base::WaitableEvent resume_event_; 227 base::WaitableEvent resume_event_;
228 228
229 // Represent Wayland global objects 229 // Represent Wayland global objects
230 MockCompositor compositor_; 230 MockCompositor compositor_;
231 MockOutput output_; 231 MockOutput output_;
232 MockSeat seat_; 232 MockSeat seat_;
233 MockXdgShell xdg_shell_; 233 MockXdgShell xdg_shell_;
234 234
235 std::unique_ptr<base::FileDescriptorWatcher::Controller> controller_; 235 base::MessagePumpLibevent::FileDescriptorWatcher controller_;
236 236
237 DISALLOW_COPY_AND_ASSIGN(FakeServer); 237 DISALLOW_COPY_AND_ASSIGN(FakeServer);
238 }; 238 };
239 239
240 } // namespace wl 240 } // namespace wl
241 241
242 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_ 242 #endif // UI_OZONE_PLATFORM_WAYLAND_FAKE_SERVER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/ozone/platform/wayland/fake_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698