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

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

Issue 1434903002: InternalResourcePtr: allowed only as stack allocated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | 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) 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 276
277 virtual void destroyDecodedDataForFailedRevalidation() { } 277 virtual void destroyDecodedDataForFailedRevalidation() { }
278 278
279 // Normal resource pointers will silently switch what Resource* they referen ce when we 279 // Normal resource pointers will silently switch what Resource* they referen ce when we
280 // successfully revalidated the resource. We need a way to guarantee that th e Resource 280 // successfully revalidated the resource. We need a way to guarantee that th e Resource
281 // that received the 304 response survives long enough to switch everything over to the 281 // that received the 304 response survives long enough to switch everything over to the
282 // revalidatedresource. The normal mechanisms for keeping a Resource alive e xternally 282 // revalidatedresource. The normal mechanisms for keeping a Resource alive e xternally
283 // (ResourcePtrs and ResourceClients registering themselves) don't work in t his case, so 283 // (ResourcePtrs and ResourceClients registering themselves) don't work in t his case, so
284 // have a separate internal protector). 284 // have a separate internal protector).
285 class InternalResourcePtr { 285 class InternalResourcePtr {
286 STACK_ALLOCATED();
286 public: 287 public:
287 explicit InternalResourcePtr(Resource* resource) 288 explicit InternalResourcePtr(Resource* resource)
288 : m_resource(resource) 289 : m_resource(resource)
289 { 290 {
290 m_resource->incrementProtectorCount(); 291 m_resource->incrementProtectorCount();
291 } 292 }
292 293
293 ~InternalResourcePtr() 294 ~InternalResourcePtr()
294 { 295 {
295 m_resource->decrementProtectorCount(); 296 m_resource->decrementProtectorCount();
296 m_resource->deleteIfPossible(); 297 m_resource->deleteIfPossible();
297 } 298 }
298 private: 299 private:
299 Resource* m_resource; 300 RawPtrWillBeMember<Resource> m_resource;
300 }; 301 };
301 302
302 void incrementProtectorCount() { m_protectorCount++; } 303 void incrementProtectorCount() { m_protectorCount++; }
303 void decrementProtectorCount() { m_protectorCount--; } 304 void decrementProtectorCount() { m_protectorCount--; }
304 305
305 void setEncodedSize(size_t); 306 void setEncodedSize(size_t);
306 void setDecodedSize(size_t); 307 void setDecodedSize(size_t);
307 void didAccessDecodedData(); 308 void didAccessDecodedData();
308 309
309 void finishPendingClients(); 310 void finishPendingClients();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 const char* ResourceTypeName(Resource::Type); 436 const char* ResourceTypeName(Resource::Type);
436 #endif 437 #endif
437 438
438 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 439 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
439 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \ 440 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->type() = = Resource::typeName, resource.type() == Resource::typeName); \
440 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource >& ptr) { return to##typeName##Resource(ptr.get()); } 441 inline typeName##Resource* to##typeName##Resource(const ResourcePtr<Resource >& ptr) { return to##typeName##Resource(ptr.get()); }
441 442
442 } 443 }
443 444
444 #endif 445 #endif
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