OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BLIMP_ENGINE_BROWSER_HOST_RENDER_WIDGET_MESSAGE_PROCESSOR_H_ | |
6 #define BLIMP_ENGINE_BROWSER_HOST_RENDER_WIDGET_MESSAGE_PROCESSOR_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/containers/small_map.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "blimp/net/blimp_message_processor.h" | |
14 #include "blimp/net/input_message_processor.h" | |
15 | |
16 namespace blink { | |
17 class WebInputEvent; | |
18 } | |
19 | |
20 namespace blimp { | |
21 | |
22 // Handles all incoming and outgoing protobuf message types tied to a specific | |
23 // RenderWidget. This includes BlimpMessage::INPUT, BlimpMessage::COMPOSITOR, | |
24 // and BlimpMessage::RENDER_WIDGET messages. Delegates can be added to be | |
25 // notified of incoming messages. This class automatically handles dropping | |
26 // stale BlimpMessage::RENDER_WIDGET messages from the client after a | |
27 // RenderWidgetMessage::INITIALIZE message is sent. | |
28 class HostRenderWidgetMessageProcessor : public BlimpMessageProcessor { | |
Kevin M
2015/11/24 18:39:59
Maybe I'm getting the terminology mixed up, but sh
David Trainor- moved to gerrit
2015/11/25 17:56:42
I was trying to tie to RenderWidget and RenderWidg
| |
29 public: | |
30 // A delegate to be notified of specific RenderWidget related incoming events. | |
31 class RenderWidgetMessageDelegate { | |
32 public: | |
33 // Called when the client is sending a WebInputEvent to the engine. | |
34 virtual void OnWebInputEvent(scoped_ptr<blink::WebInputEvent> event) = 0; | |
35 | |
36 // Called when the client sent a CompositorMessage. These messages should | |
37 // be sent to the engine's render process so they can be processed by the | |
38 // RemoteChannel of the compositor. | |
39 virtual void OnCompositorMessageReceived( | |
40 const std::vector<uint8_t>& message) = 0; | |
41 }; | |
42 | |
43 HostRenderWidgetMessageProcessor( | |
44 BlimpMessageProcessor* outgoing_message_processor); | |
45 ~HostRenderWidgetMessageProcessor() override; | |
46 | |
47 // Notifies the client that the RenderWidget for a particular WebContents has | |
48 // changed. When this is sent all incoming messages from the client sent | |
49 // before this message has been received will be dropped by this class. | |
50 void OnRenderWidgetInitialized(const int tab_id); | |
51 | |
52 // Sends a CompositorMessage for |tab_id| to the client. | |
53 void SendCompositorMessage(const int tab_id, | |
54 const std::vector<uint8_t>& message); | |
55 | |
56 // Sets a RenderWidgetMessageDelegate to be notified of all incoming | |
57 // RenderWidget related messages for |tab_id| from the client. | |
58 void SetDelegate(const int tab_id, RenderWidgetMessageDelegate* delegate); | |
59 void RemoveDelegate(const int tab_id); | |
60 | |
61 // BlimpMessageProcessor implementation. | |
62 void ProcessMessage(scoped_ptr<BlimpMessage> message, | |
63 const net::CompletionCallback& callback) override; | |
64 | |
65 private: | |
66 RenderWidgetMessageDelegate* FindDelegate(const int tab_id); | |
67 uint32_t GetRenderWidgetId(const int tab_id); | |
68 | |
69 typedef base::SmallMap<std::map<int, RenderWidgetMessageDelegate*> > | |
70 DelegateMap; | |
71 typedef base::SmallMap<std::map<int, uint32_t> > RenderWidgetIdMap; | |
72 | |
73 DelegateMap delegates_; | |
74 RenderWidgetIdMap render_widget_ids_; | |
75 | |
76 InputMessageProcessor input_message_processor_; | |
77 | |
78 BlimpMessageProcessor* outgoing_message_processor_; | |
79 | |
80 DISALLOW_COPY_AND_ASSIGN(HostRenderWidgetMessageProcessor); | |
81 }; | |
82 | |
83 } // namespace blimp | |
84 | |
85 #endif // BLIMP_ENGINE_BROWSER_HOST_RENDER_WIDGET_MESSAGE_PROCESSOR_H_ | |
OLD | NEW |