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

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

Issue 231873006: Make sure resource client is called asynchronously (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments 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
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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 556 }
557 557
558 void Resource::didAccessDecodedData() 558 void Resource::didAccessDecodedData()
559 { 559 {
560 memoryCache()->updateDecodedResource(this, UpdateForAccess); 560 memoryCache()->updateDecodedResource(this, UpdateForAccess);
561 memoryCache()->prune(); 561 memoryCache()->prune();
562 } 562 }
563 563
564 void Resource::finishPendingClients() 564 void Resource::finishPendingClients()
565 { 565 {
566 while (!m_clientsAwaitingCallback.isEmpty()) { 566 // Clients can be added during the loop. We must not process them now.
567 ResourceClient* client = m_clientsAwaitingCallback.begin()->key; 567 // So save the current set to the stack.
568 m_clientsAwaitingCallback.remove(client); 568 HashCountedSet<ResourceClient*> clientsAwaitingCallback;
569 m_clients.add(client); 569 clientsAwaitingCallback.swap(m_clientsAwaitingCallback);
570 didAddClient(client); 570
571 for (HashCountedSet<ResourceClient*>::iterator it = clientsAwaitingCallback. begin(); it != clientsAwaitingCallback.end(); ++it) {
572 m_clients.add(it->key);
573 didAddClient(it->key);
571 } 574 }
575 // It is a critical problem if a callback is scheduled but there is no clien t waiting for it.
576 // Such a callback cannot be cancelled. It is better to crash the renderer n ow.
577 RELEASE_ASSERT(!ResourceCallback::callbackHandler()->isScheduled(this) || !m _clientsAwaitingCallback.isEmpty());
572 } 578 }
573 579
574 void Resource::prune() 580 void Resource::prune()
575 { 581 {
576 destroyDecodedDataIfPossible(); 582 destroyDecodedDataIfPossible();
577 unlock(); 583 unlock();
578 } 584 }
579 585
580 void Resource::setResourceToRevalidate(Resource* resource) 586 void Resource::setResourceToRevalidate(Resource* resource)
581 { 587 {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 return "Shader"; 948 return "Shader";
943 case Resource::ImportResource: 949 case Resource::ImportResource:
944 return "ImportResource"; 950 return "ImportResource";
945 } 951 }
946 ASSERT_NOT_REACHED(); 952 ASSERT_NOT_REACHED();
947 return "Unknown"; 953 return "Unknown";
948 } 954 }
949 #endif // !LOG_DISABLED 955 #endif // !LOG_DISABLED
950 956
951 } 957 }
OLDNEW
« Source/core/fetch/RawResourceTest.cpp ('K') | « Source/core/fetch/RawResourceTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698