Chromium Code Reviews| 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..e98f6b588379d4c2318e4edea4920309cbc71ecb |
| --- /dev/null |
| +++ b/content/renderer/presentation/presentation_connection_proxy.h |
| @@ -0,0 +1,70 @@ |
| +// 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" |
|
mark a. foltz
2016/11/16 01:16:39
Nit: Move to .cc
zhaobin
2016/11/23 22:52:29
Done.
|
| +#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 PresentationConnection owned by one frame with |
| +// PresentationConnection owned by a different frame. |
| +// |
| +// |SetSourceConnection| sets |source_connection_| to PresentationConnection |
| +// object owned by current frame. |
|
mark a. foltz
2016/11/16 01:16:39
What defines "current frame"? Maybe just say "own
zhaobin
2016/11/23 22:52:29
Done.
|
| +// |SetTargetConnection| sets |target_connection_| to mojo handle of |
| +// PresentationConnection object owned by a different frame. |
| +// |
| +// 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 controlling frame to receiver frame: |
| +// 1. Controlling frame 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 frame is fired. |
| +// |
| +// Sending message from receiver frame to controlling frame and notifying state |
| +// changes works the same. |
|
mark a. foltz
2016/11/16 01:16:39
Are state changes handled by this proxy or by a di
zhaobin
2016/11/23 22:52:29
Will add state change APIs to Proxy class in futur
|
| +// |
| +// Instance of this class is only created for offscreen presentations. |
| +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 OnMessage(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_ |