Index: content/renderer/presentation/presentation_connection_proxy.h |
diff --git a/content/renderer/presentation/presentation_connection_proxy.h b/content/renderer/presentation/presentation_connection_proxy.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..17fd7d421935aa1d50ffdf91380a59a80ed0c268 |
--- /dev/null |
+++ b/content/renderer/presentation/presentation_connection_proxy.h |
@@ -0,0 +1,73 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_ |
+#define CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_ |
+ |
+#include "base/callback.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
+#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationConnection.h" |
+#include "third_party/WebKit/public/platform/modules/presentation/WebPresentationConnectionProxy.h" |
+#include "third_party/WebKit/public/platform/modules/presentation/presentation.mojom.h" |
+ |
+namespace content { |
+ |
+// This class connects PrensentationConnection object living in |
mark a. foltz
2016/10/21 00:53:03
typo in PresentationConnection
zhaobin
2016/10/22 02:44:13
Done.
|
+// controller(receiver) render process |
mark a. foltz
2016/10/21 00:53:03
... one frame with a PresentationConnection owned
zhaobin
2016/10/22 02:44:13
Done.
|
+// with PresentationConnection object living in receiver(controller) render |
+// process. |
mark a. foltz
2016/10/21 00:53:03
It's up to the embedder to decide whether the cont
zhaobin
2016/10/22 02:44:13
Done.
|
+// |
+// |SetSourceConnection| sets |source_connection_| to PresentationConnection |
+// object lives in current render process. |
+// |SetTargetConnection| sets |target_connection_| to mojo handle of |
+// PresentationConnection object lives in remote render process. |
+// |
+// When both |source_connection_| and |target_connection_| are set, |
+// we can send message or notify state changes between controller and receiver. |
+// |
+// To send message from controller page to receiver page: |
mark a. foltz
2016/10/21 00:53:03
controlling frame to receiver frame:
zhaobin
2016/10/22 02:44:13
Done.
|
+// 1. controller page invokes connection.sendMessage(); |
+// 2. This call is delegated to controller presentation connection proxy's |
+// SendString(). |
+// PresentationConnectionProxy::SendString() { |
+// target_connection_->OnConnectionMessageReceived(); |
+// } |
+// 3. Receiver PresentationConnectionProxy::OnConnectionMessageReceived() is |
+// invoked. |
+// 4. connection.onmessage event on receiver page is fired. |
+// |
+// Sending message from receiver to controller and notifying state changes |
+// between controller and receiver works the same. |
+// |
+// Instance of this class is only created for 1-UA mode. |
mark a. foltz
2016/10/21 00:53:03
s/1-UA mode/offscreen presentations/
zhaobin
2016/10/22 02:44:13
Done.
|
+class PresentationConnectionProxy |
+ : public blink::WebPresentationConnectionProxy, |
+ public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) { |
+ public: |
+ PresentationConnectionProxy(); |
+ ~PresentationConnectionProxy() override; |
+ |
+ blink::mojom::PresentationConnectionPtr Bind(); |
+ |
+ // WebPresentationConnectionProxy Implementation |
+ void SetSourceConnection( |
+ blink::WebPresentationConnection* connection) override; |
+ void SendString(const blink::WebString& message) override; |
+ void SendArrayBuffer(const uint8_t* data, size_t length) override; |
+ |
+ // blink::mojom::PresentationConnection implementation |
+ void SetTargetConnection( |
+ blink::mojom::PresentationConnectionPtr connection) override; |
+ void OnConnectionMessageReceived( |
+ blink::mojom::SessionMessagePtr message) override; |
+ |
+ private: |
+ mojo::Binding<blink::mojom::PresentationConnection> binding_; |
+ blink::mojom::PresentationConnectionPtr target_connection_; |
+ blink::WebPresentationConnection* source_connection_; |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_ |