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

Side by Side Diff: content/renderer/presentation/presentation_connection_proxy.h

Issue 2471263003: [Presentation API] (4th)(1-UA blink side) Add WebPresentationConnection and WebPresentationConnecti… (Closed)
Patch Set: PresentationConnectionProxy::Send() will be invoked from PresentationDispatcher Created 4 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 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 CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
7
8 #include "base/callback.h"
9 #include "mojo/public/cpp/bindings/binding.h"
10 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nConnectionProxy.h"
11 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h"
12
13 namespace content {
14
15 using OnMessageCallback = base::Callback<void(bool)>;
16
17 // This class connects PresentationConnection owned by one frame with
18 // PresentationConnection owned by a different frame.
19 //
20 // |SetSourceConnection| sets |source_connection_| to PresentationConnection
21 // object owned by one frame.
22 // |SetTargetConnection| sets |target_connection_| to mojo handle of
23 // PresentationConnection object owned by a different frame.
24 //
25 // When both |source_connection_| and |target_connection_| are set,
26 // we can send message or notify state changes between controller and receiver.
27 //
28 // To send message from controlling frame to receiver frame:
29 // 1. Controlling frame invokes connection.sendMessage();
30 // 2. This call is delegated to controller presentation connection proxy's
31 // SendString().
32 // PresentationConnectionProxy::SendString() {
33 // target_connection_->OnConnectionMessageReceived();
34 // }
35 // 3. Receiver PresentationConnectionProxy::OnConnectionMessageReceived() is
36 // invoked.
37 // 4. connection.onmessage event on receiver frame is fired.
38 //
39 // Sending message from receiver frame to controlling frame and notifying state
40 // changes works the same.
41 //
42 // Instance of this class is only created for offscreen presentations.
43 class PresentationConnectionProxy
44 : public blink::WebPresentationConnectionProxy,
45 public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) {
46 public:
47 PresentationConnectionProxy();
48 ~PresentationConnectionProxy() override;
49
50 blink::mojom::PresentationConnectionPtr Bind();
51
52 // WebPresentationConnectionProxy Implementation
53 void SetSourceConnection(
54 blink::WebPresentationConnection* connection) override;
55
56 void SendSessionMessage(
57 blink::mojom::PresentationSessionInfoPtr session,
58 blink::mojom::SessionMessagePtr session_message) const;
59
60 // blink::mojom::PresentationConnection implementation
61 void SetTargetConnection(
62 blink::mojom::PresentationConnectionPtr connection) override;
63 void OnMessage(blink::mojom::SessionMessagePtr message,
64 const OnMessageCallback& callback) override;
65 void DidChangeState(blink::mojom::PresentationConnectionState state) override;
66
67 void RegisterOnMessageCallback(const OnMessageCallback& callback);
68
69 private:
70 mojo::Binding<blink::mojom::PresentationConnection> binding_;
71 blink::mojom::PresentationConnectionPtr target_connection_;
72 blink::WebPresentationConnection* source_connection_;
73 OnMessageCallback on_message_callback_;
74 };
75
76 } // namespace content
77
78 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698