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

Side by Side Diff: third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp

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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "modules/presentation/PresentationConnection.h" 5 #include "modules/presentation/PresentationConnection.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/dom/DOMArrayBuffer.h" 8 #include "core/dom/DOMArrayBuffer.h"
9 #include "core/dom/DOMArrayBufferView.h" 9 #include "core/dom/DOMArrayBufferView.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 client->closeSession(m_url, m_id, m_proxy.get()); 402 client->closeSession(m_url, m_id, m_proxy.get());
403 403
404 tearDown(); 404 tearDown();
405 } 405 }
406 406
407 void PresentationConnection::terminate() { 407 void PresentationConnection::terminate() {
408 if (m_state != WebPresentationConnectionState::Connected) 408 if (m_state != WebPresentationConnectionState::Connected)
409 return; 409 return;
410 WebPresentationClient* client = presentationClient(getExecutionContext()); 410 WebPresentationClient* client = presentationClient(getExecutionContext());
411 if (client) 411 if (client)
412 client->terminateSession(m_url, m_id); 412 client->terminateConnection(m_url, m_id);
413 413
414 tearDown(); 414 tearDown();
415 } 415 }
416 416
417 bool PresentationConnection::matches( 417 bool PresentationConnection::matches(
418 const WebPresentationSessionInfo& sessionInfo) const { 418 const WebPresentationSessionInfo& sessionInfo) const {
419 return m_url == KURL(sessionInfo.url) && m_id == String(sessionInfo.id); 419 return m_url == KURL(sessionInfo.url) && m_id == String(sessionInfo.id);
420 } 420 }
421 421
422 bool PresentationConnection::matches(const String& id, const KURL& url) const { 422 bool PresentationConnection::matches(const String& id, const KURL& url) const {
423 return m_url == url && m_id == id; 423 return m_url == url && m_id == id;
424 } 424 }
425 425
426 void PresentationConnection::didChangeState( 426 void PresentationConnection::didChangeState(
427 WebPresentationConnectionState state) { 427 WebPresentationConnectionState state) {
428 didChangeState(state, true /* shouldDispatchEvent */);
429 }
430
431 void PresentationConnection::didChangeState(
432 WebPresentationConnectionState state,
433 bool shouldDispatchEvent) {
428 if (m_state == state) 434 if (m_state == state)
429 return; 435 return;
430 436
431 m_state = state; 437 m_state = state;
438
439 if (!shouldDispatchEvent)
440 return;
441
432 switch (m_state) { 442 switch (m_state) {
433 case WebPresentationConnectionState::Connecting: 443 case WebPresentationConnectionState::Connecting:
434 NOTREACHED(); 444 NOTREACHED();
435 return; 445 return;
436 case WebPresentationConnectionState::Connected: 446 case WebPresentationConnectionState::Connected:
437 dispatchStateChangeEvent(Event::create(EventTypeNames::connect)); 447 dispatchStateChangeEvent(Event::create(EventTypeNames::connect));
438 return; 448 return;
439 case WebPresentationConnectionState::Terminated: 449 case WebPresentationConnectionState::Terminated:
440 dispatchStateChangeEvent(Event::create(EventTypeNames::terminate)); 450 dispatchStateChangeEvent(Event::create(EventTypeNames::terminate));
441 return; 451 return;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 void PresentationConnection::tearDown() { 512 void PresentationConnection::tearDown() {
503 // Cancel current Blob loading if any. 513 // Cancel current Blob loading if any.
504 if (m_blobLoader) { 514 if (m_blobLoader) {
505 m_blobLoader->cancel(); 515 m_blobLoader->cancel();
506 m_blobLoader.clear(); 516 m_blobLoader.clear();
507 } 517 }
508 m_messages.clear(); 518 m_messages.clear();
509 } 519 }
510 520
511 } // namespace blink 521 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698