Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / android_webview / browser / test / fake_window.h
blobafe5a7fb5b4b50bc9caa1a853bf5f05a43ede876
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_TEST_FAKE_WINDOW_H_
6 #define ANDROID_WEBVIEW_BROWSER_TEST_FAKE_WINDOW_H_
8 #include <map>
10 #include "android_webview/public/browser/draw_gl.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/sequence_checker.h"
13 #include "base/single_thread_task_runner.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gl/gl_context.h"
16 #include "ui/gl/gl_surface.h"
18 namespace base {
19 class Thread;
20 class WaitableEvent;
23 namespace android_webview {
25 class BrowserViewRenderer;
26 class SharedRendererState;
28 class WindowHooks {
29 public:
30 virtual ~WindowHooks() {}
32 virtual void WillOnDraw() = 0;
33 virtual void DidOnDraw(bool success) = 0;
35 virtual void WillSyncOnRT(SharedRendererState* functor) = 0;
36 virtual void DidSyncOnRT(SharedRendererState* functor) = 0;
37 virtual void WillProcessOnRT(SharedRendererState* functor) = 0;
38 virtual void DidProcessOnRT(SharedRendererState* functor) = 0;
39 virtual bool WillDrawOnRT(SharedRendererState* functor,
40 AwDrawGLInfo* draw_info) = 0;
41 virtual void DidDrawOnRT(SharedRendererState* functor) = 0;
44 class FakeWindow {
45 public:
46 FakeWindow(BrowserViewRenderer* view,
47 WindowHooks* hooks,
48 gfx::Rect location);
49 ~FakeWindow();
51 void Detach();
53 // BrowserViewRendererClient methods.
54 void RequestDrawGL(bool wait_for_completion);
55 void PostInvalidate();
56 const gfx::Size& surface_size() { return surface_size_; }
58 private:
59 class ScopedMakeCurrent;
61 void OnDrawHardware();
62 void CheckCurrentlyOnUIThread();
63 void CreateRenderThreadIfNeeded();
65 void InitializeOnRT(base::WaitableEvent* sync);
66 void DestroyOnRT(base::WaitableEvent* sync);
67 void ProcessFunctorOnRT(base::WaitableEvent* sync);
68 void DrawFunctorOnRT(base::WaitableEvent* sync);
69 void CheckCurrentlyOnRT();
71 // const so can be used on both threads.
72 BrowserViewRenderer* const view_;
73 WindowHooks* const hooks_;
74 const gfx::Size surface_size_;
76 // UI thread members.
77 gfx::Rect location_;
78 bool on_draw_hardware_pending_;
79 base::SequenceChecker ui_checker_;
81 // Render thread members.
82 scoped_ptr<base::Thread> render_thread_;
83 base::SequenceChecker rt_checker_;
84 SharedRendererState* functor_;
85 scoped_refptr<base::SingleThreadTaskRunner> render_thread_loop_;
86 scoped_refptr<gfx::GLSurface> surface_;
87 scoped_refptr<gfx::GLContext> context_;
88 bool context_current_;
90 base::WeakPtrFactory<FakeWindow> weak_ptr_factory_;
92 DISALLOW_COPY_AND_ASSIGN(FakeWindow);
95 } // namespace android_webview
97 #endif // ANDROID_WEBVIEW_BROWSER_TEST_FAKE_WINDOW_H_