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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResource.cpp

Issue 2182023002: Bug fix: Fix wrong assumption in ImageResource when adding observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address on hiroshige's review Created 4 years, 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp » ('j') | 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 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 HashCountedSet<ImageResourceObserver*> observers; 110 HashCountedSet<ImageResourceObserver*> observers;
111 m_observers.swap(observers); 111 m_observers.swap(observers);
112 for (const auto& it : observers) 112 for (const auto& it : observers)
113 m_finishedObservers.add(it.key, it.value); 113 m_finishedObservers.add(it.key, it.value);
114 114
115 Resource::markClientsAndObserversFinished(); 115 Resource::markClientsAndObserversFinished();
116 } 116 }
117 117
118 void ImageResource::didAddClient(ResourceClient* client) 118 void ImageResource::didAddClient(ResourceClient* client)
119 { 119 {
120 DCHECK(!m_data || m_image); 120 DCHECK((m_multipartParser && isLoading()) || !m_data || m_image);
121 Resource::didAddClient(client); 121 Resource::didAddClient(client);
122 } 122 }
123 123
124 void ImageResource::addObserver(ImageResourceObserver* observer) 124 void ImageResource::addObserver(ImageResourceObserver* observer)
125 { 125 {
126 willAddClientOrObserver(); 126 willAddClientOrObserver();
127 127
128 m_observers.add(observer); 128 m_observers.add(observer);
129 129
130 if (isCacheValidator()) 130 if (isCacheValidator())
131 return; 131 return;
132 132
133 DCHECK(!m_data || m_image); 133 // When the response is not multipart, if |m_data| exists, |m_image| must
134 // be created. This is assured that |updateImage()| is called when
135 // |appendData()| is called.
136 //
137 // On the other hand, when the response is multipart, |updateImage()| is
138 // not called in |appendData()|, which means |m_image| might not be created
139 // even when |m_data| exists. This is intentional since creating a |m_image|
140 // on receiving data might destroy an existing image in a previous part.
141 DCHECK((m_multipartParser && isLoading()) || !m_data || m_image);
134 142
135 if (m_image && !m_image->isNull()) { 143 if (m_image && !m_image->isNull()) {
136 observer->imageChanged(this); 144 observer->imageChanged(this);
137 } 145 }
138 146
139 if (isLoaded()) { 147 if (isLoaded()) {
140 observer->imageNotifyFinished(this); 148 observer->imageNotifyFinished(this);
141 if (m_observers.contains(observer)) { 149 if (m_observers.contains(observer)) {
142 m_finishedObservers.add(observer); 150 m_finishedObservers.add(observer);
143 m_observers.remove(observer); 151 m_observers.remove(observer);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 if (response().wasFetchedViaServiceWorker()) 593 if (response().wasFetchedViaServiceWorker())
586 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 594 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
587 if (!getImage()->currentFrameHasSingleSecurityOrigin()) 595 if (!getImage()->currentFrameHasSingleSecurityOrigin())
588 return false; 596 return false;
589 if (passesAccessControlCheck(securityOrigin)) 597 if (passesAccessControlCheck(securityOrigin))
590 return true; 598 return true;
591 return !securityOrigin->taintsCanvas(response().url()); 599 return !securityOrigin->taintsCanvas(response().url());
592 } 600 }
593 601
594 } // namespace blink 602 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698