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

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: resolve code review comments from Mark 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 client->closeSession(m_url, m_id); 404 client->closeSession(m_url, m_id);
405 405
406 tearDown(); 406 tearDown();
407 } 407 }
408 408
409 void PresentationConnection::terminate() { 409 void PresentationConnection::terminate() {
410 if (m_state != WebPresentationConnectionState::Connected) 410 if (m_state != WebPresentationConnectionState::Connected)
411 return; 411 return;
412 WebPresentationClient* client = presentationClient(getExecutionContext()); 412 WebPresentationClient* client = presentationClient(getExecutionContext());
413 if (client) 413 if (client)
414 client->terminateSession(m_url, m_id); 414 client->terminateConnection(m_url, m_id);
415 415
416 tearDown(); 416 tearDown();
417 } 417 }
418 418
419 bool PresentationConnection::matches( 419 bool PresentationConnection::matches(
420 const WebPresentationSessionInfo& sessionInfo) const { 420 const WebPresentationSessionInfo& sessionInfo) const {
421 return m_url == KURL(sessionInfo.url) && m_id == String(sessionInfo.id); 421 return m_url == KURL(sessionInfo.url) && m_id == String(sessionInfo.id);
422 } 422 }
423 423
424 bool PresentationConnection::matches(const String& id, const KURL& url) const { 424 bool PresentationConnection::matches(const String& id, const KURL& url) const {
425 return m_url == url && m_id == id; 425 return m_url == url && m_id == id;
426 } 426 }
427 427
428 void PresentationConnection::didChangeState( 428 void PresentationConnection::didChangeState(
429 WebPresentationConnectionState state) { 429 WebPresentationConnectionState state) {
430 didChangeState(state, true /* shouldDispatchEvent */);
431 }
432
433 void PresentationConnection::didChangeState(
434 WebPresentationConnectionState state,
435 bool shouldDispatchEvent) {
430 if (m_state == state) 436 if (m_state == state)
431 return; 437 return;
432 438
433 m_state = state; 439 m_state = state;
440
441 if (!shouldDispatchEvent)
442 return;
443
434 switch (m_state) { 444 switch (m_state) {
435 case WebPresentationConnectionState::Connecting: 445 case WebPresentationConnectionState::Connecting:
436 NOTREACHED(); 446 NOTREACHED();
437 return; 447 return;
438 case WebPresentationConnectionState::Connected: 448 case WebPresentationConnectionState::Connected:
439 dispatchStateChangeEvent(Event::create(EventTypeNames::connect)); 449 dispatchStateChangeEvent(Event::create(EventTypeNames::connect));
440 return; 450 return;
441 case WebPresentationConnectionState::Terminated: 451 case WebPresentationConnectionState::Terminated:
442 dispatchStateChangeEvent(Event::create(EventTypeNames::terminate)); 452 dispatchStateChangeEvent(Event::create(EventTypeNames::terminate));
443 return; 453 return;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 void PresentationConnection::tearDown() { 514 void PresentationConnection::tearDown() {
505 // Cancel current Blob loading if any. 515 // Cancel current Blob loading if any.
506 if (m_blobLoader) { 516 if (m_blobLoader) {
507 m_blobLoader->cancel(); 517 m_blobLoader->cancel();
508 m_blobLoader.clear(); 518 m_blobLoader.clear();
509 } 519 }
510 m_messages.clear(); 520 m_messages.clear();
511 } 521 }
512 522
513 } // namespace blink 523 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698