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

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: resolve code review comments from Mark 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 // |on_message_callback| will be invoked once per message received.
48 PresentationConnectionProxy(const OnMessageCallback& on_message_callback);
49 ~PresentationConnectionProxy() override;
50
51 blink::mojom::PresentationConnectionPtr Bind();
52
53 // WebPresentationConnectionProxy Implementation
54 void SetSourceConnection(
55 blink::WebPresentationConnection* connection) override;
56
57 void SendSessionMessage(
58 blink::mojom::PresentationSessionInfoPtr session,
59 blink::mojom::SessionMessagePtr session_message) const;
60
61 // blink::mojom::PresentationConnection implementation
62 void SetTargetConnection(
63 blink::mojom::PresentationConnectionPtr connection) override;
64 void OnMessage(blink::mojom::SessionMessagePtr message,
65 const OnMessageCallback& callback) override;
66 void DidChangeState(blink::mojom::PresentationConnectionState state) override;
67
68 private:
69 mojo::Binding<blink::mojom::PresentationConnection> binding_;
70 blink::mojom::PresentationConnectionPtr target_connection_;
71 blink::WebPresentationConnection* source_connection_;
72 OnMessageCallback on_message_callback_;
73 };
74
75 } // namespace content
76
77 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698