Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: blimp/engine/browser/engine_render_widget_message_processor.h

Issue 1450423002: Add glue between the client and engine for Blimp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_ipc2
Patch Set: Fix build break Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_ENGINE_RENDER_WIDGET_MESSAGE_PROCESSOR_H_
6 #define BLIMP_ENGINE_BROWSER_ENGINE_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 EngineRenderWidgetMessageProcessor : public BlimpMessageProcessor {
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 EngineRenderWidgetMessageProcessor(
44 BlimpMessageProcessor* render_widget_message_processor,
45 BlimpMessageProcessor* compositor_message_processor);
46 ~EngineRenderWidgetMessageProcessor() override;
47
48 // Notifies the client that the RenderWidget for a particular WebContents has
49 // changed. When this is sent all incoming messages from the client sent
50 // before this message has been received will be dropped by this class.
51 void OnRenderWidgetInitialized(const int tab_id);
52
53 // Sends a CompositorMessage for |tab_id| to the client.
54 void SendCompositorMessage(const int tab_id,
55 const std::vector<uint8_t>& message);
56
57 // Sets a RenderWidgetMessageDelegate to be notified of all incoming
58 // RenderWidget related messages for |tab_id| from the client. There can only
59 // be one RenderWidgetMessageDelegate per tab.
60 void SetDelegate(const int tab_id, RenderWidgetMessageDelegate* delegate);
61 void RemoveDelegate(const int tab_id);
62
63 // BlimpMessageProcessor implementation.
64 void ProcessMessage(scoped_ptr<BlimpMessage> message,
65 const net::CompletionCallback& callback) override;
66
67 private:
68 // Returns nullptr if no delegate is found.
69 RenderWidgetMessageDelegate* FindDelegate(const int tab_id);
70
71 // Returns 0 if no id is found.
72 uint32_t GetRenderWidgetId(const int tab_id);
73
74 typedef base::SmallMap<std::map<int, RenderWidgetMessageDelegate*> >
75 DelegateMap;
76 typedef base::SmallMap<std::map<int, uint32_t> > RenderWidgetIdMap;
77
78 DelegateMap delegates_;
79 RenderWidgetIdMap render_widget_ids_;
80
81 InputMessageProcessor input_message_processor_;
82
83 BlimpMessageProcessor* render_widget_message_processor_;
84 BlimpMessageProcessor* compositor_message_processor_;
85
86 DISALLOW_COPY_AND_ASSIGN(EngineRenderWidgetMessageProcessor);
87 };
88
89 } // namespace blimp
90
91 #endif // BLIMP_ENGINE_BROWSER_ENGINE_RENDER_WIDGET_MESSAGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « blimp/engine/browser/blimp_engine_session.cc ('k') | blimp/engine/browser/engine_render_widget_message_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698