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

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

Issue 2400923002: Move BlimpInputManager to BlimpDocument from BlimpCompositor. (Closed)
Patch Set: Fixes based on review. 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)
David Trainor- moved to gerrit 2016/10/10 21:12:20 Can you just call the other constructor with the a
xingliu 2016/10/10 21:48:00 Done.
16 : document_id_(document_id), manager_(document_manager) { 19 : document_id_(document_id), manager_(document_manager) {
17 compositor_ = base::MakeUnique<BlimpCompositor>(compositor_deps, this); 20 compositor_ = base::MakeUnique<BlimpCompositor>(compositor_deps, this);
21 CreateInputManager(compositor_deps);
18 } 22 }
19 23
20 BlimpDocument::~BlimpDocument() = default; 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 CreateInputManager(compositor_deps);
32 }
33
34 BlimpDocument::~BlimpDocument() {
35 compositor_.reset();
36
37 // Destroy the old input manager state.
38 // It is important to destroy the LayerTreeHost before destroying the input
39 // manager as it has a reference to the cc::InputHandlerClient owned by the
40 // BlimpInputManager.
41 input_manager_.reset();
42 }
21 43
22 BlimpCompositor* BlimpDocument::GetCompositor() { 44 BlimpCompositor* BlimpDocument::GetCompositor() {
23 return compositor_.get(); 45 return compositor_.get();
24 } 46 }
25 47
26 void BlimpDocument::SetCompositorForTest( 48 bool BlimpDocument::OnTouchEvent(const ui::MotionEvent& motion_event) {
27 std::unique_ptr<BlimpCompositor> compositor) { 49 if (input_manager_)
28 compositor_ = std::move(compositor); 50 return input_manager_->OnTouchEvent(motion_event);
51 return false;
52 }
53
54 void BlimpDocument::SendCompositorMessage(
55 const cc::proto::CompositorMessage& message) {
56 manager_->SendCompositorMessage(document_id_, message);
29 } 57 }
30 58
31 void BlimpDocument::SendWebGestureEvent( 59 void BlimpDocument::SendWebGestureEvent(
32 const blink::WebGestureEvent& gesture_event) { 60 const blink::WebGestureEvent& gesture_event) {
33 manager_->SendWebGestureEvent(document_id_, gesture_event); 61 manager_->SendWebGestureEvent(document_id_, gesture_event);
34 } 62 }
35 63
36 void BlimpDocument::SendCompositorMessage( 64 void BlimpDocument::CreateInputManager(
37 const cc::proto::CompositorMessage& message) { 65 BlimpCompositorDependencies* compositor_deps) {
38 manager_->SendCompositorMessage(document_id_, message); 66 DCHECK(!input_manager_);
67 input_manager_ =
68 BlimpInputManager::Create(this, base::ThreadTaskRunnerHandle::Get(),
69 compositor_deps->GetCompositorTaskRunner(),
70 compositor_->GetInputHandler());
39 } 71 }
40 72
41 } // namespace client 73 } // namespace client
42 } // namespace blimp 74 } // 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