Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / android_webview / browser / shared_renderer_state.h
blob3db14b7144114981f77f2fd0f8031ca768801daf
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
3 // found in the LICENSE file.
5 #ifndef ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
6 #define ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_
8 #include "android_webview/browser/gl_view_renderer_manager.h"
9 #include "android_webview/browser/parent_compositor_draw_constraints.h"
10 #include "base/cancelable_callback.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/synchronization/lock.h"
14 #include "cc/output/compositor_frame_ack.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/geometry/vector2d.h"
18 struct AwDrawGLInfo;
20 namespace android_webview {
22 namespace internal {
23 class RequestDrawGLTracker;
26 class BrowserViewRenderer;
27 class ChildFrame;
28 class HardwareRenderer;
29 class InsideHardwareReleaseReset;
31 // This class is used to pass data between UI thread and RenderThread.
32 class SharedRendererState {
33 public:
34 SharedRendererState(
35 const scoped_refptr<base::SingleThreadTaskRunner>& ui_loop,
36 BrowserViewRenderer* browser_view_renderer);
37 ~SharedRendererState();
39 // This function can be called from any thread.
40 void ClientRequestDrawGL();
42 // UI thread methods.
43 void SetScrollOffsetOnUI(gfx::Vector2d scroll_offset);
44 void SetCompositorFrameOnUI(scoped_ptr<ChildFrame> frame);
45 void InitializeHardwareDrawIfNeededOnUI();
46 void ReleaseHardwareDrawIfNeededOnUI();
47 ParentCompositorDrawConstraints GetParentDrawConstraintsOnUI() const;
48 void SwapReturnedResourcesOnUI(cc::ReturnedResourceArray* resources);
49 bool ReturnedResourcesEmptyOnUI() const;
50 scoped_ptr<ChildFrame> PassUncommittedFrameOnUI();
52 // RT thread methods.
53 gfx::Vector2d GetScrollOffsetOnRT();
54 scoped_ptr<ChildFrame> PassCompositorFrameOnRT();
55 void DrawGL(AwDrawGLInfo* draw_info);
56 void PostExternalDrawConstraintsToChildCompositorOnRT(
57 const ParentCompositorDrawConstraints& parent_draw_constraints);
58 void InsertReturnedResourcesOnRT(const cc::ReturnedResourceArray& resources);
60 private:
61 friend class internal::RequestDrawGLTracker;
62 class InsideHardwareReleaseReset {
63 public:
64 explicit InsideHardwareReleaseReset(
65 SharedRendererState* shared_renderer_state);
66 ~InsideHardwareReleaseReset();
68 private:
69 SharedRendererState* shared_renderer_state_;
72 // RT thread method.
73 void DidDrawGLProcess();
75 // UI thread methods.
76 void ResetRequestDrawGLCallback();
77 void ClientRequestDrawGLOnUI();
78 void UpdateParentDrawConstraintsOnUI();
79 bool IsInsideHardwareRelease() const;
80 void SetInsideHardwareRelease(bool inside);
82 // Accessed by UI thread.
83 scoped_refptr<base::SingleThreadTaskRunner> ui_loop_;
84 BrowserViewRenderer* browser_view_renderer_;
85 base::WeakPtr<SharedRendererState> ui_thread_weak_ptr_;
86 base::CancelableClosure request_draw_gl_cancelable_closure_;
88 // Accessed by RT thread.
89 scoped_ptr<HardwareRenderer> hardware_renderer_;
91 // This is accessed by both UI and RT now. TODO(hush): move to RT only.
92 GLViewRendererManager::Key renderer_manager_key_;
94 // Accessed by both UI and RT thread.
95 mutable base::Lock lock_;
96 gfx::Vector2d scroll_offset_;
97 scoped_ptr<ChildFrame> child_frame_;
98 bool inside_hardware_release_;
99 ParentCompositorDrawConstraints parent_draw_constraints_;
100 cc::ReturnedResourceArray returned_resources_;
101 base::Closure request_draw_gl_closure_;
103 base::WeakPtrFactory<SharedRendererState> weak_factory_on_ui_thread_;
105 DISALLOW_COPY_AND_ASSIGN(SharedRendererState);
108 } // namespace android_webview
110 #endif // ANDROID_WEBVIEW_BROWSER_SHARED_RENDERER_STATE_H_