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

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

Issue 2484273003: [Presentation API] (1-UA) fire PresentationConnection onterminate event if receiver page gets destr… (Closed)
Patch Set: rebase Created 3 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_dispatcher.h" 5 #include "content/renderer/presentation/presentation_dispatcher.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 }), 275 }),
276 message_request_queue_.end()); 276 message_request_queue_.end());
277 277
278 connection_proxy->close(); 278 connection_proxy->close();
279 279
280 ConnectToPresentationServiceIfNeeded(); 280 ConnectToPresentationServiceIfNeeded();
281 presentation_service_->CloseConnection(presentationUrl, 281 presentation_service_->CloseConnection(presentationUrl,
282 presentationId.utf8()); 282 presentationId.utf8());
283 } 283 }
284 284
285 void PresentationDispatcher::terminateSession( 285 void PresentationDispatcher::terminateConnection(
286 const blink::WebURL& presentationUrl, 286 const blink::WebURL& presentationUrl,
287 const blink::WebString& presentationId) { 287 const blink::WebString& presentationId) {
288 if (receiver_) {
289 receiver_->terminateConnection();
290 return;
291 }
292
288 ConnectToPresentationServiceIfNeeded(); 293 ConnectToPresentationServiceIfNeeded();
289 presentation_service_->Terminate(presentationUrl, presentationId.utf8()); 294 presentation_service_->Terminate(presentationUrl, presentationId.utf8());
290 } 295 }
291 296
292 void PresentationDispatcher::getAvailability( 297 void PresentationDispatcher::getAvailability(
293 const blink::WebVector<blink::WebURL>& availabilityUrls, 298 const blink::WebVector<blink::WebURL>& availabilityUrls,
294 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callback) { 299 std::unique_ptr<blink::WebPresentationAvailabilityCallbacks> callback) {
295 DCHECK(!availabilityUrls.isEmpty()); 300 DCHECK(!availabilityUrls.isEmpty());
296 301
297 std::vector<GURL> urls; 302 std::vector<GURL> urls;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 401
397 // Remove all pending send message requests. 402 // Remove all pending send message requests.
398 MessageRequestQueue empty; 403 MessageRequestQueue empty;
399 std::swap(message_request_queue_, empty); 404 std::swap(message_request_queue_, empty);
400 } 405 }
401 406
402 void PresentationDispatcher::OnDestruct() { 407 void PresentationDispatcher::OnDestruct() {
403 delete this; 408 delete this;
404 } 409 }
405 410
411 void PresentationDispatcher::WidgetWillClose() {
412 if (!receiver_)
413 return;
414
415 receiver_->didChangeSessionState(
416 blink::WebPresentationConnectionState::Terminated);
417 }
418
406 void PresentationDispatcher::OnScreenAvailabilityUpdated(const GURL& url, 419 void PresentationDispatcher::OnScreenAvailabilityUpdated(const GURL& url,
407 bool available) { 420 bool available) {
408 auto* listening_status = GetListeningStatus(url); 421 auto* listening_status = GetListeningStatus(url);
409 if (!listening_status) 422 if (!listening_status)
410 return; 423 return;
411 424
412 if (listening_status->listening_state == ListeningState::WAITING) 425 if (listening_status->listening_state == ListeningState::WAITING)
413 listening_status->listening_state = ListeningState::ACTIVE; 426 listening_status->listening_state = ListeningState::ACTIVE;
414 427
415 auto new_screen_availability = available ? ScreenAvailability::AVAILABLE 428 auto new_screen_availability = available ? ScreenAvailability::AVAILABLE
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 805
793 PresentationDispatcher::ListeningStatus::ListeningStatus( 806 PresentationDispatcher::ListeningStatus::ListeningStatus(
794 const GURL& availability_url) 807 const GURL& availability_url)
795 : url(availability_url), 808 : url(availability_url),
796 last_known_availability(ScreenAvailability::UNKNOWN), 809 last_known_availability(ScreenAvailability::UNKNOWN),
797 listening_state(ListeningState::INACTIVE) {} 810 listening_state(ListeningState::INACTIVE) {}
798 811
799 PresentationDispatcher::ListeningStatus::~ListeningStatus() {} 812 PresentationDispatcher::ListeningStatus::~ListeningStatus() {}
800 813
801 } // namespace content 814 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698