Chromium Code Reviews| Index: cc/test/test_context_provider.h |
| diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h |
| index f294eb7ecd5ba42c7dfbda03498eb3b42026f0dc..cb5794ed0e5b1f598e69a19e62253d3c43d0946d 100644 |
| --- a/cc/test/test_context_provider.h |
| +++ b/cc/test/test_context_provider.h |
| @@ -30,14 +30,33 @@ class TestContextProvider : public ContextProvider { |
| CreateCallback; |
| static scoped_refptr<TestContextProvider> Create(); |
| - // Creates a worker context provider that can be used on any thread. This is |
| - // equivalent to: Create(); BindToCurrentThread(). |
| - static scoped_refptr<TestContextProvider> CreateWorker(); |
| static scoped_refptr<TestContextProvider> Create( |
| std::unique_ptr<TestWebGraphicsContext3D> context); |
| - bool BindToCurrentThread() override; |
| - void DetachFromThread() override; |
| + class Factory : public ContextProvider::Factory { |
| + public: |
| + // Creates a context provider with default capabilities. |
| + Factory(); |
| + // Creates a context provider wrapping the given TestWebGraphicsContext3D. |
| + explicit Factory(std::unique_ptr<TestWebGraphicsContext3D> context); |
| + // Creates a context provider with the given capabilities. |
| + explicit Factory(const gpu::Capabilities& capabilities); |
| + // Fails to create a context provider, simulating loss of the gpu channel or |
| + // other such error conditions. |
| + enum FailCreate { kFailCreate = 1 }; |
| + explicit Factory(FailCreate); |
| + |
| + ~Factory(); |
| + scoped_refptr<ContextProvider> CreateContext() override; |
| + |
| + private: |
|
danakj
2016/05/17 23:17:15
Notably I made these private and added constructor
|
| + const bool fail_create_ = false; |
| + std::unique_ptr<TestWebGraphicsContext3D> context_; |
| + const gpu::Capabilities capabilities_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Factory); |
| + }; |
| + |
| gpu::Capabilities ContextCapabilities() override; |
| gpu::gles2::GLES2Interface* ContextGL() override; |
| gpu::ContextSupport* ContextSupport() override; |
| @@ -46,15 +65,9 @@ class TestContextProvider : public ContextProvider { |
| base::Lock* GetLock() override; |
| void DeleteCachedResources() override; |
| void SetLostContextCallback(const LostContextCallback& cb) override; |
| + void DetachFromThread() override; |
| TestWebGraphicsContext3D* TestContext3d(); |
| - |
| - // This returns the TestWebGraphicsContext3D but is valid to call |
| - // before the context is bound to a thread. This is needed to set up |
| - // state on the test context before binding. Don't call |
| - // InitializeOnCurrentThread on the context returned from this method. |
| - TestWebGraphicsContext3D* UnboundTestContext3d(); |
| - |
| TestContextSupport* support() { return &support_; } |
| protected: |
| @@ -69,10 +82,8 @@ class TestContextProvider : public ContextProvider { |
| std::unique_ptr<TestWebGraphicsContext3D> context3d_; |
| std::unique_ptr<TestGLES2Interface> context_gl_; |
| - bool bound_; |
| - base::ThreadChecker main_thread_checker_; |
| - base::ThreadChecker context_thread_checker_; |
| + base::ThreadChecker thread_checker_; |
| base::Lock context_lock_; |