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

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: Rebase 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // with the loader to obtain the resource from the network. 63 // with the loader to obtain the resource from the network.
64 class PLATFORM_EXPORT Resource : public GarbageCollectedFinalized<Resource>, 64 class PLATFORM_EXPORT Resource : public GarbageCollectedFinalized<Resource>,
65 public MemoryCoordinatorClient { 65 public MemoryCoordinatorClient {
66 USING_GARBAGE_COLLECTED_MIXIN(Resource); 66 USING_GARBAGE_COLLECTED_MIXIN(Resource);
67 WTF_MAKE_NONCOPYABLE(Resource); 67 WTF_MAKE_NONCOPYABLE(Resource);
68 68
69 public: 69 public:
70 // |Type| enum values are used in UMAs, so do not change the values of 70 // |Type| enum values are used in UMAs, so do not change the values of
71 // existing |Type|. When adding a new |Type|, append it at the end and update 71 // existing |Type|. When adding a new |Type|, append it at the end and update
72 // |kLastResourceType|. 72 // |kLastResourceType|.
73 enum Type { 73 enum Type : uint8_t {
74 kMainResource, 74 kMainResource,
75 kImage, 75 kImage,
76 kCSSStyleSheet, 76 kCSSStyleSheet,
77 kScript, 77 kScript,
78 kFont, 78 kFont,
79 kRaw, 79 kRaw,
80 kSVGDocument, 80 kSVGDocument,
81 kXSLStyleSheet, 81 kXSLStyleSheet,
82 kLinkPrefetch, 82 kLinkPrefetch,
83 kTextTrack, 83 kTextTrack,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // The reference policy indicates that the client should not affect whether 155 // The reference policy indicates that the client should not affect whether
156 // a preload is considered referenced or not. This allows for "passive" 156 // a preload is considered referenced or not. This allows for "passive"
157 // resource clients that simply observe the resource. 157 // resource clients that simply observe the resource.
158 void AddClient(ResourceClient*, PreloadReferencePolicy = kMarkAsReferenced); 158 void AddClient(ResourceClient*, PreloadReferencePolicy = kMarkAsReferenced);
159 void RemoveClient(ResourceClient*); 159 void RemoveClient(ResourceClient*);
160 160
161 void AddFinishObserver(ResourceFinishObserver*, 161 void AddFinishObserver(ResourceFinishObserver*,
162 PreloadReferencePolicy = kMarkAsReferenced); 162 PreloadReferencePolicy = kMarkAsReferenced);
163 void RemoveFinishObserver(ResourceFinishObserver*); 163 void RemoveFinishObserver(ResourceFinishObserver*);
164 164
165 enum PreloadResult { 165 enum PreloadResult : uint8_t {
166 kPreloadNotReferenced, 166 kPreloadNotReferenced,
167 kPreloadReferenced, 167 kPreloadReferenced,
168 kPreloadReferencedWhileLoading, 168 kPreloadReferencedWhileLoading,
169 kPreloadReferencedWhileComplete 169 kPreloadReferencedWhileComplete
170 }; 170 };
171 PreloadResult GetPreloadResult() const { return preload_result_; } 171 PreloadResult GetPreloadResult() const { return preload_result_; }
172 172
173 ResourceStatus GetStatus() const { return status_; } 173 ResourceStatus GetStatus() const { return status_; }
174 void SetStatus(ResourceStatus status) { status_ = status; } 174 void SetStatus(ResourceStatus status) { status_ = status; }
175 175
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 void RevalidationSucceeded(const ResourceResponse&); 429 void RevalidationSucceeded(const ResourceResponse&);
430 void RevalidationFailed(); 430 void RevalidationFailed();
431 431
432 size_t CalculateOverheadSize() const; 432 size_t CalculateOverheadSize() const;
433 433
434 String ReasonNotDeletable() const; 434 String ReasonNotDeletable() const;
435 435
436 // MemoryCoordinatorClient overrides: 436 // MemoryCoordinatorClient overrides:
437 void OnPurgeMemory() override; 437 void OnPurgeMemory() override;
438 438
439 PreloadResult preload_result_;
440 Type type_;
441 ResourceStatus status_;
442
439 Member<CachedMetadataHandlerImpl> cache_handler_; 443 Member<CachedMetadataHandlerImpl> cache_handler_;
440 RefPtr<SecurityOrigin> fetcher_security_origin_; 444 RefPtr<SecurityOrigin> fetcher_security_origin_;
441 445
442 ResourceError error_; 446 ResourceError error_;
443 447
444 double load_finish_time_; 448 double load_finish_time_;
445 449
446 unsigned long identifier_; 450 unsigned long identifier_;
447 451
452 unsigned preload_count_;
453 double preload_discovery_time_;
454
448 size_t encoded_size_; 455 size_t encoded_size_;
449 size_t encoded_size_memory_usage_; 456 size_t encoded_size_memory_usage_;
450 size_t decoded_size_; 457 size_t decoded_size_;
451 458
452 // Resource::calculateOverheadSize() is affected by changes in 459 // Resource::calculateOverheadSize() is affected by changes in
453 // |m_resourceRequest.url()|, but |m_overheadSize| is not updated after 460 // |m_resourceRequest.url()|, but |m_overheadSize| is not updated after
454 // initial |m_resourceRequest| is given, to reduce MemoryCache manipulation 461 // initial |m_resourceRequest| is given, to reduce MemoryCache manipulation
455 // and thus potential bugs. crbug.com/594644 462 // and thus potential bugs. crbug.com/594644
456 const size_t overhead_size_; 463 const size_t overhead_size_;
457 464
458 unsigned preload_count_;
459
460 double preload_discovery_time_;
461
462 String cache_identifier_; 465 String cache_identifier_;
463 466
464 PreloadResult preload_result_;
465 Type type_;
466 ResourceStatus status_;
467
468 bool needs_synchronous_cache_hit_; 467 bool needs_synchronous_cache_hit_;
469 bool link_preload_; 468 bool link_preload_;
470 bool is_revalidating_; 469 bool is_revalidating_;
471 bool is_alive_; 470 bool is_alive_;
472 bool is_add_remove_client_prohibited_; 471 bool is_add_remove_client_prohibited_;
473 bool is_revalidation_start_forbidden_ = false; 472 bool is_revalidation_start_forbidden_ = false;
474 473
475 ResourceIntegrityDisposition integrity_disposition_; 474 ResourceIntegrityDisposition integrity_disposition_;
476 IntegrityMetadataSet integrity_metadata_; 475 IntegrityMetadataSet integrity_metadata_;
477 476
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 }; 512 };
514 513
515 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 514 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
516 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ 515 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \
517 resource->GetType() == Resource::k##typeName, \ 516 resource->GetType() == Resource::k##typeName, \
518 resource.GetType() == Resource::k##typeName); 517 resource.GetType() == Resource::k##typeName);
519 518
520 } // namespace blink 519 } // namespace blink
521 520
522 #endif 521 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698