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

Side by Side Diff: sky/engine/testing/platform/platform_impl.cc

Issue 681173002: Delete WebWaitableEvent (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « sky/engine/testing/platform/platform_impl.h ('k') | sky/viewer/platform/platform_impl.h » ('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 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 #include "sky/engine/testing/platform/platform_impl.h" 5 #include "sky/engine/testing/platform/platform_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "net/base/data_url.h" 13 #include "net/base/data_url.h"
14 #include "net/base/mime_util.h" 14 #include "net/base/mime_util.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "sky/engine/public/platform/WebWaitableEvent.h"
17 16
18 namespace sky { 17 namespace sky {
19 namespace {
20
21 class WebWaitableEventImpl : public blink::WebWaitableEvent {
22 public:
23 WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {}
24 virtual ~WebWaitableEventImpl() {}
25
26 virtual void wait() { impl_->Wait(); }
27 virtual void signal() { impl_->Signal(); }
28
29 base::WaitableEvent* impl() {
30 return impl_.get();
31 }
32
33 private:
34 scoped_ptr<base::WaitableEvent> impl_;
35 DISALLOW_COPY_AND_ASSIGN(WebWaitableEventImpl);
36 };
37
38 } // namespace
39 18
40 PlatformImpl::PlatformImpl() 19 PlatformImpl::PlatformImpl()
41 : main_loop_(base::MessageLoop::current()), 20 : main_loop_(base::MessageLoop::current()),
42 shared_timer_func_(NULL), 21 shared_timer_func_(NULL),
43 shared_timer_fire_time_(0.0), 22 shared_timer_fire_time_(0.0),
44 shared_timer_fire_time_was_set_while_suspended_(false), 23 shared_timer_fire_time_was_set_while_suspended_(false),
45 shared_timer_suspended_(0) { 24 shared_timer_suspended_(0) {
46 } 25 }
47 26
48 PlatformImpl::~PlatformImpl() { 27 PlatformImpl::~PlatformImpl() {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 std::string mimetype, charset, data; 117 std::string mimetype, charset, data;
139 if (net::DataURL::Parse(url, &mimetype, &charset, &data) 118 if (net::DataURL::Parse(url, &mimetype, &charset, &data)
140 && net::IsSupportedMimeType(mimetype)) { 119 && net::IsSupportedMimeType(mimetype)) {
141 mimetype_out = blink::WebString::fromUTF8(mimetype); 120 mimetype_out = blink::WebString::fromUTF8(mimetype);
142 charset_out = blink::WebString::fromUTF8(charset); 121 charset_out = blink::WebString::fromUTF8(charset);
143 return data; 122 return data;
144 } 123 }
145 return blink::WebData(); 124 return blink::WebData();
146 } 125 }
147 126
148 blink::WebWaitableEvent* PlatformImpl::createWaitableEvent() {
149 return new WebWaitableEventImpl();
150 }
151
152 blink::WebWaitableEvent* PlatformImpl::waitMultipleEvents(
153 const blink::WebVector<blink::WebWaitableEvent*>& web_events) {
154 std::vector<base::WaitableEvent*> events;
155 for (size_t i = 0; i < web_events.size(); ++i)
156 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl());
157 size_t idx = base::WaitableEvent::WaitMany(
158 vector_as_array(&events), events.size());
159 DCHECK_LT(idx, web_events.size());
160 return web_events[idx];
161 }
162
163 } // namespace sky 127 } // namespace sky
OLDNEW
« no previous file with comments | « sky/engine/testing/platform/platform_impl.h ('k') | sky/viewer/platform/platform_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698