| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/browser/test/fake_window.h" | 5 #include "android_webview/browser/test/fake_window.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/browser_view_renderer.h" | 7 #include "android_webview/browser/browser_view_renderer.h" |
| 8 #include "android_webview/browser/child_frame.h" | 8 #include "android_webview/browser/child_frame.h" |
| 9 #include "android_webview/browser/render_thread_manager.h" | 9 #include "android_webview/browser/render_thread_manager.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 CheckCurrentlyOnUIThread(); | 54 CheckCurrentlyOnUIThread(); |
| 55 DCHECK(view_); | 55 DCHECK(view_); |
| 56 view_->OnAttachedToWindow(location_.width(), location_.height()); | 56 view_->OnAttachedToWindow(location_.width(), location_.height()); |
| 57 view_->SetWindowVisibility(true); | 57 view_->SetWindowVisibility(true); |
| 58 view_->SetViewVisibility(true); | 58 view_->SetViewVisibility(true); |
| 59 } | 59 } |
| 60 | 60 |
| 61 FakeWindow::~FakeWindow() { | 61 FakeWindow::~FakeWindow() { |
| 62 CheckCurrentlyOnUIThread(); | 62 CheckCurrentlyOnUIThread(); |
| 63 if (render_thread_loop_) { | 63 if (render_thread_loop_) { |
| 64 base::WaitableEvent completion(true, false); | 64 base::WaitableEvent completion( |
| 65 base::WaitableEvent::ResetPolicy::MANUAL, |
| 66 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 65 render_thread_loop_->PostTask( | 67 render_thread_loop_->PostTask( |
| 66 FROM_HERE, base::Bind(&FakeWindow::DestroyOnRT, base::Unretained(this), | 68 FROM_HERE, base::Bind(&FakeWindow::DestroyOnRT, base::Unretained(this), |
| 67 &completion)); | 69 &completion)); |
| 68 completion.Wait(); | 70 completion.Wait(); |
| 69 } | 71 } |
| 70 | 72 |
| 71 render_thread_.reset(); | 73 render_thread_.reset(); |
| 72 } | 74 } |
| 73 | 75 |
| 74 void FakeWindow::Detach() { | 76 void FakeWindow::Detach() { |
| 75 CheckCurrentlyOnUIThread(); | 77 CheckCurrentlyOnUIThread(); |
| 76 view_->OnDetachedFromWindow(); | 78 view_->OnDetachedFromWindow(); |
| 77 } | 79 } |
| 78 | 80 |
| 79 void FakeWindow::RequestInvokeGL(FakeFunctor* functor, | 81 void FakeWindow::RequestInvokeGL(FakeFunctor* functor, |
| 80 bool wait_for_completion) { | 82 bool wait_for_completion) { |
| 81 CheckCurrentlyOnUIThread(); | 83 CheckCurrentlyOnUIThread(); |
| 82 base::WaitableEvent completion(true, false); | 84 base::WaitableEvent completion( |
| 85 base::WaitableEvent::ResetPolicy::MANUAL, |
| 86 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 83 render_thread_loop_->PostTask( | 87 render_thread_loop_->PostTask( |
| 84 FROM_HERE, | 88 FROM_HERE, |
| 85 base::Bind(&FakeWindow::InvokeFunctorOnRT, base::Unretained(this), | 89 base::Bind(&FakeWindow::InvokeFunctorOnRT, base::Unretained(this), |
| 86 functor, wait_for_completion ? &completion : nullptr)); | 90 functor, wait_for_completion ? &completion : nullptr)); |
| 87 if (wait_for_completion) | 91 if (wait_for_completion) |
| 88 completion.Wait(); | 92 completion.Wait(); |
| 89 } | 93 } |
| 90 | 94 |
| 91 void FakeWindow::InvokeFunctorOnRT(FakeFunctor* functor, | 95 void FakeWindow::InvokeFunctorOnRT(FakeFunctor* functor, |
| 92 base::WaitableEvent* sync) { | 96 base::WaitableEvent* sync) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 120 on_draw_hardware_pending_ = false; | 124 on_draw_hardware_pending_ = false; |
| 121 | 125 |
| 122 view_->PrepareToDraw(gfx::Vector2d(), location_); | 126 view_->PrepareToDraw(gfx::Vector2d(), location_); |
| 123 hooks_->WillOnDraw(); | 127 hooks_->WillOnDraw(); |
| 124 bool success = view_->OnDrawHardware(); | 128 bool success = view_->OnDrawHardware(); |
| 125 hooks_->DidOnDraw(success); | 129 hooks_->DidOnDraw(success); |
| 126 FakeFunctor* functor = hooks_->GetFunctor(); | 130 FakeFunctor* functor = hooks_->GetFunctor(); |
| 127 if (success && functor) { | 131 if (success && functor) { |
| 128 CreateRenderThreadIfNeeded(); | 132 CreateRenderThreadIfNeeded(); |
| 129 | 133 |
| 130 base::WaitableEvent completion(true, false); | 134 base::WaitableEvent completion( |
| 135 base::WaitableEvent::ResetPolicy::MANUAL, |
| 136 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 131 render_thread_loop_->PostTask( | 137 render_thread_loop_->PostTask( |
| 132 FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT, | 138 FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT, |
| 133 base::Unretained(this), functor, &completion)); | 139 base::Unretained(this), functor, &completion)); |
| 134 completion.Wait(); | 140 completion.Wait(); |
| 135 } | 141 } |
| 136 } | 142 } |
| 137 | 143 |
| 138 void FakeWindow::ProcessSyncOnRT(FakeFunctor* functor, | 144 void FakeWindow::ProcessSyncOnRT(FakeFunctor* functor, |
| 139 base::WaitableEvent* sync) { | 145 base::WaitableEvent* sync) { |
| 140 CheckCurrentlyOnRT(); | 146 CheckCurrentlyOnRT(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 162 CheckCurrentlyOnUIThread(); | 168 CheckCurrentlyOnUIThread(); |
| 163 if (render_thread_) { | 169 if (render_thread_) { |
| 164 DCHECK(render_thread_loop_); | 170 DCHECK(render_thread_loop_); |
| 165 return; | 171 return; |
| 166 } | 172 } |
| 167 render_thread_.reset(new base::Thread("TestRenderThread")); | 173 render_thread_.reset(new base::Thread("TestRenderThread")); |
| 168 render_thread_->Start(); | 174 render_thread_->Start(); |
| 169 render_thread_loop_ = render_thread_->task_runner(); | 175 render_thread_loop_ = render_thread_->task_runner(); |
| 170 rt_checker_.DetachFromSequence(); | 176 rt_checker_.DetachFromSequence(); |
| 171 | 177 |
| 172 base::WaitableEvent completion(true, false); | 178 base::WaitableEvent completion( |
| 179 base::WaitableEvent::ResetPolicy::MANUAL, |
| 180 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 173 render_thread_loop_->PostTask( | 181 render_thread_loop_->PostTask( |
| 174 FROM_HERE, base::Bind(&FakeWindow::InitializeOnRT, base::Unretained(this), | 182 FROM_HERE, base::Bind(&FakeWindow::InitializeOnRT, base::Unretained(this), |
| 175 &completion)); | 183 &completion)); |
| 176 completion.Wait(); | 184 completion.Wait(); |
| 177 } | 185 } |
| 178 | 186 |
| 179 void FakeWindow::InitializeOnRT(base::WaitableEvent* sync) { | 187 void FakeWindow::InitializeOnRT(base::WaitableEvent* sync) { |
| 180 CheckCurrentlyOnRT(); | 188 CheckCurrentlyOnRT(); |
| 181 surface_ = gl::init::CreateOffscreenGLSurface(surface_size_); | 189 surface_ = gl::init::CreateOffscreenGLSurface(surface_size_); |
| 182 DCHECK(surface_); | 190 DCHECK(surface_); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 268 |
| 261 bool FakeFunctor::RequestInvokeGL(bool wait_for_completion) { | 269 bool FakeFunctor::RequestInvokeGL(bool wait_for_completion) { |
| 262 DCHECK(window_); | 270 DCHECK(window_); |
| 263 window_->RequestInvokeGL(this, wait_for_completion); | 271 window_->RequestInvokeGL(this, wait_for_completion); |
| 264 return true; | 272 return true; |
| 265 } | 273 } |
| 266 | 274 |
| 267 void FakeFunctor::DetachFunctorFromView() {} | 275 void FakeFunctor::DetachFunctorFromView() {} |
| 268 | 276 |
| 269 } // namespace android_webview | 277 } // namespace android_webview |
| OLD | NEW |