Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Side by Side Diff: blimp/client/core/render_widget/blimp_document.cc

Issue 2400923002: Move BlimpInputManager to BlimpDocument from BlimpCompositor. (Closed)
Patch Set: Use c++11 ctor. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "blimp/client/core/render_widget/blimp_document.h" 5 #include "blimp/client/core/render_widget/blimp_document.h"
6 6
7 #include "base/threading/thread_task_runner_handle.h"
8 #include "blimp/client/core/compositor/blimp_compositor_dependencies.h"
9 #include "blimp/client/core/input/blimp_input_manager.h"
7 #include "blimp/client/core/render_widget/blimp_document_manager.h" 10 #include "blimp/client/core/render_widget/blimp_document_manager.h"
8 #include "cc/layers/layer.h" 11 #include "cc/layers/layer.h"
9 12
10 namespace blimp { 13 namespace blimp {
11 namespace client { 14 namespace client {
12 15
13 BlimpDocument::BlimpDocument(int document_id, 16 BlimpDocument::BlimpDocument(int document_id,
14 BlimpCompositorDependencies* compositor_deps, 17 BlimpCompositorDependencies* compositor_deps,
15 BlimpDocumentManager* document_manager) 18 BlimpDocumentManager* document_manager)
16 : document_id_(document_id), manager_(document_manager) { 19 : BlimpDocument(document_id,
17 compositor_ = base::MakeUnique<BlimpCompositor>(compositor_deps, this); 20 base::MakeUnique<BlimpCompositor>(compositor_deps, this),
21 compositor_deps,
22 document_manager) {}
23
24 BlimpDocument::BlimpDocument(int document_id,
25 std::unique_ptr<BlimpCompositor> compositor,
26 BlimpCompositorDependencies* compositor_deps,
27 BlimpDocumentManager* document_manager)
28 : document_id_(document_id),
29 compositor_(std::move(compositor)),
30 manager_(document_manager) {
31 DCHECK(!input_manager_);
Khushal 2016/10/10 21:54:54 You shouldn't DCHECK. The |input_manager_| has not
xingliu 2016/10/10 23:00:16 Done, yeah, seems DCHECK previously is not in ctor
32 input_manager_ =
33 BlimpInputManager::Create(this, base::ThreadTaskRunnerHandle::Get(),
34 compositor_deps->GetCompositorTaskRunner(),
35 compositor_->GetInputHandler());
18 } 36 }
19 37
20 BlimpDocument::~BlimpDocument() = default; 38 BlimpDocument::~BlimpDocument() {
39 compositor_.reset();
40
41 // Destroy the old input manager state.
42 // It is important to destroy the LayerTreeHost before destroying the input
43 // manager as it has a reference to the cc::InputHandlerClient owned by the
44 // BlimpInputManager.
45 input_manager_.reset();
46 }
21 47
22 BlimpCompositor* BlimpDocument::GetCompositor() { 48 BlimpCompositor* BlimpDocument::GetCompositor() {
23 return compositor_.get(); 49 return compositor_.get();
24 } 50 }
25 51
26 void BlimpDocument::SetCompositorForTest( 52 bool BlimpDocument::OnTouchEvent(const ui::MotionEvent& motion_event) {
27 std::unique_ptr<BlimpCompositor> compositor) { 53 if (input_manager_)
28 compositor_ = std::move(compositor); 54 return input_manager_->OnTouchEvent(motion_event);
29 } 55 return false;
30
31 void BlimpDocument::SendWebGestureEvent(
32 const blink::WebGestureEvent& gesture_event) {
33 manager_->SendWebGestureEvent(document_id_, gesture_event);
34 } 56 }
35 57
36 void BlimpDocument::SendCompositorMessage( 58 void BlimpDocument::SendCompositorMessage(
37 const cc::proto::CompositorMessage& message) { 59 const cc::proto::CompositorMessage& message) {
38 manager_->SendCompositorMessage(document_id_, message); 60 manager_->SendCompositorMessage(document_id_, message);
39 } 61 }
40 62
63 void BlimpDocument::SendWebGestureEvent(
64 const blink::WebGestureEvent& gesture_event) {
65 manager_->SendWebGestureEvent(document_id_, gesture_event);
66 }
67
41 } // namespace client 68 } // namespace client
42 } // namespace blimp 69 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/render_widget/blimp_document.h ('k') | blimp/client/core/render_widget/blimp_document_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698