| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ENGINE_FEATURE_ENGINE_RENDER_WIDGET_FEATURE_H_ | 5 #ifndef BLIMP_ENGINE_FEATURE_ENGINE_RENDER_WIDGET_FEATURE_H_ |
| 6 #define BLIMP_ENGINE_FEATURE_ENGINE_RENDER_WIDGET_FEATURE_H_ | 6 #define BLIMP_ENGINE_FEATURE_ENGINE_RENDER_WIDGET_FEATURE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/atomic_sequence_num.h" | 13 #include "base/atomic_sequence_num.h" |
| 14 #include "base/containers/small_map.h" | 14 #include "base/containers/small_map.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "blimp/engine/session/settings_manager.h" |
| 17 #include "blimp/net/blimp_message_processor.h" | 18 #include "blimp/net/blimp_message_processor.h" |
| 18 #include "blimp/net/input_message_converter.h" | 19 #include "blimp/net/input_message_converter.h" |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 class WebGestureEvent; | 22 class WebGestureEvent; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 class RenderWidgetHost; | 26 class RenderWidgetHost; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace blimp { | 29 namespace blimp { |
| 30 namespace engine { |
| 29 | 31 |
| 30 // Handles all incoming and outgoing protobuf message types tied to a specific | 32 // Handles all incoming and outgoing protobuf message types tied to a specific |
| 31 // RenderWidget. This includes BlimpMessage::INPUT, BlimpMessage::COMPOSITOR, | 33 // RenderWidget. This includes BlimpMessage::INPUT, BlimpMessage::COMPOSITOR, |
| 32 // and BlimpMessage::RENDER_WIDGET messages. Delegates can be added to be | 34 // and BlimpMessage::RENDER_WIDGET messages. Delegates can be added to be |
| 33 // notified of incoming messages. This class automatically handles dropping | 35 // notified of incoming messages. This class automatically handles dropping |
| 34 // stale BlimpMessage::RENDER_WIDGET messages from the client after a | 36 // stale BlimpMessage::RENDER_WIDGET messages from the client after a |
| 35 // RenderWidgetMessage::INITIALIZE message is sent. | 37 // RenderWidgetMessage::INITIALIZE message is sent. |
| 36 class EngineRenderWidgetFeature : public BlimpMessageProcessor { | 38 class EngineRenderWidgetFeature : public BlimpMessageProcessor, |
| 39 public SettingsManager::Observer { |
| 37 public: | 40 public: |
| 38 // A delegate to be notified of specific RenderWidget related incoming events. | 41 // A delegate to be notified of specific RenderWidget related incoming events. |
| 39 class RenderWidgetMessageDelegate { | 42 class RenderWidgetMessageDelegate { |
| 40 public: | 43 public: |
| 41 // Called when the client is sending a WebGestureEvent to the engine. | 44 // Called when the client is sending a WebGestureEvent to the engine. |
| 42 virtual void OnWebGestureEvent( | 45 virtual void OnWebGestureEvent( |
| 43 content::RenderWidgetHost* render_widget_host, | 46 content::RenderWidgetHost* render_widget_host, |
| 44 scoped_ptr<blink::WebGestureEvent> event) = 0; | 47 scoped_ptr<blink::WebGestureEvent> event) = 0; |
| 45 | 48 |
| 46 // Called when the client sent a CompositorMessage. These messages should | 49 // Called when the client sent a CompositorMessage. These messages should |
| 47 // be sent to the engine's render process so they can be processed by the | 50 // be sent to the engine's render process so they can be processed by the |
| 48 // RemoteChannel of the compositor. | 51 // RemoteChannel of the compositor. |
| 49 virtual void OnCompositorMessageReceived( | 52 virtual void OnCompositorMessageReceived( |
| 50 content::RenderWidgetHost* render_widget_host, | 53 content::RenderWidgetHost* render_widget_host, |
| 51 const std::vector<uint8_t>& message) = 0; | 54 const std::vector<uint8_t>& message) = 0; |
| 52 }; | 55 }; |
| 53 | 56 |
| 54 EngineRenderWidgetFeature(); | 57 explicit EngineRenderWidgetFeature(SettingsManager* settings); |
| 55 ~EngineRenderWidgetFeature() override; | 58 ~EngineRenderWidgetFeature() override; |
| 56 | 59 |
| 57 void set_render_widget_message_sender( | 60 void set_render_widget_message_sender( |
| 58 scoped_ptr<BlimpMessageProcessor> message_processor); | 61 scoped_ptr<BlimpMessageProcessor> message_processor); |
| 59 | 62 |
| 60 void set_input_message_sender( | 63 void set_input_message_sender( |
| 61 scoped_ptr<BlimpMessageProcessor> message_processor); | 64 scoped_ptr<BlimpMessageProcessor> message_processor); |
| 62 | 65 |
| 63 void set_compositor_message_sender( | 66 void set_compositor_message_sender( |
| 64 scoped_ptr<BlimpMessageProcessor> message_processor); | 67 scoped_ptr<BlimpMessageProcessor> message_processor); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 91 // Sets a RenderWidgetMessageDelegate to be notified of all incoming | 94 // Sets a RenderWidgetMessageDelegate to be notified of all incoming |
| 92 // RenderWidget related messages for |tab_id| from the client. There can only | 95 // RenderWidget related messages for |tab_id| from the client. There can only |
| 93 // be one RenderWidgetMessageDelegate per tab. | 96 // be one RenderWidgetMessageDelegate per tab. |
| 94 void SetDelegate(const int tab_id, RenderWidgetMessageDelegate* delegate); | 97 void SetDelegate(const int tab_id, RenderWidgetMessageDelegate* delegate); |
| 95 void RemoveDelegate(const int tab_id); | 98 void RemoveDelegate(const int tab_id); |
| 96 | 99 |
| 97 // BlimpMessageProcessor implementation. | 100 // BlimpMessageProcessor implementation. |
| 98 void ProcessMessage(scoped_ptr<BlimpMessage> message, | 101 void ProcessMessage(scoped_ptr<BlimpMessage> message, |
| 99 const net::CompletionCallback& callback) override; | 102 const net::CompletionCallback& callback) override; |
| 100 | 103 |
| 104 // Settings::Observer implementation. |
| 105 void OnWebPreferencesChanged() override; |
| 106 |
| 101 private: | 107 private: |
| 102 typedef base::SmallMap<std::map<int, RenderWidgetMessageDelegate*> > | 108 typedef base::SmallMap<std::map<int, RenderWidgetMessageDelegate*> > |
| 103 DelegateMap; | 109 DelegateMap; |
| 104 | 110 |
| 105 typedef base::SmallMap<std::map<content::RenderWidgetHost*, int>> | 111 typedef base::SmallMap<std::map<content::RenderWidgetHost*, int>> |
| 106 RenderWidgetToIdMap; | 112 RenderWidgetToIdMap; |
| 107 | 113 |
| 108 typedef base::SmallMap<std::map<int, content::RenderWidgetHost*>> | 114 typedef base::SmallMap<std::map<int, content::RenderWidgetHost*>> |
| 109 IdToRenderWidgetMap; | 115 IdToRenderWidgetMap; |
| 110 | 116 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // But we generate our own ids to avoid having the render widget protocol tied | 150 // But we generate our own ids to avoid having the render widget protocol tied |
| 145 // to always using a combination of these ids, generated by the content layer. | 151 // to always using a combination of these ids, generated by the content layer. |
| 146 // By using an AtomicSequenceNumber for identifying render widgets across | 152 // By using an AtomicSequenceNumber for identifying render widgets across |
| 147 // tabs, we can be sure that there will always be a 1:1 mapping between the | 153 // tabs, we can be sure that there will always be a 1:1 mapping between the |
| 148 // render widget and the consumer of the features tied to this widget on the | 154 // render widget and the consumer of the features tied to this widget on the |
| 149 // client, which is the BlimpCompositor. | 155 // client, which is the BlimpCompositor. |
| 150 base::AtomicSequenceNumber next_widget_id_; | 156 base::AtomicSequenceNumber next_widget_id_; |
| 151 | 157 |
| 152 InputMessageConverter input_message_converter_; | 158 InputMessageConverter input_message_converter_; |
| 153 | 159 |
| 160 SettingsManager* settings_manager_; |
| 161 |
| 154 // Outgoing message processors for RENDER_WIDGET, COMPOSITOR and INPUT types. | 162 // Outgoing message processors for RENDER_WIDGET, COMPOSITOR and INPUT types. |
| 155 scoped_ptr<BlimpMessageProcessor> render_widget_message_sender_; | 163 scoped_ptr<BlimpMessageProcessor> render_widget_message_sender_; |
| 156 scoped_ptr<BlimpMessageProcessor> compositor_message_sender_; | 164 scoped_ptr<BlimpMessageProcessor> compositor_message_sender_; |
| 157 scoped_ptr<BlimpMessageProcessor> input_message_sender_; | 165 scoped_ptr<BlimpMessageProcessor> input_message_sender_; |
| 158 | 166 |
| 159 DISALLOW_COPY_AND_ASSIGN(EngineRenderWidgetFeature); | 167 DISALLOW_COPY_AND_ASSIGN(EngineRenderWidgetFeature); |
| 160 }; | 168 }; |
| 161 | 169 |
| 170 } // namespace engine |
| 162 } // namespace blimp | 171 } // namespace blimp |
| 163 | 172 |
| 164 #endif // BLIMP_ENGINE_FEATURE_ENGINE_RENDER_WIDGET_FEATURE_H_ | 173 #endif // BLIMP_ENGINE_FEATURE_ENGINE_RENDER_WIDGET_FEATURE_H_ |
| OLD | NEW |