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

Side by Side Diff: Source/core/fetch/Resource.cpp

Issue 243533002: Fix aggressive RELEASE_ASSERTs in Resource (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 471
472 m_clients.add(client); 472 m_clients.add(client);
473 return true; 473 return true;
474 } 474 }
475 475
476 void Resource::removeClient(ResourceClient* client) 476 void Resource::removeClient(ResourceClient* client)
477 { 477 {
478 if (m_clientsAwaitingCallback.contains(client)) { 478 if (m_clientsAwaitingCallback.contains(client)) {
479 ASSERT(!m_clients.contains(client)); 479 ASSERT(!m_clients.contains(client));
480 m_clientsAwaitingCallback.remove(client); 480 m_clientsAwaitingCallback.remove(client);
481 if (m_clientsAwaitingCallback.isEmpty())
482 ResourceCallback::callbackHandler()->cancel(this);
483 } else { 481 } else {
484 RELEASE_ASSERT(m_clients.contains(client)); 482 ASSERT(m_clients.contains(client));
485 m_clients.remove(client); 483 m_clients.remove(client);
486 didRemoveClient(client); 484 didRemoveClient(client);
487 } 485 }
488 486
487 if (m_clientsAwaitingCallback.isEmpty())
488 ResourceCallback::callbackHandler()->cancel(this);
489
489 bool deleted = deleteIfPossible(); 490 bool deleted = deleteIfPossible();
490 if (!deleted && !hasClients()) { 491 if (!deleted && !hasClients()) {
491 memoryCache()->makeDead(this); 492 memoryCache()->makeDead(this);
492 if (!m_switchingClientsToRevalidatedResource) 493 if (!m_switchingClientsToRevalidatedResource)
493 allClientsRemoved(); 494 allClientsRemoved();
494 495
495 // RFC2616 14.9.2: 496 // RFC2616 14.9.2:
496 // "no-store: ... MUST make a best-effort attempt to remove the informat ion from volatile storage as promptly as possible" 497 // "no-store: ... MUST make a best-effort attempt to remove the informat ion from volatile storage as promptly as possible"
497 // "... History buffers MAY store such responses as part of their normal operation." 498 // "... History buffers MAY store such responses as part of their normal operation."
498 // We allow non-secure content to be reused in history, but we do not al low secure content to be reused. 499 // We allow non-secure content to be reused in history, but we do not al low secure content to be reused.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 for (size_t i = 0; i < clientsToNotify.size(); ++i) { 582 for (size_t i = 0; i < clientsToNotify.size(); ++i) {
582 ResourceClient* client = clientsToNotify[i]; 583 ResourceClient* client = clientsToNotify[i];
583 584
584 // Handle case (2) to skip removed clients. 585 // Handle case (2) to skip removed clients.
585 if (!m_clientsAwaitingCallback.remove(client)) 586 if (!m_clientsAwaitingCallback.remove(client))
586 continue; 587 continue;
587 m_clients.add(client); 588 m_clients.add(client);
588 didAddClient(client); 589 didAddClient(client);
589 } 590 }
590 591
591 bool scheduled = ResourceCallback::callbackHandler()->isScheduled(this); 592 // It is still possible for the above loop to finish a new client synchronou sly.
592 // It is a critical problem if a callback is scheduled but there is no clien t waiting for it. 593 // If there's no client waiting we should deschedule.
593 // Such a callback cannot be cancelled. It is better to crash the renderer n ow. 594 if (ResourceCallback::callbackHandler()->isScheduled(this) && m_clientsAwait ingCallback.isEmpty()) {
Nate Chapin 2014/04/18 18:43:46 Style nit: the curly braces are unnecessary.
594 RELEASE_ASSERT(!scheduled || !m_clientsAwaitingCallback.isEmpty()); 595 ResourceCallback::callbackHandler()->cancel(this);
596 }
595 597
596 // Prevent the case when there are clients waiting but no callback scheduled . 598 // Prevent the case when there are clients waiting but no callback scheduled .
597 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); 599 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled);
598 } 600 }
599 601
600 void Resource::prune() 602 void Resource::prune()
601 { 603 {
602 destroyDecodedDataIfPossible(); 604 destroyDecodedDataIfPossible();
603 unlock(); 605 unlock();
604 } 606 }
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 return "ImportResource"; 981 return "ImportResource";
980 case Resource::Media: 982 case Resource::Media:
981 return "Media"; 983 return "Media";
982 } 984 }
983 ASSERT_NOT_REACHED(); 985 ASSERT_NOT_REACHED();
984 return "Unknown"; 986 return "Unknown";
985 } 987 }
986 #endif // !LOG_DISABLED 988 #endif // !LOG_DISABLED
987 989
988 } 990 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698