| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ | |
| 6 #define BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/ptr_util.h" | |
| 12 #include "blimp/client/core/compositor/blimp_compositor.h" | |
| 13 #include "blimp/client/core/input/blimp_input_manager.h" | |
| 14 | |
| 15 namespace blimp { | |
| 16 namespace client { | |
| 17 | |
| 18 class BlimpCompositorDependencies; | |
| 19 class BlimpDocumentManager; | |
| 20 | |
| 21 // BlimpDocument maps to an engine side render widget. | |
| 22 // 1. Is created on receiving an RenderWidgetMessage from the engine. | |
| 23 // 2. Owns the BlimpCompositor instance. | |
| 24 // 3. Handles touch events and forward them to the engine. | |
| 25 class BlimpDocument : public BlimpCompositorClient, | |
| 26 public BlimpInputManagerClient { | |
| 27 public: | |
| 28 BlimpDocument(int document_id, | |
| 29 BlimpCompositorDependencies* compositor_dependencies, | |
| 30 BlimpDocumentManager* document_manager); | |
| 31 ~BlimpDocument() override; | |
| 32 | |
| 33 int document_id() const { return document_id_; } | |
| 34 | |
| 35 // Returns the compositor instance. | |
| 36 BlimpCompositor* GetCompositor(); | |
| 37 | |
| 38 // Forwards the touch event to the |input_manager_|. | |
| 39 // virtual for testing. | |
| 40 virtual bool OnTouchEvent(const ui::MotionEvent& motion_event); | |
| 41 | |
| 42 protected: | |
| 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); | |
| 48 | |
| 49 private: | |
| 50 // BlimpCompositorClient implementation. | |
| 51 void SendCompositorMessage( | |
| 52 const cc::proto::CompositorMessage& message) override; | |
| 53 | |
| 54 // BlimpInputManagerClient implementation. | |
| 55 void SendWebGestureEvent( | |
| 56 const blink::WebGestureEvent& gesture_event) override; | |
| 57 | |
| 58 // The unique identifier for this document instance. | |
| 59 const int document_id_; | |
| 60 | |
| 61 // The compositor instance. | |
| 62 std::unique_ptr<BlimpCompositor> compositor_; | |
| 63 | |
| 64 // Used to send messages to the corresponding render widget on the engine. | |
| 65 BlimpDocumentManager* manager_; | |
| 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 | |
| 75 DISALLOW_COPY_AND_ASSIGN(BlimpDocument); | |
| 76 }; | |
| 77 | |
| 78 } // namespace client | |
| 79 } // namespace blimp | |
| 80 | |
| 81 #endif // BLIMP_CLIENT_CORE_RENDER_WIDGET_BLIMP_DOCUMENT_H_ | |
| OLD | NEW |