Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ | 5 #ifndef BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ |
| 6 #define BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ | 6 #define BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "blimp/client/core/compositor/blimp_compositor.h" | 12 #include "blimp/client/core/compositor/blimp_compositor.h" |
| 13 #include "blimp/client/core/input/blimp_input_manager.h" | |
| 13 | 14 |
| 14 namespace blimp { | 15 namespace blimp { |
| 15 namespace client { | 16 namespace client { |
| 16 | 17 |
| 17 class BlimpCompositorDependencies; | 18 class BlimpCompositorDependencies; |
| 18 class BlimpDocumentManager; | 19 class BlimpDocumentManager; |
| 19 | 20 |
| 20 // BlimpDocument maps to an engine side render widget. | 21 // BlimpDocument maps to an engine side render widget. |
| 21 // 1. Is created on receiving an RenderWidgetMessage from the engine. | 22 // 1. Is created on receiving an RenderWidgetMessage from the engine. |
| 22 // 2. Owns the BlimpCompositor instance. | 23 // 2. Owns the BlimpCompositor instance. |
| 23 class BlimpDocument : public BlimpCompositorClient { | 24 // 3. Handles touch events and forward them to the engine. |
| 25 class BlimpDocument : public BlimpCompositorClient, | |
| 26 public BlimpInputManagerClient { | |
| 24 public: | 27 public: |
| 25 BlimpDocument(int document_id, | 28 BlimpDocument(int document_id, |
| 26 BlimpCompositorDependencies* compositor_dependencies, | 29 BlimpCompositorDependencies* compositor_dependencies, |
| 27 BlimpDocumentManager* document_manager); | 30 BlimpDocumentManager* document_manager); |
| 28 ~BlimpDocument() override; | 31 ~BlimpDocument() override; |
| 29 | 32 |
| 30 int document_id() const { return document_id_; } | 33 int document_id() const { return document_id_; } |
| 31 | 34 |
| 32 // Returns the compositor instance. | 35 // Returns the compositor instance. |
| 33 BlimpCompositor* GetCompositor(); | 36 BlimpCompositor* GetCompositor(); |
| 34 | 37 |
| 38 // Forwards the touch event to the |input_manager_|. | |
| 39 // virtual for testing. | |
| 40 virtual bool OnTouchEvent(const ui::MotionEvent& motion_event); | |
| 41 | |
| 35 protected: | 42 protected: |
|
Khushal
2016/10/07 03:40:15
How about adding a protected ctor for tests here,
xingliu
2016/10/10 19:00:17
Good idea.
| |
| 36 void SetCompositorForTest(std::unique_ptr<BlimpCompositor> compositor); | 43 void SetCompositorForTest(std::unique_ptr<BlimpCompositor> compositor, |
| 44 BlimpCompositorDependencies* compositor_deps); | |
| 37 | 45 |
| 38 private: | 46 private: |
| 39 // BlimpCompositorClient implementation. | 47 // BlimpCompositorClient implementation. |
| 48 void SendCompositorMessage( | |
| 49 const cc::proto::CompositorMessage& message) override; | |
| 50 | |
| 51 // BlimpInputManagerClient implementation. | |
| 40 void SendWebGestureEvent( | 52 void SendWebGestureEvent( |
| 41 const blink::WebGestureEvent& gesture_event) override; | 53 const blink::WebGestureEvent& gesture_event) override; |
| 42 void SendCompositorMessage( | |
| 43 const cc::proto::CompositorMessage& message) override; | |
| 44 | 54 |
| 45 // The unique identifier for this document instance. | 55 // The unique identifier for this document instance. |
| 46 const int document_id_; | 56 const int document_id_; |
| 47 | 57 |
| 48 // The compositor instance. | 58 // The compositor instance. |
| 49 std::unique_ptr<BlimpCompositor> compositor_; | 59 std::unique_ptr<BlimpCompositor> compositor_; |
| 50 | 60 |
| 51 // Used to send messages to the corresponding render widget on the engine. | 61 // Used to send messages to the corresponding render widget on the engine. |
| 52 BlimpDocumentManager* manager_; | 62 BlimpDocumentManager* manager_; |
| 53 | 63 |
| 64 // Handles input events for the current document. The lifetime of the | |
| 65 // input manager is tied to the lifetime of the layer tree host of its | |
| 66 // compositor which owns the cc::InputHandler. | |
| 67 // The input events are forwarded to this input handler by | |
| 68 // the manager to be handled by the client compositor for the current | |
| 69 // document. | |
| 70 std::unique_ptr<BlimpInputManager> input_manager_; | |
| 71 | |
| 54 DISALLOW_COPY_AND_ASSIGN(BlimpDocument); | 72 DISALLOW_COPY_AND_ASSIGN(BlimpDocument); |
| 55 }; | 73 }; |
| 56 | 74 |
| 57 } // namespace client | 75 } // namespace client |
| 58 } // namespace blimp | 76 } // namespace blimp |
| 59 | 77 |
| 60 #endif // BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ | 78 #endif // BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ |
| OLD | NEW |