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

Side by Side Diff: sky/viewer/platform/platform_impl.cc

Issue 673033002: Remove WebThread (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 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 | « sky/viewer/platform/platform_impl.h ('k') | sky/viewer/platform/webthread_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/viewer/platform/platform_impl.h" 5 #include "sky/viewer/platform/platform_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "mojo/public/cpp/application/application_impl.h" 14 #include "mojo/public/cpp/application/application_impl.h"
15 #include "net/base/data_url.h" 15 #include "net/base/data_url.h"
16 #include "net/base/mime_util.h" 16 #include "net/base/mime_util.h"
17 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
18 #include "sky/engine/public/platform/WebConvertableToTraceFormat.h" 18 #include "sky/engine/public/platform/WebConvertableToTraceFormat.h"
19 #include "sky/engine/public/platform/WebWaitableEvent.h" 19 #include "sky/engine/public/platform/WebWaitableEvent.h"
20 #include "sky/viewer/platform/webthread_impl.h"
21 #include "sky/viewer/platform/weburlloader_impl.h" 20 #include "sky/viewer/platform/weburlloader_impl.h"
22 21
23 namespace sky { 22 namespace sky {
24 namespace { 23 namespace {
25 24
26 class WebWaitableEventImpl : public blink::WebWaitableEvent { 25 class WebWaitableEventImpl : public blink::WebWaitableEvent {
27 public: 26 public:
28 WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {} 27 WebWaitableEventImpl() : impl_(new base::WaitableEvent(false, false)) {}
29 virtual ~WebWaitableEventImpl() {} 28 virtual ~WebWaitableEventImpl() {}
30 29
(...skipping 25 matching lines...) Expand all
56 blink::WebConvertableToTraceFormat convertable_; 55 blink::WebConvertableToTraceFormat convertable_;
57 }; 56 };
58 57
59 } // namespace 58 } // namespace
60 59
61 PlatformImpl::PlatformImpl(mojo::ApplicationImpl* app) 60 PlatformImpl::PlatformImpl(mojo::ApplicationImpl* app)
62 : main_loop_(base::MessageLoop::current()), 61 : main_loop_(base::MessageLoop::current()),
63 shared_timer_func_(NULL), 62 shared_timer_func_(NULL),
64 shared_timer_fire_time_(0.0), 63 shared_timer_fire_time_(0.0),
65 shared_timer_fire_time_was_set_while_suspended_(false), 64 shared_timer_fire_time_was_set_while_suspended_(false),
66 shared_timer_suspended_(0), 65 shared_timer_suspended_(0) {
67 current_thread_slot_(&DestroyCurrentThread) {
68 app->ConnectToService("mojo://network_service/", &network_service_); 66 app->ConnectToService("mojo://network_service/", &network_service_);
69 67
70 mojo::CookieStorePtr cookie_store; 68 mojo::CookieStorePtr cookie_store;
71 network_service_->GetCookieStore(GetProxy(&cookie_store)); 69 network_service_->GetCookieStore(GetProxy(&cookie_store));
72 } 70 }
73 71
74 PlatformImpl::~PlatformImpl() { 72 PlatformImpl::~PlatformImpl() {
75 } 73 }
76 74
77 blink::WebMimeRegistry* PlatformImpl::mimeRegistry() { 75 blink::WebMimeRegistry* PlatformImpl::mimeRegistry() {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 const { 175 const {
178 blink::WebURLError error; 176 blink::WebURLError error;
179 error.domain = blink::WebString::fromUTF8(net::kErrorDomain); 177 error.domain = blink::WebString::fromUTF8(net::kErrorDomain);
180 error.reason = net::ERR_ABORTED; 178 error.reason = net::ERR_ABORTED;
181 error.unreachableURL = url; 179 error.unreachableURL = url;
182 error.staleCopyInCache = false; 180 error.staleCopyInCache = false;
183 error.isCancellation = true; 181 error.isCancellation = true;
184 return error; 182 return error;
185 } 183 }
186 184
187 blink::WebThread* PlatformImpl::currentThread() {
188 WebThreadImplForMessageLoop* thread =
189 static_cast<WebThreadImplForMessageLoop*>(current_thread_slot_.Get());
190 if (thread)
191 return (thread);
192
193 scoped_refptr<base::MessageLoopProxy> message_loop =
194 base::MessageLoopProxy::current();
195 if (!message_loop.get())
196 return NULL;
197
198 thread = new WebThreadImplForMessageLoop(message_loop.get());
199 current_thread_slot_.Set(thread);
200 return thread;
201 }
202
203 blink::WebWaitableEvent* PlatformImpl::createWaitableEvent() { 185 blink::WebWaitableEvent* PlatformImpl::createWaitableEvent() {
204 return new WebWaitableEventImpl(); 186 return new WebWaitableEventImpl();
205 } 187 }
206 188
207 blink::WebWaitableEvent* PlatformImpl::waitMultipleEvents( 189 blink::WebWaitableEvent* PlatformImpl::waitMultipleEvents(
208 const blink::WebVector<blink::WebWaitableEvent*>& web_events) { 190 const blink::WebVector<blink::WebWaitableEvent*>& web_events) {
209 std::vector<base::WaitableEvent*> events; 191 std::vector<base::WaitableEvent*> events;
210 for (size_t i = 0; i < web_events.size(); ++i) 192 for (size_t i = 0; i < web_events.size(); ++i)
211 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl()); 193 events.push_back(static_cast<WebWaitableEventImpl*>(web_events[i])->impl());
212 size_t idx = base::WaitableEvent::WaitMany( 194 size_t idx = base::WaitableEvent::WaitMany(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void PlatformImpl::updateTraceEventDuration( 280 void PlatformImpl::updateTraceEventDuration(
299 const unsigned char* category_group_enabled, 281 const unsigned char* category_group_enabled,
300 const char* name, 282 const char* name,
301 TraceEventHandle handle) { 283 TraceEventHandle handle) {
302 base::debug::TraceEventHandle traceEventHandle; 284 base::debug::TraceEventHandle traceEventHandle;
303 memcpy(&traceEventHandle, &handle, sizeof(handle)); 285 memcpy(&traceEventHandle, &handle, sizeof(handle));
304 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 286 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
305 category_group_enabled, name, traceEventHandle); 287 category_group_enabled, name, traceEventHandle);
306 } 288 }
307 289
308 // static
309 void PlatformImpl::DestroyCurrentThread(void* thread) {
310 WebThreadImplForMessageLoop* impl =
311 static_cast<WebThreadImplForMessageLoop*>(thread);
312 delete impl;
313 }
314
315 } // namespace sky 290 } // namespace sky
OLDNEW
« no previous file with comments | « sky/viewer/platform/platform_impl.h ('k') | sky/viewer/platform/webthread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698