Chromium Code Reviews| 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_session.h" | 8 #include "content/public/common/presentation_session.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" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 callback.Run(true); | 59 callback.Run(true); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // TODO(crbug.com/588874): Ensure legal PresentationConnection state transitions | 62 // TODO(crbug.com/588874): Ensure legal PresentationConnection state transitions |
| 63 // in a single place. | 63 // in a single place. |
| 64 void PresentationConnectionProxy::DidChangeState( | 64 void PresentationConnectionProxy::DidChangeState( |
| 65 content::PresentationConnectionState state) { | 65 content::PresentationConnectionState state) { |
| 66 if (state != content::PRESENTATION_CONNECTION_STATE_CONNECTED) { | 66 if (state == content::PRESENTATION_CONNECTION_STATE_CONNECTED) { |
| 67 // |DidChangeState| should only handle state transition from connecting -> | 67 source_connection_->didChangeState( |
| 68 // connected. PresentationService and MRP handles other state transitions. | 68 blink::WebPresentationConnectionState::Connected); |
|
dcheng
2017/03/02 07:31:07
Kind of feels like it'd be easier to just pass in
zhaobin
2017/03/02 21:52:20
Created crbug.com/698000.
| |
| 69 } else if (state == content::PRESENTATION_CONNECTION_STATE_CLOSED) { | |
| 70 source_connection_->didChangeState( | |
| 71 blink::WebPresentationConnectionState::Closed); | |
| 72 } else { | |
| 69 NOTREACHED(); | 73 NOTREACHED(); |
| 70 return; | |
| 71 } | 74 } |
| 75 } | |
| 72 | 76 |
| 77 void PresentationConnectionProxy::OnClose() { | |
| 78 DCHECK(target_connection_ptr_); | |
| 73 source_connection_->didChangeState( | 79 source_connection_->didChangeState( |
| 74 blink::WebPresentationConnectionState::Connected); | 80 blink::WebPresentationConnectionState::Closed); |
| 81 target_connection_ptr_->DidChangeState( | |
| 82 content::PRESENTATION_CONNECTION_STATE_CLOSED); | |
| 83 } | |
| 84 | |
| 85 void PresentationConnectionProxy::close() const { | |
| 86 DCHECK(target_connection_ptr_); | |
| 87 target_connection_ptr_->OnClose(); | |
| 75 } | 88 } |
| 76 | 89 |
| 77 ControllerConnectionProxy::ControllerConnectionProxy( | 90 ControllerConnectionProxy::ControllerConnectionProxy( |
| 78 blink::WebPresentationConnection* controller_connection) | 91 blink::WebPresentationConnection* controller_connection) |
| 79 : PresentationConnectionProxy(controller_connection) {} | 92 : PresentationConnectionProxy(controller_connection) {} |
| 80 | 93 |
| 81 ControllerConnectionProxy::~ControllerConnectionProxy() = default; | 94 ControllerConnectionProxy::~ControllerConnectionProxy() = default; |
| 82 | 95 |
| 83 blink::mojom::PresentationConnectionPtr ControllerConnectionProxy::Bind() { | 96 blink::mojom::PresentationConnectionPtr ControllerConnectionProxy::Bind() { |
| 84 return binding_.CreateInterfacePtrAndBind(); | 97 return binding_.CreateInterfacePtrAndBind(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 106 blink::mojom::PresentationConnectionPtr controller_connection_ptr) { | 119 blink::mojom::PresentationConnectionPtr controller_connection_ptr) { |
| 107 DCHECK(!target_connection_ptr_); | 120 DCHECK(!target_connection_ptr_); |
| 108 target_connection_ptr_ = std::move(controller_connection_ptr); | 121 target_connection_ptr_ = std::move(controller_connection_ptr); |
| 109 target_connection_ptr_->DidChangeState( | 122 target_connection_ptr_->DidChangeState( |
| 110 content::PRESENTATION_CONNECTION_STATE_CONNECTED); | 123 content::PRESENTATION_CONNECTION_STATE_CONNECTED); |
| 111 | 124 |
| 112 DidChangeState(content::PRESENTATION_CONNECTION_STATE_CONNECTED); | 125 DidChangeState(content::PRESENTATION_CONNECTION_STATE_CONNECTED); |
| 113 } | 126 } |
| 114 | 127 |
| 115 } // namespace content | 128 } // namespace content |
| OLD | NEW |