| 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: |
| 36 void SetCompositorForTest(std::unique_ptr<BlimpCompositor> compositor); | 43 // Constructor that may take a mock compositor as input for testing. |
| 44 BlimpDocument(int document_id, |
| 45 std::unique_ptr<BlimpCompositor> compositor, |
| 46 BlimpCompositorDependencies* compositor_dependencies, |
| 47 BlimpDocumentManager* document_manager); |
| 37 | 48 |
| 38 private: | 49 private: |
| 39 // BlimpCompositorClient implementation. | 50 // BlimpCompositorClient implementation. |
| 51 void SendCompositorMessage( |
| 52 const cc::proto::CompositorMessage& message) override; |
| 53 |
| 54 // BlimpInputManagerClient implementation. |
| 40 void SendWebGestureEvent( | 55 void SendWebGestureEvent( |
| 41 const blink::WebGestureEvent& gesture_event) override; | 56 const blink::WebGestureEvent& gesture_event) override; |
| 42 void SendCompositorMessage( | |
| 43 const cc::proto::CompositorMessage& message) override; | |
| 44 | 57 |
| 45 // The unique identifier for this document instance. | 58 // The unique identifier for this document instance. |
| 46 const int document_id_; | 59 const int document_id_; |
| 47 | 60 |
| 48 // The compositor instance. | 61 // The compositor instance. |
| 49 std::unique_ptr<BlimpCompositor> compositor_; | 62 std::unique_ptr<BlimpCompositor> compositor_; |
| 50 | 63 |
| 51 // Used to send messages to the corresponding render widget on the engine. | 64 // Used to send messages to the corresponding render widget on the engine. |
| 52 BlimpDocumentManager* manager_; | 65 BlimpDocumentManager* manager_; |
| 53 | 66 |
| 67 // Handles input events for the current document. The lifetime of the |
| 68 // input manager is tied to the lifetime of the layer tree host of its |
| 69 // compositor which owns the cc::InputHandler. |
| 70 // The input events are forwarded to this input handler by |
| 71 // the manager to be handled by the client compositor for the current |
| 72 // document. |
| 73 std::unique_ptr<BlimpInputManager> input_manager_; |
| 74 |
| 54 DISALLOW_COPY_AND_ASSIGN(BlimpDocument); | 75 DISALLOW_COPY_AND_ASSIGN(BlimpDocument); |
| 55 }; | 76 }; |
| 56 | 77 |
| 57 } // namespace client | 78 } // namespace client |
| 58 } // namespace blimp | 79 } // namespace blimp |
| 59 | 80 |
| 60 #endif // BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ | 81 #endif // BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ |
| OLD | NEW |