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

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

Issue 210293005: Resource: Add more crash preventing assertions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/fetch/Resource.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) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 16 matching lines...) Expand all
27 #include "platform/Timer.h" 27 #include "platform/Timer.h"
28 #include "platform/network/ResourceError.h" 28 #include "platform/network/ResourceError.h"
29 #include "platform/network/ResourceLoadPriority.h" 29 #include "platform/network/ResourceLoadPriority.h"
30 #include "platform/network/ResourceRequest.h" 30 #include "platform/network/ResourceRequest.h"
31 #include "platform/network/ResourceResponse.h" 31 #include "platform/network/ResourceResponse.h"
32 #include "wtf/HashCountedSet.h" 32 #include "wtf/HashCountedSet.h"
33 #include "wtf/HashSet.h" 33 #include "wtf/HashSet.h"
34 #include "wtf/OwnPtr.h" 34 #include "wtf/OwnPtr.h"
35 #include "wtf/text/WTFString.h" 35 #include "wtf/text/WTFString.h"
36 36
37 // FIXME(crbug.com/352043): This is temporarily enabled even on RELEASE to diagn ose a wild crash.
38 #define ENABLE_RESOURCE_IS_DELETED_CHECK
39
37 namespace WebCore { 40 namespace WebCore {
38 41
39 struct FetchInitiatorInfo; 42 struct FetchInitiatorInfo;
40 class MemoryCache; 43 class MemoryCache;
41 class CachedMetadata; 44 class CachedMetadata;
42 class ResourceClient; 45 class ResourceClient;
43 class ResourcePtrBase; 46 class ResourcePtrBase;
44 class ResourceFetcher; 47 class ResourceFetcher;
45 class InspectorResource; 48 class InspectorResource;
46 class ResourceLoader; 49 class ResourceLoader;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 235
233 double loadFinishTime() const { return m_loadFinishTime; } 236 double loadFinishTime() const { return m_loadFinishTime; }
234 237
235 virtual bool canReuse(const ResourceRequest&) const { return true; } 238 virtual bool canReuse(const ResourceRequest&) const { return true; }
236 239
237 // Used by the MemoryCache to reduce the memory consumption of the entry. 240 // Used by the MemoryCache to reduce the memory consumption of the entry.
238 void prune(); 241 void prune();
239 242
240 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); 243 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&);
241 244
245 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK
246 void assertAlive() const { RELEASE_ASSERT(!m_deleted); }
247 #else
248 void assertAlive() const { }
249 #endif
250
242 protected: 251 protected:
243 virtual void checkNotify(); 252 virtual void checkNotify();
244 virtual void finishOnePart(); 253 virtual void finishOnePart();
245 254
246 // Normal resource pointers will silently switch what Resource* they referen ce when we 255 // Normal resource pointers will silently switch what Resource* they referen ce when we
247 // successfully revalidated the resource. We need a way to guarantee that th e Resource 256 // successfully revalidated the resource. We need a way to guarantee that th e Resource
248 // that received the 304 response survives long enough to switch everything over to the 257 // that received the 304 response survives long enough to switch everything over to the
249 // revalidatedresource. The normal mechanisms for keeping a Resource alive e xternally 258 // revalidatedresource. The normal mechanisms for keeping a Resource alive e xternally
250 // (ResourcePtrs and ResourceClients registering themselves) don't work in t his case, so 259 // (ResourcePtrs and ResourceClients registering themselves) don't work in t his case, so
251 // have a separate internal protector). 260 // have a separate internal protector).
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 369
361 unsigned m_switchingClientsToRevalidatedResource : 1; 370 unsigned m_switchingClientsToRevalidatedResource : 1;
362 371
363 unsigned m_type : 4; // Type 372 unsigned m_type : 4; // Type
364 unsigned m_status : 3; // Status 373 unsigned m_status : 3; // Status
365 374
366 unsigned m_wasPurged : 1; 375 unsigned m_wasPurged : 1;
367 376
368 unsigned m_needsSynchronousCacheHit : 1; 377 unsigned m_needsSynchronousCacheHit : 1;
369 378
370 #ifndef NDEBUG 379 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK
371 bool m_deleted; 380 bool m_deleted;
372 #endif 381 #endif
373 382
374 // If this field is non-null we are using the resource as a proxy for checki ng whether an existing resource is still up to date 383 // If this field is non-null we are using the resource as a proxy for checki ng whether an existing resource is still up to date
375 // using HTTP If-Modified-Since/If-None-Match headers. If the response is 30 4 all clients of this resource are moved 384 // using HTTP If-Modified-Since/If-None-Match headers. If the response is 30 4 all clients of this resource are moved
376 // to to be clients of m_resourceToRevalidate and the resource is deleted. I f not, the field is zeroed and this 385 // to to be clients of m_resourceToRevalidate and the resource is deleted. I f not, the field is zeroed and this
377 // resources becomes normal resource load. 386 // resources becomes normal resource load.
378 Resource* m_resourceToRevalidate; 387 Resource* m_resourceToRevalidate;
379 388
380 // If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate). 389 // If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate).
(...skipping 11 matching lines...) Expand all
392 const char* ResourceTypeName(Resource::Type); 401 const char* ResourceTypeName(Resource::Type);
393 #endif 402 #endif
394 403
395 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 404 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
396 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \ 405 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \
397 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource >& ptr) { return to##typeName##Resource(ptr.get()); } 406 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource >& ptr) { return to##typeName##Resource(ptr.get()); }
398 407
399 } 408 }
400 409
401 #endif 410 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698