blob: aeae757bec009e32aa05b9ce8cdb0064f22ea37b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_
#define MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_local_storage.h"
#include "base/timer/timer.h"
#include "cc/blink/web_compositor_support_impl.h"
#include "mojo/services/html_viewer/webmimeregistry_impl.h"
#include "mojo/services/html_viewer/webthemeengine_impl.h"
#include "mojo/services/public/interfaces/network/network_service.mojom.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebScrollbarBehavior.h"
namespace mojo {
class ApplicationImpl;
class WebCookieJarImpl;
class BlinkPlatformImpl : public blink::Platform {
public:
explicit BlinkPlatformImpl(ApplicationImpl* app);
virtual ~BlinkPlatformImpl();
// blink::Platform methods:
virtual blink::WebCookieJar* cookieJar();
virtual blink::WebMimeRegistry* mimeRegistry();
virtual blink::WebThemeEngine* themeEngine();
virtual blink::WebString defaultLocale();
virtual double currentTime();
virtual double monotonicallyIncreasingTime();
virtual void cryptographicallyRandomValues(
unsigned char* buffer, size_t length);
virtual void setSharedTimerFiredFunction(void (*func)());
virtual void setSharedTimerFireInterval(double interval_seconds);
virtual void stopSharedTimer();
virtual void callOnMainThread(void (*func)(void*), void* context);
virtual bool isThreadedCompositingEnabled();
virtual blink::WebCompositorSupport* compositorSupport();
virtual blink::WebURLLoader* createURLLoader();
virtual blink::WebSocketHandle* createWebSocketHandle();
virtual blink::WebString userAgent();
virtual blink::WebData parseDataURL(
const blink::WebURL& url, blink::WebString& mime_type,
blink::WebString& charset);
virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
virtual blink::WebThread* createThread(const char* name);
virtual blink::WebThread* currentThread();
virtual blink::WebWaitableEvent* createWaitableEvent();
virtual blink::WebWaitableEvent* waitMultipleEvents(
const blink::WebVector<blink::WebWaitableEvent*>& events);
virtual blink::WebScrollbarBehavior* scrollbarBehavior();
virtual const unsigned char* getTraceCategoryEnabledFlag(
const char* category_name);
private:
void SuspendSharedTimer();
void ResumeSharedTimer();
void DoTimeout() {
if (shared_timer_func_ && !shared_timer_suspended_)
shared_timer_func_();
}
static void DestroyCurrentThread(void*);
NetworkServicePtr network_service_;
base::MessageLoop* main_loop_;
base::OneShotTimer<BlinkPlatformImpl> shared_timer_;
void (*shared_timer_func_)();
double shared_timer_fire_time_;
bool shared_timer_fire_time_was_set_while_suspended_;
int shared_timer_suspended_; // counter
base::ThreadLocalStorage::Slot current_thread_slot_;
cc_blink::WebCompositorSupportImpl compositor_support_;
WebThemeEngineImpl theme_engine_;
scoped_ptr<WebCookieJarImpl> cookie_jar_;
WebMimeRegistryImpl mime_registry_;
blink::WebScrollbarBehavior scrollbar_behavior_;
DISALLOW_COPY_AND_ASSIGN(BlinkPlatformImpl);
};
} // namespace mojo
#endif // MOJO_SERVICES_HTML_VIEWER_BLINK_PLATFORM_IMPL_H_
|