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

Side by Side Diff: blimp/client/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: Address comments! Created 5 years, 1 month 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_CLIENT_RENDER_WIDGET_MESSAGE_PROCESSOR_H_
nyquist 2015/11/24 08:55:43 Would it make sense to put these in some subfolder
David Trainor- moved to gerrit 2015/11/25 17:56:42 Put these in compositor, as that's where they're a
6 #define BLIMP_CLIENT_RENDER_WIDGET_MESSAGE_PROCESSOR_H_
7
8 #include "base/containers/small_map.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "blimp/client/blimp_client_export.h"
12 #include "blimp/net/blimp_message_processor.h"
13 #include "blimp/net/input_message_generator.h"
14
15 namespace blink {
16 class WebInputEvent;
17 }
nyquist 2015/11/24 08:55:43 Nit: // namespace blink?
David Trainor- moved to gerrit 2015/11/25 17:56:42 I was explicitly asked not to for short namespace
18
19 namespace cc {
20 namespace proto {
21 class CompositorMessage;
22 }
nyquist 2015/11/24 08:55:43 Nit: end of namespace comment here and below?
David Trainor- moved to gerrit 2015/11/25 17:56:42 See above.
23 }
24
25 namespace blimp {
26
27 // Handles all incoming and outgoing protobuf message types tied to a specific
28 // RenderWidget. This includes BlimpMessage::INPUT, BlimpMessage::COMPOSITOR,
29 // and BlimpMessage::RENDER_WIDGET messages. Delegates can be added to be
30 // notified of incoming messages. This class automatically attaches a specific
31 // id so that the engine can drop stale RenderWidget related messages after it
32 // sends a RenderWidgetMessage::INITIALIZE message.
33 class BLIMP_CLIENT_EXPORT RenderWidgetMessageProcessor
34 : public BlimpMessageProcessor {
35 public:
36 // A delegate to be notified of specific RenderWidget related incoming events.
37 class RenderWidgetMessageDelegate {
38 public:
39 // Called when the engine's RenderWidget has changed for a particular
40 // WebContents. When this is received all state related to the existing
41 // client RenderWidget should be reset.
42 virtual void OnRenderWidgetInitialized() = 0;
43
44 // Called when the engine sent a CompositorMessage. These messages should
45 // be sent to the client's RemoteChannel of the compositor.
46 virtual void OnCompositorMessageReceived(
47 scoped_ptr<cc::proto::CompositorMessage> message) = 0;
48 };
49
50 RenderWidgetMessageProcessor(
51 BlimpMessageProcessor* outgoing_message_processor);
52 ~RenderWidgetMessageProcessor() override;
53
54 // Sends a WebInputEvent for |tab_id| to the engine.
55 void SendInputEvent(const int tab_id, const blink::WebInputEvent& event);
56
57 // Sends a CompositorMessage for |tab_id| to the engine.
58 void SendCompositorMessage(const int tab_id,
59 const cc::proto::CompositorMessage& message);
60
61 // Sets a RenderWidgetMessageDelegate to be notified of all incoming
62 // RenderWidget related messages for |tab_id| from the engine.
63 void SetDelegate(const int tab_id, RenderWidgetMessageDelegate* delegate);
nyquist 2015/11/24 08:55:43 Nit: Could you add a comment saying there can only
David Trainor- moved to gerrit 2015/11/25 17:56:42 Done.
64 void RemoveDelegate(const int tab_id);
65
66 // BlimpMessageProcessor implementation.
67 void ProcessMessage(scoped_ptr<BlimpMessage> message,
68 const net::CompletionCallback& callback) override;
69
70 private:
71 RenderWidgetMessageDelegate* FindDelegate(const int tab_id);
nyquist 2015/11/24 08:55:43 Optional nit: Do we want to add a comment saying t
David Trainor- moved to gerrit 2015/11/25 17:56:42 I assumed it was implicit. I can add a comment th
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 InputMessageGenerator input_message_generator_;
82
83 BlimpMessageProcessor* outgoing_message_processor_;
84
85 DISALLOW_COPY_AND_ASSIGN(RenderWidgetMessageProcessor);
86 };
87
88 } // namespace blimp
89
90 #endif // BLIMP_CLIENT_RENDER_WIDGET_MESSAGE_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698