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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceLoaderOptions.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 #define ResourceLoaderOptions_h 32 #define ResourceLoaderOptions_h
33 33
34 #include "platform/CrossThreadCopier.h" 34 #include "platform/CrossThreadCopier.h"
35 #include "platform/loader/fetch/FetchInitiatorInfo.h" 35 #include "platform/loader/fetch/FetchInitiatorInfo.h"
36 #include "platform/loader/fetch/IntegrityMetadata.h" 36 #include "platform/loader/fetch/IntegrityMetadata.h"
37 #include "platform/weborigin/SecurityOrigin.h" 37 #include "platform/weborigin/SecurityOrigin.h"
38 #include "platform/wtf/Allocator.h" 38 #include "platform/wtf/Allocator.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 enum DataBufferingPolicy { kBufferData, kDoNotBufferData }; 42 enum DataBufferingPolicy : uint8_t { kBufferData, kDoNotBufferData };
43 43
44 enum ContentSecurityPolicyDisposition { 44 enum ContentSecurityPolicyDisposition : uint8_t {
45 kCheckContentSecurityPolicy, 45 kCheckContentSecurityPolicy,
46 kDoNotCheckContentSecurityPolicy 46 kDoNotCheckContentSecurityPolicy
47 }; 47 };
48 48
49 enum RequestInitiatorContext { 49 enum RequestInitiatorContext : uint8_t {
50 kDocumentContext, 50 kDocumentContext,
51 kWorkerContext, 51 kWorkerContext,
52 }; 52 };
53 53
54 enum StoredCredentials { 54 enum StoredCredentials : uint8_t {
55 kAllowStoredCredentials, 55 kAllowStoredCredentials,
56 kDoNotAllowStoredCredentials 56 kDoNotAllowStoredCredentials
57 }; 57 };
58 58
59 // APIs like XMLHttpRequest and EventSource let the user decide whether to send 59 // APIs like XMLHttpRequest and EventSource let the user decide whether to send
60 // credentials, but they're always sent for same-origin requests. Additional 60 // credentials, but they're always sent for same-origin requests. Additional
61 // information is needed to handle cross-origin redirects correctly. 61 // information is needed to handle cross-origin redirects correctly.
62 enum CredentialRequest { 62 enum CredentialRequest : uint8_t {
63 kClientRequestedCredentials, 63 kClientRequestedCredentials,
64 kClientDidNotRequestCredentials 64 kClientDidNotRequestCredentials
65 }; 65 };
66 66
67 enum SynchronousPolicy { kRequestSynchronously, kRequestAsynchronously }; 67 enum SynchronousPolicy : uint8_t {
68 kRequestSynchronously,
69 kRequestAsynchronously
70 };
68 71
69 // A resource fetch can be marked as being CORS enabled. The loader must perform 72 // A resource fetch can be marked as being CORS enabled. The loader must perform
70 // an access check upon seeing the response. 73 // an access check upon seeing the response.
71 enum CORSEnabled { kNotCORSEnabled, kIsCORSEnabled }; 74 enum CORSEnabled : uint8_t { kNotCORSEnabled, kIsCORSEnabled };
72 75
73 // Was the request generated from a "parser-inserted" element? 76 // Was the request generated from a "parser-inserted" element?
74 // https://html.spec.whatwg.org/multipage/scripting.html#parser-inserted 77 // https://html.spec.whatwg.org/multipage/scripting.html#parser-inserted
75 enum ParserDisposition { kParserInserted, kNotParserInserted }; 78 enum ParserDisposition : uint8_t { kParserInserted, kNotParserInserted };
76 79
77 enum CacheAwareLoadingEnabled { 80 enum CacheAwareLoadingEnabled : uint8_t {
78 kNotCacheAwareLoadingEnabled, 81 kNotCacheAwareLoadingEnabled,
79 kIsCacheAwareLoadingEnabled 82 kIsCacheAwareLoadingEnabled
80 }; 83 };
81 84
82 struct ResourceLoaderOptions { 85 struct ResourceLoaderOptions {
83 USING_FAST_MALLOC(ResourceLoaderOptions); 86 USING_FAST_MALLOC(ResourceLoaderOptions);
84 87
85 public: 88 public:
86 ResourceLoaderOptions(StoredCredentials allow_credentials, 89 ResourceLoaderOptions(StoredCredentials allow_credentials,
87 CredentialRequest credentials_requested) 90 CredentialRequest credentials_requested)
(...skipping 17 matching lines...) Expand all
105 // FIXME: check contentSecurityPolicyOption. 108 // FIXME: check contentSecurityPolicyOption.
106 // initiatorInfo is purely informational and should be benign for re-use. 109 // initiatorInfo is purely informational and should be benign for re-use.
107 // requestInitiatorContext is benign (indicates document vs. worker) 110 // requestInitiatorContext is benign (indicates document vs. worker)
108 if (synchronous_policy != other.synchronous_policy) 111 if (synchronous_policy != other.synchronous_policy)
109 return false; 112 return false;
110 return cors_enabled == other.cors_enabled; 113 return cors_enabled == other.cors_enabled;
111 // securityOrigin has more complicated checks which callers are responsible 114 // securityOrigin has more complicated checks which callers are responsible
112 // for. 115 // for.
113 } 116 }
114 117
118 FetchInitiatorInfo initiator_info;
119
115 // When adding members, CrossThreadResourceLoaderOptionsData should be 120 // When adding members, CrossThreadResourceLoaderOptionsData should be
116 // updated. 121 // updated.
117 DataBufferingPolicy data_buffering_policy; 122 DataBufferingPolicy data_buffering_policy;
118 123
119 // Whether HTTP credentials and cookies are sent with the request. 124 // Whether HTTP credentials and cookies are sent with the request.
120 StoredCredentials allow_credentials; 125 StoredCredentials allow_credentials;
121 126
122 // Whether the client (e.g. XHR) wanted credentials in the first place. 127 // Whether the client (e.g. XHR) wanted credentials in the first place.
123 CredentialRequest credentials_requested; 128 CredentialRequest credentials_requested;
124 129
125 ContentSecurityPolicyDisposition content_security_policy_option; 130 ContentSecurityPolicyDisposition content_security_policy_option;
126 FetchInitiatorInfo initiator_info;
127 RequestInitiatorContext request_initiator_context; 131 RequestInitiatorContext request_initiator_context;
128 SynchronousPolicy synchronous_policy; 132 SynchronousPolicy synchronous_policy;
129 133
130 // If the resource is loaded out-of-origin, whether or not to use CORS. 134 // If the resource is loaded out-of-origin, whether or not to use CORS.
131 CORSEnabled cors_enabled; 135 CORSEnabled cors_enabled;
132 136
133 RefPtr<SecurityOrigin> security_origin; 137 RefPtr<SecurityOrigin> security_origin;
134 String content_security_policy_nonce; 138 String content_security_policy_nonce;
135 IntegrityMetadataSet integrity_metadata; 139 IntegrityMetadataSet integrity_metadata;
136 ParserDisposition parser_disposition; 140 ParserDisposition parser_disposition;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 struct CrossThreadCopier<ResourceLoaderOptions> { 197 struct CrossThreadCopier<ResourceLoaderOptions> {
194 using Type = CrossThreadResourceLoaderOptionsData; 198 using Type = CrossThreadResourceLoaderOptionsData;
195 static Type Copy(const ResourceLoaderOptions& options) { 199 static Type Copy(const ResourceLoaderOptions& options) {
196 return CrossThreadResourceLoaderOptionsData(options); 200 return CrossThreadResourceLoaderOptionsData(options);
197 } 201 }
198 }; 202 };
199 203
200 } // namespace blink 204 } // namespace blink
201 205
202 #endif // ResourceLoaderOptions_h 206 #endif // ResourceLoaderOptions_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698