| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/presentation/presentation_connection_proxy.h" | 5 #include "content/renderer/presentation/presentation_connection_proxy.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/public/common/presentation_info.h" | 8 #include "content/public/common/presentation_info.h" |
| 9 #include "content/renderer/presentation/presentation_dispatcher.h" | 9 #include "content/renderer/presentation/presentation_dispatcher.h" |
| 10 #include "third_party/WebKit/public/platform/WebString.h" | 10 #include "third_party/WebKit/public/platform/WebString.h" |
| 11 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnection.h" | 11 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nConnection.h" |
| 12 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" | 12 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nController.h" |
| 13 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nInfo.h" | 13 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nInfo.h" |
| 14 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nReceiver.h" |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 | 17 |
| 17 PresentationConnectionProxy::PresentationConnectionProxy( | 18 PresentationConnectionProxy::PresentationConnectionProxy( |
| 18 blink::WebPresentationConnection* source_connection) | 19 blink::WebPresentationConnection* source_connection) |
| 19 : binding_(this), | 20 : binding_(this), |
| 20 target_connection_ptr_(nullptr), | 21 target_connection_ptr_(nullptr), |
| 21 source_connection_(source_connection) { | 22 source_connection_(source_connection) { |
| 22 DCHECK(source_connection_); | 23 DCHECK(source_connection_); |
| 23 } | 24 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } else if (state == content::PRESENTATION_CONNECTION_STATE_TERMINATED) { | 60 } else if (state == content::PRESENTATION_CONNECTION_STATE_TERMINATED) { |
| 60 source_connection_->DidChangeState( | 61 source_connection_->DidChangeState( |
| 61 blink::WebPresentationConnectionState::kTerminated); | 62 blink::WebPresentationConnectionState::kTerminated); |
| 62 } else { | 63 } else { |
| 63 NOTREACHED(); | 64 NOTREACHED(); |
| 64 } | 65 } |
| 65 } | 66 } |
| 66 | 67 |
| 67 void PresentationConnectionProxy::OnClose() { | 68 void PresentationConnectionProxy::OnClose() { |
| 68 DCHECK(target_connection_ptr_); | 69 DCHECK(target_connection_ptr_); |
| 69 source_connection_->DidClose(); | 70 DidChangeState(content::PRESENTATION_CONNECTION_STATE_CLOSED); |
| 70 target_connection_ptr_->DidChangeState( | 71 target_connection_ptr_->DidChangeState( |
| 71 content::PRESENTATION_CONNECTION_STATE_CLOSED); | 72 content::PRESENTATION_CONNECTION_STATE_CLOSED); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void PresentationConnectionProxy::Close() const { | 75 void PresentationConnectionProxy::Close() const { |
| 75 DCHECK(target_connection_ptr_); | 76 DCHECK(target_connection_ptr_); |
| 76 target_connection_ptr_->OnClose(); | 77 target_connection_ptr_->OnClose(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void PresentationConnectionProxy::NotifyTargetConnection( | 80 void PresentationConnectionProxy::NotifyTargetConnection( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 } | 99 } |
| 99 | 100 |
| 100 blink::mojom::PresentationConnectionRequest | 101 blink::mojom::PresentationConnectionRequest |
| 101 ControllerConnectionProxy::MakeRemoteRequest() { | 102 ControllerConnectionProxy::MakeRemoteRequest() { |
| 102 DCHECK(!target_connection_ptr_) | 103 DCHECK(!target_connection_ptr_) |
| 103 << "target_connection_ptr_ should only be bound once."; | 104 << "target_connection_ptr_ should only be bound once."; |
| 104 return mojo::MakeRequest(&target_connection_ptr_); | 105 return mojo::MakeRequest(&target_connection_ptr_); |
| 105 } | 106 } |
| 106 | 107 |
| 107 ReceiverConnectionProxy::ReceiverConnectionProxy( | 108 ReceiverConnectionProxy::ReceiverConnectionProxy( |
| 108 blink::WebPresentationConnection* receiver_connection) | 109 blink::WebPresentationConnection* receiver_connection, |
| 109 : PresentationConnectionProxy(receiver_connection) {} | 110 blink::WebPresentationReceiver* receiver) |
| 111 : PresentationConnectionProxy(receiver_connection), receiver_(receiver) { |
| 112 DCHECK(receiver_); |
| 113 } |
| 110 | 114 |
| 111 ReceiverConnectionProxy::~ReceiverConnectionProxy() = default; | 115 ReceiverConnectionProxy::~ReceiverConnectionProxy() = default; |
| 112 | 116 |
| 113 void ReceiverConnectionProxy::Bind( | 117 void ReceiverConnectionProxy::Bind( |
| 114 blink::mojom::PresentationConnectionRequest receiver_connection_request) { | 118 blink::mojom::PresentationConnectionRequest receiver_connection_request) { |
| 115 binding_.Bind(std::move(receiver_connection_request)); | 119 binding_.Bind(std::move(receiver_connection_request)); |
| 116 } | 120 } |
| 117 | 121 |
| 118 void ReceiverConnectionProxy::BindControllerConnection( | 122 void ReceiverConnectionProxy::BindControllerConnection( |
| 119 blink::mojom::PresentationConnectionPtr controller_connection_ptr) { | 123 blink::mojom::PresentationConnectionPtr controller_connection_ptr) { |
| 120 DCHECK(!target_connection_ptr_); | 124 DCHECK(!target_connection_ptr_); |
| 121 target_connection_ptr_ = std::move(controller_connection_ptr); | 125 target_connection_ptr_ = std::move(controller_connection_ptr); |
| 122 target_connection_ptr_->DidChangeState( | 126 target_connection_ptr_->DidChangeState( |
| 123 content::PRESENTATION_CONNECTION_STATE_CONNECTED); | 127 content::PRESENTATION_CONNECTION_STATE_CONNECTED); |
| 124 | 128 |
| 125 DidChangeState(content::PRESENTATION_CONNECTION_STATE_CONNECTED); | 129 DidChangeState(content::PRESENTATION_CONNECTION_STATE_CONNECTED); |
| 126 } | 130 } |
| 127 | 131 |
| 132 void ReceiverConnectionProxy::DidChangeState( |
| 133 content::PresentationConnectionState state) { |
| 134 PresentationConnectionProxy::DidChangeState(state); |
| 135 if (state == content::PRESENTATION_CONNECTION_STATE_CLOSED) |
| 136 receiver_->RemoveConnection(source_connection_); |
| 137 } |
| 138 |
| 128 } // namespace content | 139 } // namespace content |
| OLD | NEW |