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

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

Issue 2920663002: Class/struct layout optimization for blink Resource related classes (Closed)
Patch Set: Created 3 years, 6 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
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 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 rights reserved. 6 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // with the loader to obtain the resource from the network. 62 // with the loader to obtain the resource from the network.
63 class PLATFORM_EXPORT Resource : public GarbageCollectedFinalized<Resource>, 63 class PLATFORM_EXPORT Resource : public GarbageCollectedFinalized<Resource>,
64 public MemoryCoordinatorClient { 64 public MemoryCoordinatorClient {
65 USING_GARBAGE_COLLECTED_MIXIN(Resource); 65 USING_GARBAGE_COLLECTED_MIXIN(Resource);
66 WTF_MAKE_NONCOPYABLE(Resource); 66 WTF_MAKE_NONCOPYABLE(Resource);
67 67
68 public: 68 public:
69 // |Type| enum values are used in UMAs, so do not change the values of 69 // |Type| enum values are used in UMAs, so do not change the values of
70 // existing |Type|. When adding a new |Type|, append it at the end and update 70 // existing |Type|. When adding a new |Type|, append it at the end and update
71 // |kLastResourceType|. 71 // |kLastResourceType|.
72 enum Type { 72 enum Type : uint8_t {
73 kMainResource, 73 kMainResource,
74 kImage, 74 kImage,
75 kCSSStyleSheet, 75 kCSSStyleSheet,
76 kScript, 76 kScript,
77 kFont, 77 kFont,
78 kRaw, 78 kRaw,
79 kSVGDocument, 79 kSVGDocument,
80 kXSLStyleSheet, 80 kXSLStyleSheet,
81 kLinkPrefetch, 81 kLinkPrefetch,
82 kTextTrack, 82 kTextTrack,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 virtual ResourcePriority PriorityFromObservers() { 150 virtual ResourcePriority PriorityFromObservers() {
151 return ResourcePriority(); 151 return ResourcePriority();
152 } 152 }
153 153
154 // The reference policy indicates that the client should not affect whether 154 // The reference policy indicates that the client should not affect whether
155 // a preload is considered referenced or not. This allows for "passive" 155 // a preload is considered referenced or not. This allows for "passive"
156 // resource clients that simply observe the resource. 156 // resource clients that simply observe the resource.
157 void AddClient(ResourceClient*, PreloadReferencePolicy = kMarkAsReferenced); 157 void AddClient(ResourceClient*, PreloadReferencePolicy = kMarkAsReferenced);
158 void RemoveClient(ResourceClient*); 158 void RemoveClient(ResourceClient*);
159 159
160 enum PreloadResult { 160 enum PreloadResult : uint8_t {
161 kPreloadNotReferenced, 161 kPreloadNotReferenced,
162 kPreloadReferenced, 162 kPreloadReferenced,
163 kPreloadReferencedWhileLoading, 163 kPreloadReferencedWhileLoading,
164 kPreloadReferencedWhileComplete 164 kPreloadReferencedWhileComplete
165 }; 165 };
166 PreloadResult GetPreloadResult() const { return preload_result_; } 166 PreloadResult GetPreloadResult() const { return preload_result_; }
167 167
168 ResourceStatus GetStatus() const { return status_; } 168 ResourceStatus GetStatus() const { return status_; }
169 void SetStatus(ResourceStatus status) { status_ = status; } 169 void SetStatus(ResourceStatus status) { status_ = status; }
170 170
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 void RevalidationSucceeded(const ResourceResponse&); 422 void RevalidationSucceeded(const ResourceResponse&);
423 void RevalidationFailed(); 423 void RevalidationFailed();
424 424
425 size_t CalculateOverheadSize() const; 425 size_t CalculateOverheadSize() const;
426 426
427 String ReasonNotDeletable() const; 427 String ReasonNotDeletable() const;
428 428
429 // MemoryCoordinatorClient overrides: 429 // MemoryCoordinatorClient overrides:
430 void OnPurgeMemory() override; 430 void OnPurgeMemory() override;
431 431
432 PreloadResult preload_result_;
433 Type type_;
434 ResourceStatus status_;
435
436 bool needs_synchronous_cache_hit_ : 1;
dcheng 2017/06/05 18:15:40 Is the bitfield packing necessary? We don't pack e
stanisc 2017/06/06 22:47:55 Not necessary in this particular case. I was debat
dcheng 2017/06/07 17:09:22 If I had written the CL, I probably wouldn't have
stanisc 2017/06/08 21:34:03 OK, I've removed bitfields because that has been s
437 bool link_preload_ : 1;
438 bool is_revalidating_ : 1;
439 bool is_alive_ : 1;
440
441 bool is_add_remove_client_prohibited_;
442 bool is_revalidation_start_forbidden_ = false;
443
444 ResourceIntegrityDisposition integrity_disposition_;
dcheng 2017/06/07 17:09:22 This IMO is the big disadvantage of reordering fie
stanisc 2017/06/08 21:34:03 OK, moved it back.
445
432 Member<CachedMetadataHandlerImpl> cache_handler_; 446 Member<CachedMetadataHandlerImpl> cache_handler_;
433 RefPtr<SecurityOrigin> fetcher_security_origin_; 447 RefPtr<SecurityOrigin> fetcher_security_origin_;
434 448
435 ResourceError error_; 449 ResourceError error_;
436 450
437 double load_finish_time_; 451 double load_finish_time_;
438 452
439 unsigned long identifier_; 453 unsigned long identifier_;
440 454
455 unsigned preload_count_;
456 double preload_discovery_time_;
457
441 size_t encoded_size_; 458 size_t encoded_size_;
442 size_t encoded_size_memory_usage_; 459 size_t encoded_size_memory_usage_;
443 size_t decoded_size_; 460 size_t decoded_size_;
444 461
445 // Resource::calculateOverheadSize() is affected by changes in 462 // Resource::calculateOverheadSize() is affected by changes in
446 // |m_resourceRequest.url()|, but |m_overheadSize| is not updated after 463 // |m_resourceRequest.url()|, but |m_overheadSize| is not updated after
447 // initial |m_resourceRequest| is given, to reduce MemoryCache manipulation 464 // initial |m_resourceRequest| is given, to reduce MemoryCache manipulation
448 // and thus potential bugs. crbug.com/594644 465 // and thus potential bugs. crbug.com/594644
449 const size_t overhead_size_; 466 const size_t overhead_size_;
450 467
451 unsigned preload_count_;
452
453 double preload_discovery_time_;
454
455 String cache_identifier_; 468 String cache_identifier_;
456 469
457 PreloadResult preload_result_;
458 Type type_;
459 ResourceStatus status_;
460
461 bool needs_synchronous_cache_hit_;
462 bool link_preload_;
463 bool is_revalidating_;
464 bool is_alive_;
465 bool is_add_remove_client_prohibited_;
466 bool is_revalidation_start_forbidden_ = false;
467
468 ResourceIntegrityDisposition integrity_disposition_;
469 IntegrityMetadataSet integrity_metadata_; 470 IntegrityMetadataSet integrity_metadata_;
470 471
471 // Ordered list of all redirects followed while fetching this resource. 472 // Ordered list of all redirects followed while fetching this resource.
472 Vector<RedirectPair> redirect_chain_; 473 Vector<RedirectPair> redirect_chain_;
473 474
474 HeapHashCountedSet<WeakMember<ResourceClient>> clients_; 475 HeapHashCountedSet<WeakMember<ResourceClient>> clients_;
475 HeapHashCountedSet<WeakMember<ResourceClient>> clients_awaiting_callback_; 476 HeapHashCountedSet<WeakMember<ResourceClient>> clients_awaiting_callback_;
476 HeapHashCountedSet<WeakMember<ResourceClient>> finished_clients_; 477 HeapHashCountedSet<WeakMember<ResourceClient>> finished_clients_;
477 478
478 ResourceLoaderOptions options_; 479 ResourceLoaderOptions options_;
(...skipping 26 matching lines...) Expand all
505 }; 506 };
506 507
507 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 508 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
508 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ 509 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \
509 resource->GetType() == Resource::k##typeName, \ 510 resource->GetType() == Resource::k##typeName, \
510 resource.GetType() == Resource::k##typeName); 511 resource.GetType() == Resource::k##typeName);
511 512
512 } // namespace blink 513 } // namespace blink
513 514
514 #endif 515 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698