Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 nConnection.h" | |
|
mark a. foltz
2016/11/16 01:16:39
Nit: Move to .cc
zhaobin
2016/11/23 22:52:29
Done.
| |
| 11 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nConnectionProxy.h" | |
| 12 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 // This class connects PresentationConnection owned by one frame with | |
| 17 // PresentationConnection owned by a different frame. | |
| 18 // | |
| 19 // |SetSourceConnection| sets |source_connection_| to PresentationConnection | |
| 20 // 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.
| |
| 21 // |SetTargetConnection| sets |target_connection_| to mojo handle of | |
| 22 // PresentationConnection object owned by a different frame. | |
| 23 // | |
| 24 // When both |source_connection_| and |target_connection_| are set, | |
| 25 // we can send message or notify state changes between controller and receiver. | |
| 26 // | |
| 27 // To send message from controlling frame to receiver frame: | |
| 28 // 1. Controlling frame invokes connection.sendMessage(); | |
| 29 // 2. This call is delegated to controller presentation connection proxy's | |
| 30 // SendString(). | |
| 31 // PresentationConnectionProxy::SendString() { | |
| 32 // target_connection_->OnConnectionMessageReceived(); | |
| 33 // } | |
| 34 // 3. Receiver PresentationConnectionProxy::OnConnectionMessageReceived() is | |
| 35 // invoked. | |
| 36 // 4. connection.onmessage event on receiver frame is fired. | |
| 37 // | |
| 38 // Sending message from receiver frame to controlling frame and notifying state | |
| 39 // 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
| |
| 40 // | |
| 41 // Instance of this class is only created for offscreen presentations. | |
| 42 class PresentationConnectionProxy | |
| 43 : public blink::WebPresentationConnectionProxy, | |
| 44 public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) { | |
| 45 public: | |
| 46 PresentationConnectionProxy(); | |
| 47 ~PresentationConnectionProxy() override; | |
| 48 | |
| 49 blink::mojom::PresentationConnectionPtr Bind(); | |
| 50 | |
| 51 // WebPresentationConnectionProxy Implementation | |
| 52 void SetSourceConnection( | |
| 53 blink::WebPresentationConnection* connection) override; | |
| 54 void SendString(const blink::WebString& message) override; | |
| 55 void SendArrayBuffer(const uint8_t* data, size_t length) override; | |
| 56 | |
| 57 // blink::mojom::PresentationConnection implementation | |
| 58 void SetTargetConnection( | |
| 59 blink::mojom::PresentationConnectionPtr connection) override; | |
| 60 void OnMessage(blink::mojom::SessionMessagePtr message) override; | |
| 61 | |
| 62 private: | |
| 63 mojo::Binding<blink::mojom::PresentationConnection> binding_; | |
| 64 blink::mojom::PresentationConnectionPtr target_connection_; | |
| 65 blink::WebPresentationConnection* source_connection_; | |
| 66 }; | |
| 67 | |
| 68 } // namespace content | |
| 69 | |
| 70 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_ | |
| OLD | NEW |