Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / browser / aura / gpu_process_transport_factory.h
blob56d3e55498ab08809ab8d00c058e22a8ac775222
1 // Copyright (c) 2013 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_BROWSER_AURA_GPU_PROCESS_TRANSPORT_FACTORY_H_
6 #define CONTENT_BROWSER_AURA_GPU_PROCESS_TRANSPORT_FACTORY_H_
8 #include <map>
10 #include "base/id_map.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
15 #include "content/browser/aura/image_transport_factory.h"
16 #include "ui/compositor/compositor.h"
18 namespace content {
19 class BrowserCompositorOutputSurface;
20 class BrowserCompositorOutputSurfaceProxy;
21 class CompositorSwapClient;
22 class ContextProviderCommandBuffer;
23 class ReflectorImpl;
24 class WebGraphicsContext3DCommandBufferImpl;
25 class WebGraphicsContext3DSwapBuffersClient;
27 class GpuProcessTransportFactory
28 : public ui::ContextFactory,
29 public ImageTransportFactory {
30 public:
31 GpuProcessTransportFactory();
33 virtual ~GpuProcessTransportFactory();
35 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
36 CreateOffscreenCommandBufferContext();
38 // ui::ContextFactory implementation.
39 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
40 ui::Compositor* compositor) OVERRIDE;
41 virtual scoped_refptr<ui::Reflector> CreateReflector(
42 ui::Compositor* source,
43 ui::Layer* target) OVERRIDE;
44 virtual void RemoveReflector(
45 scoped_refptr<ui::Reflector> reflector) OVERRIDE;
46 virtual void RemoveCompositor(ui::Compositor* compositor) OVERRIDE;
47 virtual scoped_refptr<cc::ContextProvider>
48 OffscreenContextProviderForMainThread() OVERRIDE;
49 virtual scoped_refptr<cc::ContextProvider>
50 OffscreenContextProviderForCompositorThread() OVERRIDE;
51 virtual bool DoesCreateTestContexts() OVERRIDE;
53 // ImageTransportFactory implementation.
54 virtual ui::ContextFactory* AsContextFactory() OVERRIDE;
55 virtual gfx::GLSurfaceHandle CreateSharedSurfaceHandle() OVERRIDE;
56 virtual void DestroySharedSurfaceHandle(
57 gfx::GLSurfaceHandle surface) OVERRIDE;
58 virtual scoped_refptr<ui::Texture> CreateTransportClient(
59 float device_scale_factor) OVERRIDE;
60 virtual scoped_refptr<ui::Texture> CreateOwnedTexture(
61 const gfx::Size& size,
62 float device_scale_factor,
63 unsigned int texture_id) OVERRIDE;
64 virtual GLHelper* GetGLHelper() OVERRIDE;
65 virtual uint32 InsertSyncPoint() OVERRIDE;
66 virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE;
67 virtual void AddObserver(ImageTransportFactoryObserver* observer) OVERRIDE;
68 virtual void RemoveObserver(
69 ImageTransportFactoryObserver* observer) OVERRIDE;
71 void OnLostContext(ui::Compositor* compositor);
73 private:
74 struct PerCompositorData;
76 PerCompositorData* CreatePerCompositorData(ui::Compositor* compositor);
77 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContextCommon(
78 const base::WeakPtr<WebGraphicsContext3DSwapBuffersClient>& swap_client,
79 int surface_id);
81 void CreateSharedContextLazy();
83 void OnLostMainThreadSharedContextInsideCallback();
84 void OnLostMainThreadSharedContext();
86 typedef std::map<ui::Compositor*, PerCompositorData*> PerCompositorDataMap;
87 PerCompositorDataMap per_compositor_data_;
88 scoped_refptr<ContextProviderCommandBuffer> shared_contexts_main_thread_;
89 scoped_refptr<ContextProviderCommandBuffer>
90 shared_contexts_compositor_thread_;
91 scoped_ptr<GLHelper> gl_helper_;
92 ObserverList<ImageTransportFactoryObserver> observer_list_;
93 base::WeakPtrFactory<GpuProcessTransportFactory> callback_factory_;
95 // The contents of this map and its methods may only be used on the compositor
96 // thread.
97 IDMap<BrowserCompositorOutputSurface> output_surface_map_;
99 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_;
101 DISALLOW_COPY_AND_ASSIGN(GpuProcessTransportFactory);
104 } // namespace content
106 #endif // CONTENT_BROWSER_AURA_GPU_PROCESS_TRANSPORT_FACTORY_H_