[Ozone-Gbm] Explicitly crash if trying software rendering on GBM
[chromium-blink-merge.git] / content / renderer / renderer_blink_platform_impl.h
blobae8cb46bc908a6f80a58cb72478bbc24613a3623
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_RENDERER_BLINK_PLATFORM_IMPL_H_
6 #define CONTENT_RENDERER_RENDERER_BLINK_PLATFORM_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "base/id_map.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/blink/web_compositor_support_impl.h"
12 #include "content/child/blink_platform_impl.h"
13 #include "content/common/content_export.h"
14 #include "content/renderer/webpublicsuffixlist_impl.h"
15 #include "device/vibration/vibration_manager.mojom.h"
16 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
17 #include "third_party/WebKit/public/platform/WebIDBFactory.h"
18 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
20 namespace base {
21 class MessageLoopProxy;
24 namespace cc {
25 class ContextProvider;
28 namespace IPC {
29 class SyncMessageFilter;
32 namespace blink {
33 class WebBatteryStatus;
34 class WebDeviceMotionData;
35 class WebDeviceOrientationData;
36 class WebGraphicsContext3DProvider;
39 namespace content {
40 class BatteryStatusDispatcher;
41 class DeviceLightEventPump;
42 class DeviceMotionEventPump;
43 class DeviceOrientationEventPump;
44 class PlatformEventObserverBase;
45 class QuotaMessageFilter;
46 class RendererClipboardDelegate;
47 class RendererScheduler;
48 class RenderView;
49 class ThreadSafeSender;
50 class WebClipboardImpl;
51 class WebDatabaseObserverImpl;
52 class WebFileSystemImpl;
53 class WebThreadImplForScheduler;
54 class WebSchedulerImpl;
56 class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
57 public:
58 explicit RendererBlinkPlatformImpl(RendererScheduler* renderer_scheduler);
59 virtual ~RendererBlinkPlatformImpl();
61 void set_plugin_refresh_allowed(bool plugin_refresh_allowed) {
62 plugin_refresh_allowed_ = plugin_refresh_allowed;
64 // Platform methods:
65 virtual blink::WebClipboard* clipboard();
66 virtual blink::WebMimeRegistry* mimeRegistry();
67 virtual blink::WebFileUtilities* fileUtilities();
68 virtual blink::WebSandboxSupport* sandboxSupport();
69 virtual blink::WebCookieJar* cookieJar();
70 virtual blink::WebThemeEngine* themeEngine();
71 virtual blink::WebSpeechSynthesizer* createSpeechSynthesizer(
72 blink::WebSpeechSynthesizerClient* client);
73 virtual bool sandboxEnabled();
74 virtual unsigned long long visitedLinkHash(
75 const char* canonicalURL, size_t length);
76 virtual bool isLinkVisited(unsigned long long linkHash);
77 virtual void createMessageChannel(blink::WebMessagePortChannel** channel1,
78 blink::WebMessagePortChannel** channel2);
79 virtual blink::WebPrescientNetworking* prescientNetworking();
80 virtual void cacheMetadata(const blink::WebURL&, int64, const char*, size_t);
81 virtual blink::WebString defaultLocale();
82 virtual void suddenTerminationChanged(bool enabled);
83 virtual blink::WebStorageNamespace* createLocalStorageNamespace();
84 virtual blink::Platform::FileHandle databaseOpenFile(
85 const blink::WebString& vfs_file_name, int desired_flags);
86 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
87 bool sync_dir);
88 virtual long databaseGetFileAttributes(
89 const blink::WebString& vfs_file_name);
90 virtual long long databaseGetFileSize(
91 const blink::WebString& vfs_file_name);
92 virtual long long databaseGetSpaceAvailableForOrigin(
93 const blink::WebString& origin_identifier);
94 virtual blink::WebString signedPublicKeyAndChallengeString(
95 unsigned key_size_index,
96 const blink::WebString& challenge,
97 const blink::WebURL& url);
98 virtual void getPluginList(bool refresh,
99 blink::WebPluginListBuilder* builder);
100 virtual blink::WebPublicSuffixList* publicSuffixList();
101 virtual void screenColorProfile(blink::WebVector<char>* to_profile);
102 virtual blink::WebScrollbarBehavior* scrollbarBehavior();
103 virtual blink::WebIDBFactory* idbFactory();
104 virtual blink::WebFileSystem* fileSystem();
105 virtual bool canAccelerate2dCanvas();
106 virtual bool isThreadedCompositingEnabled();
107 virtual double audioHardwareSampleRate();
108 virtual size_t audioHardwareBufferSize();
109 virtual unsigned audioHardwareOutputChannels();
110 virtual blink::WebDatabaseObserver* databaseObserver();
112 virtual blink::WebAudioDevice* createAudioDevice(
113 size_t buffer_size, unsigned input_channels, unsigned channels,
114 double sample_rate, blink::WebAudioDevice::RenderCallback* callback,
115 const blink::WebString& input_device_id);
117 virtual bool loadAudioResource(
118 blink::WebAudioBus* destination_bus, const char* audio_file_data,
119 size_t data_size);
121 virtual blink::WebMIDIAccessor*
122 createMIDIAccessor(blink::WebMIDIAccessorClient* client);
124 virtual blink::WebBlobRegistry* blobRegistry();
125 virtual void sampleGamepads(blink::WebGamepads&);
126 virtual blink::WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(
127 blink::WebRTCPeerConnectionHandlerClient* client);
128 virtual blink::WebMediaStreamCenter* createMediaStreamCenter(
129 blink::WebMediaStreamCenterClient* client);
130 virtual bool processMemorySizesInBytes(
131 size_t* private_bytes, size_t* shared_bytes);
132 virtual blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
133 const blink::WebGraphicsContext3D::Attributes& attributes);
134 virtual blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
135 const blink::WebGraphicsContext3D::Attributes& attributes,
136 blink::WebGraphicsContext3D* share_context);
137 virtual blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
138 const blink::WebGraphicsContext3D::Attributes& attributes,
139 blink::WebGraphicsContext3D* share_context,
140 blink::WebGLInfo* gl_info);
141 virtual blink::WebGraphicsContext3DProvider*
142 createSharedOffscreenGraphicsContext3DProvider();
143 virtual blink::WebCompositorSupport* compositorSupport();
144 virtual blink::WebString convertIDNToUnicode(
145 const blink::WebString& host, const blink::WebString& languages);
146 virtual void startListening(blink::WebPlatformEventType,
147 blink::WebPlatformEventListener*);
148 virtual void stopListening(blink::WebPlatformEventType);
149 virtual void queryStorageUsageAndQuota(
150 const blink::WebURL& storage_partition,
151 blink::WebStorageQuotaType,
152 blink::WebStorageQuotaCallbacks);
153 virtual void vibrate(unsigned int milliseconds);
154 virtual void cancelVibration();
155 virtual blink::WebScheduler* scheduler();
156 virtual blink::WebThread* currentThread();
158 // Set the PlatformEventObserverBase in |platform_event_observers_| associated
159 // with |type| to |observer|. If there was already an observer associated to
160 // the given |type|, it will be replaced.
161 // Note that |observer| will be owned by this object after the call.
162 void SetPlatformEventObserverForTesting(
163 blink::WebPlatformEventType type,
164 scoped_ptr<PlatformEventObserverBase> observer);
166 // Disables the WebSandboxSupport implementation for testing.
167 // Tests that do not set up a full sandbox environment should call
168 // SetSandboxEnabledForTesting(false) _before_ creating any instances
169 // of this class, to ensure that we don't attempt to use sandbox-related
170 // file descriptors or other resources.
172 // Returns the previous |enable| value.
173 static bool SetSandboxEnabledForTesting(bool enable);
175 // Set a double to return when setDeviceLightListener is invoked.
176 static void SetMockDeviceLightDataForTesting(double data);
177 // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked.
178 static void SetMockDeviceMotionDataForTesting(
179 const blink::WebDeviceMotionData& data);
180 // Set WebDeviceOrientationData to return when setDeviceOrientationListener
181 // is invoked.
182 static void SetMockDeviceOrientationDataForTesting(
183 const blink::WebDeviceOrientationData& data);
185 // Notifies blink::WebBatteryStatusListener that battery status has changed.
186 void MockBatteryStatusChangedForTesting(
187 const blink::WebBatteryStatus& status);
189 WebDatabaseObserverImpl* web_database_observer_impl() {
190 return web_database_observer_impl_.get();
193 private:
194 bool CheckPreparsedJsCachingEnabled() const;
196 // Factory that takes a type and return PlatformEventObserverBase that matches
197 // it.
198 static PlatformEventObserverBase* CreatePlatformEventObserverFromType(
199 blink::WebPlatformEventType type);
201 // Use the data previously set via SetMockDevice...DataForTesting() and send
202 // them to the registered listener.
203 void SendFakeDeviceEventDataForTesting(blink::WebPlatformEventType type);
204 device::VibrationManagerPtr& GetConnectedVibrationManagerService();
206 scoped_ptr<WebSchedulerImpl> web_scheduler_;
207 scoped_ptr<WebThreadImplForScheduler> main_thread_;
209 scoped_ptr<RendererClipboardDelegate> clipboard_delegate_;
210 scoped_ptr<WebClipboardImpl> clipboard_;
212 class FileUtilities;
213 scoped_ptr<FileUtilities> file_utilities_;
215 class MimeRegistry;
216 scoped_ptr<MimeRegistry> mime_registry_;
218 class SandboxSupport;
219 scoped_ptr<SandboxSupport> sandbox_support_;
221 // This counter keeps track of the number of times sudden termination is
222 // enabled or disabled. It starts at 0 (enabled) and for every disable
223 // increments by 1, for every enable decrements by 1. When it reaches 0,
224 // we tell the browser to enable fast termination.
225 int sudden_termination_disables_;
227 // If true, then a GetPlugins call is allowed to rescan the disk.
228 bool plugin_refresh_allowed_;
230 scoped_ptr<blink::WebIDBFactory> web_idb_factory_;
232 scoped_ptr<blink::WebBlobRegistry> blob_registry_;
234 WebPublicSuffixListImpl public_suffix_list_;
236 scoped_ptr<DeviceLightEventPump> device_light_event_pump_;
237 scoped_ptr<DeviceMotionEventPump> device_motion_event_pump_;
238 scoped_ptr<DeviceOrientationEventPump> device_orientation_event_pump_;
240 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_;
241 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
242 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
243 scoped_refptr<QuotaMessageFilter> quota_message_filter_;
245 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_;
247 cc_blink::WebCompositorSupportImpl compositor_support_;
249 scoped_ptr<blink::WebScrollbarBehavior> web_scrollbar_behavior_;
251 scoped_ptr<BatteryStatusDispatcher> battery_status_dispatcher_;
253 // Handle to the Vibration mojo service.
254 device::VibrationManagerPtr vibration_manager_;
256 IDMap<PlatformEventObserverBase, IDMapOwnPointer> platform_event_observers_;
258 DISALLOW_COPY_AND_ASSIGN(RendererBlinkPlatformImpl);
261 } // namespace content
263 #endif // CONTENT_RENDERER_RENDERER_BLINK_PLATFORM_IMPL_H_