| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/serviceworkers/GlobalCacheStorage.h" | 6 #include "modules/serviceworkers/GlobalCacheStorage.h" |
| 7 | 7 |
| 8 #include "core/frame/LocalDOMWindow.h" | 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "core/frame/UseCounter.h" | 9 #include "core/frame/UseCounter.h" |
| 10 #include "core/workers/WorkerGlobalScope.h" | 10 #include "core/workers/WorkerGlobalScope.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 static GlobalCacheStorageImpl& from(T& supplementable, ExecutionContext* exe
cutionContext) | 25 static GlobalCacheStorageImpl& from(T& supplementable, ExecutionContext* exe
cutionContext) |
| 26 { | 26 { |
| 27 GlobalCacheStorageImpl* supplement = static_cast<GlobalCacheStorageImpl*
>(WillBeHeapSupplement<T>::from(supplementable, name())); | 27 GlobalCacheStorageImpl* supplement = static_cast<GlobalCacheStorageImpl*
>(WillBeHeapSupplement<T>::from(supplementable, name())); |
| 28 if (!supplement) { | 28 if (!supplement) { |
| 29 supplement = new GlobalCacheStorageImpl(); | 29 supplement = new GlobalCacheStorageImpl(); |
| 30 WillBeHeapSupplement<T>::provideTo(supplementable, name(), adoptPtrW
illBeNoop(supplement)); | 30 WillBeHeapSupplement<T>::provideTo(supplementable, name(), adoptPtrW
illBeNoop(supplement)); |
| 31 } | 31 } |
| 32 return *supplement; | 32 return *supplement; |
| 33 } | 33 } |
| 34 | 34 |
| 35 CacheStorage* caches(ScriptState* scriptState, ExceptionState& exceptionStat
e) | 35 CacheStorage* caches(ExecutionContext* context, ExceptionState& exceptionSta
te) |
| 36 { | 36 { |
| 37 ExecutionContext* context = scriptState->executionContext(); | |
| 38 if (!context->securityOrigin()->canAccessCacheStorage()) { | 37 if (!context->securityOrigin()->canAccessCacheStorage()) { |
| 39 if (context->securityContext().isSandboxed(SandboxOrigin)) | 38 if (context->securityContext().isSandboxed(SandboxOrigin)) |
| 40 exceptionState.throwSecurityError("Cache storage is disabled bec
ause the context is sandboxed and lacks the 'allow-same-origin' flag."); | 39 exceptionState.throwSecurityError("Cache storage is disabled bec
ause the context is sandboxed and lacks the 'allow-same-origin' flag."); |
| 41 else if (context->url().protocolIs("data")) | 40 else if (context->url().protocolIs("data")) |
| 42 exceptionState.throwSecurityError("Cache storage is disabled ins
ide 'data:' URLs."); | 41 exceptionState.throwSecurityError("Cache storage is disabled ins
ide 'data:' URLs."); |
| 43 else | 42 else |
| 44 exceptionState.throwSecurityError("Access to cache storage is de
nied."); | 43 exceptionState.throwSecurityError("Access to cache storage is de
nied."); |
| 45 return nullptr; | 44 return nullptr; |
| 46 } | 45 } |
| 47 | 46 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 64 { | 63 { |
| 65 } | 64 } |
| 66 | 65 |
| 67 static const char* name() { return "CacheStorage"; } | 66 static const char* name() { return "CacheStorage"; } |
| 68 | 67 |
| 69 PersistentWillBeMember<CacheStorage> m_caches; | 68 PersistentWillBeMember<CacheStorage> m_caches; |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 } // namespace | 71 } // namespace |
| 73 | 72 |
| 74 CacheStorage* GlobalCacheStorage::caches(ScriptState* scriptState, DOMWindow& wi
ndow, ExceptionState& exceptionState) | 73 CacheStorage* GlobalCacheStorage::caches(DOMWindow& window, ExceptionState& exce
ptionState) |
| 75 { | 74 { |
| 76 return GlobalCacheStorageImpl<LocalDOMWindow>::from(toLocalDOMWindow(window)
, window.executionContext()).caches(scriptState, exceptionState); | 75 return GlobalCacheStorageImpl<LocalDOMWindow>::from(toLocalDOMWindow(window)
, window.executionContext()).caches(window.executionContext(), exceptionState); |
| 77 } | 76 } |
| 78 | 77 |
| 79 CacheStorage* GlobalCacheStorage::caches(ScriptState* scriptState, WorkerGlobalS
cope& worker, ExceptionState& exceptionState) | 78 CacheStorage* GlobalCacheStorage::caches(WorkerGlobalScope& worker, ExceptionSta
te& exceptionState) |
| 80 { | 79 { |
| 81 return GlobalCacheStorageImpl<WorkerGlobalScope>::from(worker, worker.execut
ionContext()).caches(scriptState, exceptionState); | 80 return GlobalCacheStorageImpl<WorkerGlobalScope>::from(worker, worker.execut
ionContext()).caches(worker.executionContext(), exceptionState); |
| 82 } | 81 } |
| 83 | 82 |
| 84 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |