Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: content/renderer/presentation/presentation_connection_proxy.cc

Issue 2863903002: [Presentation API] Change controller connection to 'terminated' when receiver connection terminates (Closed)
Patch Set: fix layout test failures Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 // TODO(crbug.com/588874): Ensure legal PresentationConnection state transitions 50 // TODO(crbug.com/588874): Ensure legal PresentationConnection state transitions
51 // in a single place. 51 // in a single place.
52 void PresentationConnectionProxy::DidChangeState( 52 void PresentationConnectionProxy::DidChangeState(
53 content::PresentationConnectionState state) { 53 content::PresentationConnectionState state) {
54 if (state == content::PRESENTATION_CONNECTION_STATE_CONNECTED) { 54 if (state == content::PRESENTATION_CONNECTION_STATE_CONNECTED) {
55 source_connection_->DidChangeState( 55 source_connection_->DidChangeState(
56 blink::WebPresentationConnectionState::kConnected); 56 blink::WebPresentationConnectionState::kConnected);
57 } else if (state == content::PRESENTATION_CONNECTION_STATE_CLOSED) { 57 } else if (state == content::PRESENTATION_CONNECTION_STATE_CLOSED) {
58 source_connection_->DidClose(); 58 source_connection_->DidClose();
59 } else if (state == content::PRESENTATION_CONNECTION_STATE_TERMINATED) {
60 source_connection_->DidChangeState(
61 blink::WebPresentationConnectionState::kTerminated);
59 } else { 62 } else {
60 NOTREACHED(); 63 NOTREACHED();
61 } 64 }
62 } 65 }
63 66
64 void PresentationConnectionProxy::OnClose() { 67 void PresentationConnectionProxy::OnClose() {
65 DCHECK(target_connection_ptr_); 68 DCHECK(target_connection_ptr_);
66 source_connection_->DidClose(); 69 source_connection_->DidClose();
67 target_connection_ptr_->DidChangeState( 70 target_connection_ptr_->DidChangeState(
68 content::PRESENTATION_CONNECTION_STATE_CLOSED); 71 content::PRESENTATION_CONNECTION_STATE_CLOSED);
69 } 72 }
70 73
71 void PresentationConnectionProxy::Close() const { 74 void PresentationConnectionProxy::Close() const {
72 DCHECK(target_connection_ptr_); 75 DCHECK(target_connection_ptr_);
73 target_connection_ptr_->OnClose(); 76 target_connection_ptr_->OnClose();
74 } 77 }
75 78
79 void PresentationConnectionProxy::NotifyTargetConnection(
80 blink::WebPresentationConnectionState state) {
81 if (!target_connection_ptr_)
82 return;
83
84 if (state == blink::WebPresentationConnectionState::kTerminated) {
85 target_connection_ptr_->DidChangeState(
86 content::PRESENTATION_CONNECTION_STATE_TERMINATED);
87 }
88 }
89
76 ControllerConnectionProxy::ControllerConnectionProxy( 90 ControllerConnectionProxy::ControllerConnectionProxy(
77 blink::WebPresentationConnection* controller_connection) 91 blink::WebPresentationConnection* controller_connection)
78 : PresentationConnectionProxy(controller_connection) {} 92 : PresentationConnectionProxy(controller_connection) {}
79 93
80 ControllerConnectionProxy::~ControllerConnectionProxy() = default; 94 ControllerConnectionProxy::~ControllerConnectionProxy() = default;
81 95
82 blink::mojom::PresentationConnectionPtr ControllerConnectionProxy::Bind() { 96 blink::mojom::PresentationConnectionPtr ControllerConnectionProxy::Bind() {
83 return binding_.CreateInterfacePtrAndBind(); 97 return binding_.CreateInterfacePtrAndBind();
84 } 98 }
85 99
(...skipping 19 matching lines...) Expand all
105 blink::mojom::PresentationConnectionPtr controller_connection_ptr) { 119 blink::mojom::PresentationConnectionPtr controller_connection_ptr) {
106 DCHECK(!target_connection_ptr_); 120 DCHECK(!target_connection_ptr_);
107 target_connection_ptr_ = std::move(controller_connection_ptr); 121 target_connection_ptr_ = std::move(controller_connection_ptr);
108 target_connection_ptr_->DidChangeState( 122 target_connection_ptr_->DidChangeState(
109 content::PRESENTATION_CONNECTION_STATE_CONNECTED); 123 content::PRESENTATION_CONNECTION_STATE_CONNECTED);
110 124
111 DidChangeState(content::PRESENTATION_CONNECTION_STATE_CONNECTED); 125 DidChangeState(content::PRESENTATION_CONNECTION_STATE_CONNECTED);
112 } 126 }
113 127
114 } // namespace content 128 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698