Chromium Code Reviews| Index: android_webview/browser/test/fake_window.h |
| diff --git a/android_webview/browser/test/fake_window.h b/android_webview/browser/test/fake_window.h |
| index 5302f60a9c03b8bb3d09d0acb34a99b6014b383f..d14531c0c3c2b9d691d341d1d441f6ecd25c3fa5 100644 |
| --- a/android_webview/browser/test/fake_window.h |
| +++ b/android_webview/browser/test/fake_window.h |
| @@ -7,6 +7,8 @@ |
| #include <map> |
| +#include "android_webview/browser/render_thread_manager.h" |
|
boliu
2016/05/10 15:18:19
forward declare?
Tobias Sargeant
2016/05/13 13:23:57
Done.
|
| +#include "android_webview/browser/render_thread_manager_client.h" |
| #include "android_webview/public/browser/draw_gl.h" |
| #include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| @@ -24,6 +26,7 @@ class WaitableEvent; |
| namespace android_webview { |
| class BrowserViewRenderer; |
| +class Functor; |
| class WindowHooks { |
| public: |
| @@ -42,21 +45,18 @@ class WindowHooks { |
| class FakeWindow { |
| public: |
| - using DrawGLCallback = base::Callback<void(AwDrawGLInfo*)>; |
| - |
| - FakeWindow(BrowserViewRenderer* view, |
| - const DrawGLCallback& draw_gl, |
| - WindowHooks* hooks, |
| - gfx::Rect location); |
| + FakeWindow(BrowserViewRenderer* view, WindowHooks* hooks, gfx::Rect location); |
| ~FakeWindow(); |
| void Detach(); |
| - // BrowserViewRendererClient methods. |
| - void RequestInvokeGL(bool wait_for_completion); |
| + void RequestInvokeGL(Functor* functor, bool wait_for_completion); |
| void PostInvalidate(); |
| const gfx::Size& surface_size() { return surface_size_; } |
| + void SetDrawFunctor(Functor* functor); |
| + void RequestDrawGL(Functor* functor); |
| + |
| private: |
| class ScopedMakeCurrent; |
| @@ -66,10 +66,11 @@ class FakeWindow { |
| void InitializeOnRT(base::WaitableEvent* sync); |
| void DestroyOnRT(base::WaitableEvent* sync); |
| - void ProcessFunctorOnRT(base::WaitableEvent* sync); |
| - void DrawFunctorOnRT(base::WaitableEvent* sync); |
| + void InvokeFunctorOnRT(Functor* functor, base::WaitableEvent* sync); |
| + void ProcessSyncOnRT(Functor* functor, base::WaitableEvent* sync); |
| + void ProcessDrawOnRT(Functor* functor); |
| + void DrawFunctorOnRT(Functor* functor, base::WaitableEvent* sync); |
| void CheckCurrentlyOnRT(); |
|
boliu
2016/05/10 15:18:19
style: keep blank line below
Tobias Sargeant
2016/05/13 13:23:56
Done.
|
| - |
| // const so can be used on both threads. |
| BrowserViewRenderer* const view_; |
| WindowHooks* const hooks_; |
| @@ -83,17 +84,45 @@ class FakeWindow { |
| // Render thread members. |
| std::unique_ptr<base::Thread> render_thread_; |
| base::SequenceChecker rt_checker_; |
| - DrawGLCallback draw_gl_; |
| scoped_refptr<base::SingleThreadTaskRunner> render_thread_loop_; |
| scoped_refptr<gfx::GLSurface> surface_; |
| scoped_refptr<gfx::GLContext> context_; |
| bool context_current_; |
| + Functor* functor_; |
|
boliu
2016/05/10 15:18:19
there is nothing really guaranteeing lifetime betw
Tobias Sargeant
2016/05/13 13:23:57
True. It's slightly better now that FakeWindow doe
|
| base::WeakPtrFactory<FakeWindow> weak_ptr_factory_; |
| DISALLOW_COPY_AND_ASSIGN(FakeWindow); |
| }; |
| +class Functor : public RenderThreadManagerClient { |
|
boliu
2016/05/10 15:18:19
TestFunctor or something that implies it's not a p
Tobias Sargeant
2016/05/13 13:23:57
Done.
|
| + public: |
| + using DrawGLCallback = base::Callback<void(AwDrawGLInfo*)>; |
| + using RenderThreadManagerFactory = |
| + base::Callback<RenderThreadManager*(RenderThreadManagerClient*)>; |
| + |
| + Functor(RenderThreadManagerFactory render_thread_manager_factory); |
|
boliu
2016/05/10 15:18:19
explicit, const&
Tobias Sargeant
2016/05/13 13:23:57
Took your Init suggestion, no need for this constr
|
| + ~Functor() override; |
| + |
| + CompositorFrameConsumer* GetCompositorFrameConsumer(); |
| + void Attach(FakeWindow* window); |
| + void Sync(const gfx::Rect& location, |
| + base::WaitableEvent* sync, |
| + WindowHooks* hooks); |
| + void Draw(WindowHooks* hooks); |
| + void Invoke(base::WaitableEvent* sync, WindowHooks* hooks); |
| + |
| + // RenderThreadManagerClient overrides |
| + bool RequestInvokeGL(bool wait_for_completion) override; |
| + void DetachFunctorFromView() override; |
| + |
| + private: |
| + FakeWindow* window_; |
| + DrawGLCallback callback_; |
| + std::unique_ptr<RenderThreadManager> render_thread_manager_; |
| + gfx::Rect committed_location_; |
| +}; |
| + |
| } // namespace android_webview |
| #endif // ANDROID_WEBVIEW_BROWSER_TEST_FAKE_WINDOW_H_ |