Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 810cc76

Browse files
ASSERTION FAILED: m_origin || m_type == CachedResource::MainResource
https://bugs.webkit.org/show_bug.cgi?id=162472 <rdar://problem/28431522> Patch by Youenn Fablet <[email protected]> on 2016-09-26 Reviewed by Darin Adler. No change of behavior. Introducing a new CachedResource constructor for already loaded resources. Sharing code with the other constructor in the init method. The main difference with this new constructor is that the resource has no specified origin. The response tainting remains Basic. Making some additional code clean-up. * loader/cache/CachedImage.cpp: (WebCore::CachedImage::CachedImage): Making use of the new constructor. * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): (WebCore::CachedResource::finishRequestInitialization): * loader/cache/CachedResource.h: (WebCore::CachedResource::type): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@206370 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent d35025f commit 810cc76

File tree

4 files changed

+74
-51
lines changed

4 files changed

+74
-51
lines changed

Source/WebCore/ChangeLog

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
2016-09-26 Youenn Fablet <[email protected]>
2+
3+
ASSERTION FAILED: m_origin || m_type == CachedResource::MainResource
4+
https://bugs.webkit.org/show_bug.cgi?id=162472
5+
<rdar://problem/28431522>
6+
7+
Reviewed by Darin Adler.
8+
9+
No change of behavior.
10+
11+
Introducing a new CachedResource constructor for already loaded resources.
12+
Sharing code with the other constructor in the init method.
13+
The main difference with this new constructor is that the resource has no specified origin.
14+
The response tainting remains Basic.
15+
16+
Making some additional code clean-up.
17+
18+
* loader/cache/CachedImage.cpp:
19+
(WebCore::CachedImage::CachedImage): Making use of the new constructor.
20+
* loader/cache/CachedResource.cpp:
21+
(WebCore::CachedResource::CachedResource):
22+
(WebCore::CachedResource::finishRequestInitialization):
23+
* loader/cache/CachedResource.h:
24+
(WebCore::CachedResource::type):
25+
126
2016-09-26 Olivier Blin <[email protected]>
227

328
[GStreamer] Support flipY for GPU-to-GPU copy of video textures to WebGL

Source/WebCore/loader/cache/CachedImage.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,19 @@ CachedImage::CachedImage(CachedResourceRequest&& request, SessionID sessionID)
6666
}
6767

6868
CachedImage::CachedImage(Image* image, SessionID sessionID)
69-
: CachedResource(CachedResourceRequest(ResourceRequest()), ImageResource, sessionID)
69+
: CachedResource(URL(), ImageResource, sessionID)
7070
, m_image(image)
7171
, m_isManuallyCached(false)
7272
, m_shouldPaintBrokenImage(true)
7373
{
74-
setStatus(Cached);
75-
setLoading(false);
7674
}
7775

7876
CachedImage::CachedImage(const URL& url, Image* image, SessionID sessionID)
79-
: CachedResource(CachedResourceRequest(ResourceRequest(url)), ImageResource, sessionID)
77+
: CachedResource(url, ImageResource, sessionID)
8078
, m_image(image)
8179
, m_isManuallyCached(false)
8280
, m_shouldPaintBrokenImage(true)
8381
{
84-
setStatus(Cached);
85-
setLoading(false);
8682
}
8783

8884
CachedImage::CachedImage(const URL& url, Image* image, CachedImage::CacheBehaviorType type, SessionID sessionID)

