| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 struct ThreadableLoaderOptions { | 61 struct ThreadableLoaderOptions { |
| 62 DISALLOW_NEW(); | 62 DISALLOW_NEW(); |
| 63 ThreadableLoaderOptions() | 63 ThreadableLoaderOptions() |
| 64 : preflightPolicy(ConsiderPreflight), | 64 : preflightPolicy(ConsiderPreflight), |
| 65 crossOriginRequestPolicy(DenyCrossOriginRequests), | 65 crossOriginRequestPolicy(DenyCrossOriginRequests), |
| 66 contentSecurityPolicyEnforcement(EnforceContentSecurityPolicy), | 66 contentSecurityPolicyEnforcement(EnforceContentSecurityPolicy), |
| 67 timeoutMilliseconds(0) {} | 67 timeoutMilliseconds(0) {} |
| 68 | 68 |
| 69 // When adding members, CrossThreadThreadableLoaderOptionsData should | 69 // When adding members, CrossThreadThreadableLoaderOptionsData should |
| 70 // be updated. | 70 // be updated. |
| 71 PreflightPolicy | 71 |
| 72 preflightPolicy; // If AccessControl is used, how to determine if a prefl
ight is needed. | 72 // If AccessControl is used, how to determine if a preflight is needed. |
| 73 PreflightPolicy preflightPolicy; |
| 74 |
| 73 CrossOriginRequestPolicy crossOriginRequestPolicy; | 75 CrossOriginRequestPolicy crossOriginRequestPolicy; |
| 74 AtomicString initiator; | 76 AtomicString initiator; |
| 75 ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement; | 77 ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement; |
| 76 unsigned long timeoutMilliseconds; | 78 unsigned long timeoutMilliseconds; |
| 77 }; | 79 }; |
| 78 | 80 |
| 79 // Encode AtomicString as String to cross threads. | 81 // Encode AtomicString as String to cross threads. |
| 80 struct CrossThreadThreadableLoaderOptionsData { | 82 struct CrossThreadThreadableLoaderOptionsData { |
| 81 STACK_ALLOCATED(); | 83 STACK_ALLOCATED(); |
| 82 explicit CrossThreadThreadableLoaderOptionsData( | 84 explicit CrossThreadThreadableLoaderOptionsData( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 }; | 108 }; |
| 107 | 109 |
| 108 template <> | 110 template <> |
| 109 struct CrossThreadCopier<ThreadableLoaderOptions> { | 111 struct CrossThreadCopier<ThreadableLoaderOptions> { |
| 110 typedef CrossThreadThreadableLoaderOptionsData Type; | 112 typedef CrossThreadThreadableLoaderOptionsData Type; |
| 111 static Type copy(const ThreadableLoaderOptions& options) { | 113 static Type copy(const ThreadableLoaderOptions& options) { |
| 112 return CrossThreadThreadableLoaderOptionsData(options); | 114 return CrossThreadThreadableLoaderOptionsData(options); |
| 113 } | 115 } |
| 114 }; | 116 }; |
| 115 | 117 |
| 116 // Useful for doing loader operations from any thread (not threadsafe, | 118 // Useful for doing loader operations from any thread (not threadsafe, just able |
| 117 // just able to run on threads other than the main thread). | 119 // to run on threads other than the main thread). |
| 118 // | 120 // |
| 119 // Arguments common to both loadResourceSynchronously() and create(): | 121 // Arguments common to both loadResourceSynchronously() and create(): |
| 120 // | 122 // |
| 121 // - ThreadableLoaderOptions argument configures this ThreadableLoader's | 123 // - ThreadableLoaderOptions argument configures this ThreadableLoader's |
| 122 // behavior. | 124 // behavior. |
| 123 // | 125 // |
| 124 // - ResourceLoaderOptions argument will be passed to the FetchRequest | 126 // - ResourceLoaderOptions argument will be passed to the FetchRequest |
| 125 // that this ThreadableLoader creates. It can be altered e.g. when | 127 // that this ThreadableLoader creates. It can be altered e.g. when |
| 126 // redirect happens. | 128 // redirect happens. |
| 127 class CORE_EXPORT ThreadableLoader | 129 class CORE_EXPORT ThreadableLoader |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // std::unique_ptr<ThreadableLoader>). | 175 // std::unique_ptr<ThreadableLoader>). |
| 174 static ThreadableLoader* create(ExecutionContext&, | 176 static ThreadableLoader* create(ExecutionContext&, |
| 175 ThreadableLoaderClient*, | 177 ThreadableLoaderClient*, |
| 176 const ThreadableLoaderOptions&, | 178 const ThreadableLoaderOptions&, |
| 177 const ResourceLoaderOptions&); | 179 const ResourceLoaderOptions&); |
| 178 | 180 |
| 179 // The methods on the ThreadableLoaderClient passed on create() call | 181 // The methods on the ThreadableLoaderClient passed on create() call |
| 180 // may be called synchronous to start() call. | 182 // may be called synchronous to start() call. |
| 181 virtual void start(const ResourceRequest&) = 0; | 183 virtual void start(const ResourceRequest&) = 0; |
| 182 | 184 |
| 183 // A ThreadableLoader may have a timeout specified. It is possible, in some ca
ses, for | 185 // A ThreadableLoader may have a timeout specified. It is possible, in some |
| 184 // the timeout to be overridden after the request is sent (for example, XMLHtt
pRequests | 186 // cases, for the timeout to be overridden after the request is sent (for |
| 185 // may override their timeout setting after sending). | 187 // example, XMLHttpRequests may override their timeout setting after sending). |
| 186 // | 188 // |
| 187 // Set a new timeout relative to the time the request started, in milliseconds
. | 189 // Set a new timeout relative to the time the request started, in |
| 190 // milliseconds. |
| 188 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; | 191 virtual void overrideTimeout(unsigned long timeoutMilliseconds) = 0; |
| 189 | 192 |
| 190 virtual void cancel() = 0; | 193 virtual void cancel() = 0; |
| 191 | 194 |
| 192 virtual ~ThreadableLoader() {} | 195 virtual ~ThreadableLoader() {} |
| 193 | 196 |
| 194 DEFINE_INLINE_VIRTUAL_TRACE() {} | 197 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 195 | 198 |
| 196 protected: | 199 protected: |
| 197 ThreadableLoader() {} | 200 ThreadableLoader() {} |
| 198 }; | 201 }; |
| 199 | 202 |
| 200 } // namespace blink | 203 } // namespace blink |
| 201 | 204 |
| 202 #endif // ThreadableLoader_h | 205 #endif // ThreadableLoader_h |
| OLD | NEW |