Source/WebCore/loader/cache/CachedResource.cpp

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,40 +122,37 @@ CachedResource::CachedResource(CachedResourceRequest&& request, Type type, Sessi
122122
, m_loadPriority(defaultPriorityForResourceType(type))
123123
, m_responseTimestamp(std::chrono::system_clock::now())
124124
, m_origin(request.releaseOrigin())
125-
, m_lastDecodedAccessTime(0)
126-
, m_loadFinishTime(0)
127-
, m_encodedSize(0)
128-
, m_decodedSize(0)
129-
, m_accessCount(0)
130-
, m_handleCount(0)
131-
, m_preloadCount(0)
132-
, m_preloadResult(PreloadNotReferenced)
133-
, m_requestedFromNetworkingLayer(false)
134-
, m_inCache(false)
135-
, m_loading(false)
136-
, m_switchingClientsToRevalidatedResource(false)
137125
, m_type(type)
138-
, m_status(Pending)
139-
#ifndef NDEBUG
140-
, m_deleted(false)
141-
, m_lruIndex(0)
142-
#endif
143-
, m_owningCachedResourceLoader(nullptr)
144-
, m_resourceToRevalidate(nullptr)
145-
, m_proxyResource(nullptr)
146126
{
147-
ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests careless updates of the enum.
148127
ASSERT(sessionID.isValid());
149-
#ifndef NDEBUG
150-
cachedResourceLeakCounter.increment();
151-
#endif
128+
finishRequestInitialization();
129+
152130
// FIXME: We should have a better way of checking for Navigation loads, maybe FetchMode::Options::Navigate.
153131
ASSERT(m_origin || m_type == CachedResource::MainResource);
154132

155133
if (m_options.mode != FetchOptions::Mode::SameOrigin && m_origin
156134
&& !(m_resourceRequest.url().protocolIsData() && m_options.sameOriginDataURLFlag == SameOriginDataURLFlag::Set)
157135
&& !m_origin->canRequest(m_resourceRequest.url()))
158136
setCrossOrigin();
137+
}
138+
139+
CachedResource::CachedResource(const URL& url, Type type, SessionID sessionID)
140+
: m_resourceRequest(url)
141+
, m_decodedDataDeletionTimer(*this, &CachedResource::destroyDecodedData, deadDecodedDataDeletionIntervalForResourceType(type))
142+
, m_sessionID(sessionID)
143+
, m_responseTimestamp(std::chrono::system_clock::now())
144+
, m_type(type)
145+
, m_status(Cached)
146+
{
147+
ASSERT(sessionID.isValid());
148+
finishRequestInitialization();
149+
}
150+
151+
void CachedResource::finishRequestInitialization()
152+
{
153+
#ifndef NDEBUG
154+
cachedResourceLeakCounter.increment();
155+
#endif
159156

160157
if (!m_resourceRequest.url().hasFragmentIdentifier())
161158
return;

Source/WebCore/loader/cache/CachedResource.h

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ class CachedResource {
119119
const String& cachePartition() const { return m_resourceRequest.cachePartition(); }
120120
#endif
121121
SessionID sessionID() const { return m_sessionID; }
122-
Type type() const { return static_cast<Type>(m_type); }
123-
122+
Type type() const { return m_type; }
123+
124124
ResourceLoadPriority loadPriority() const { return m_loadPriority; }
125125
void setLoadPriority(const Optional<ResourceLoadPriority>&);
126126

@@ -278,6 +278,9 @@ class CachedResource {
278278
static ResourceLoadPriority defaultPriorityForResourceType(Type);
279279

280280
protected:
281+
// CachedResource constructor that may be used when the CachedResource can already be filled with response data.
282+
CachedResource(const URL&, Type, SessionID);
283+
281284
void setEncodedSize(unsigned);
282285
void setDecodedSize(unsigned);
283286
void didAccessDecodedData(double timeStamp);
@@ -298,6 +301,8 @@ class CachedResource {
298301
private:
299302
class Callback;
300303

304+
void finishRequestInitialization();
305+
301306
bool addClientToSet(CachedResourceClient*);
302307

303308
void decodedDataDeletionTimerFired();
@@ -321,42 +326,42 @@ class CachedResource {
321326
ResourceError m_error;
322327
RefPtr<SecurityOrigin> m_origin;
323328

324-
double m_lastDecodedAccessTime; // Used as a "thrash guard" in the cache
325-
double m_loadFinishTime;
329+
double m_lastDecodedAccessTime { 0 }; // Used as a "thrash guard" in the cache
330+
double m_loadFinishTime { 0 };
326331

327-
unsigned m_encodedSize;
328-
unsigned m_decodedSize;
329-
unsigned m_accessCount;
330-
unsigned m_handleCount;
331-
unsigned m_preloadCount;
332+
unsigned m_encodedSize { 0 };
333+
unsigned m_decodedSize { 0 };
334+
unsigned m_accessCount { 0 };
335+
unsigned m_handleCount { 0 };
336+
unsigned m_preloadCount { 0 };
332337

333-
unsigned m_preloadResult : 2; // PreloadResult
338+
unsigned m_preloadResult { PreloadNotReferenced };
334339

335-
bool m_requestedFromNetworkingLayer : 1;
340+
bool m_requestedFromNetworkingLayer { false };
336341

337-
bool m_inCache : 1;
338-
bool m_loading : 1;
342+
bool m_inCache { false };
343+
bool m_loading { false };
339344

340-
bool m_switchingClientsToRevalidatedResource : 1;
345+
bool m_switchingClientsToRevalidatedResource { false };
341346

342-
unsigned m_type : 4; // Type
343-
unsigned m_status : 3; // Status
347+
Type m_type; // Type
348+
unsigned m_status { Pending }; // Status
344349

345350
#ifndef NDEBUG
346-
bool m_deleted;
347-
unsigned m_lruIndex;
351+
bool m_deleted { false };
352+
unsigned m_lruIndex { 0 };
348353
#endif
349354

350-
CachedResourceLoader* m_owningCachedResourceLoader; // only non-null for resources that are not in the cache
355+
CachedResourceLoader* m_owningCachedResourceLoader { nullptr }; // only non-null for resources that are not in the cache
351356

352357
// If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date
353358
// using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
354359
// to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this
355360
// resources becomes normal resource load.
356-
CachedResource* m_resourceToRevalidate;
361+
CachedResource* m_resourceToRevalidate { nullptr };
357362

358363
// If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate).
359-
CachedResource* m_proxyResource;
364+
CachedResource* m_proxyResource { nullptr };
360365

361366
// These handles will need to be updated to point to the m_resourceToRevalidate in case we get 304 response.
362367
HashSet<CachedResourceHandleBase*> m_handlesToRevalidate;

0 commit comments

Comments
 (0)