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

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/GlobalCacheStorage.cpp

Issue 1846913009: HeapSupplements are now just Supplements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 // 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 "modules/cachestorage/GlobalCacheStorage.h" 5 #include "modules/cachestorage/GlobalCacheStorage.h"
6 6
7 #include "core/dom/ExecutionContext.h" 7 #include "core/dom/ExecutionContext.h"
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"
11 #include "modules/cachestorage/CacheStorage.h" 11 #include "modules/cachestorage/CacheStorage.h"
12 #include "platform/Supplementable.h" 12 #include "platform/Supplementable.h"
13 #include "platform/heap/Handle.h" 13 #include "platform/heap/Handle.h"
14 #include "public/platform/Platform.h" 14 #include "public/platform/Platform.h"
15 #include "public/platform/WebSecurityOrigin.h" 15 #include "public/platform/WebSecurityOrigin.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 namespace { 19 namespace {
20 20
21 template <typename T> 21 template <typename T>
22 class GlobalCacheStorageImpl final : public GarbageCollectedFinalized<GlobalCach eStorageImpl<T>>, public HeapSupplement<T> { 22 class GlobalCacheStorageImpl final : public GarbageCollectedFinalized<GlobalCach eStorageImpl<T>>, public Supplement<T> {
23 USING_GARBAGE_COLLECTED_MIXIN(GlobalCacheStorageImpl); 23 USING_GARBAGE_COLLECTED_MIXIN(GlobalCacheStorageImpl);
24 public: 24 public:
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* >(HeapSupplement<T>::from(supplementable, name())); 27 GlobalCacheStorageImpl* supplement = static_cast<GlobalCacheStorageImpl* >(Supplement<T>::from(supplementable, name()));
28 if (!supplement) { 28 if (!supplement) {
29 supplement = new GlobalCacheStorageImpl(); 29 supplement = new GlobalCacheStorageImpl;
30 HeapSupplement<T>::provideTo(supplementable, name(), supplement); 30 Supplement<T>::provideTo(supplementable, name(), supplement);
31 } 31 }
32 return *supplement; 32 return *supplement;
33 } 33 }
34 34
35 ~GlobalCacheStorageImpl() 35 ~GlobalCacheStorageImpl()
36 { 36 {
37 if (m_caches) 37 if (m_caches)
38 m_caches->dispose(); 38 m_caches->dispose();
39 } 39 }
40 40
(...skipping 14 matching lines...) Expand all
55 m_caches = CacheStorage::create(GlobalFetch::ScopedFetcher::from(fet chingScope), Platform::current()->cacheStorage(WebSecurityOrigin(context->getSec urityOrigin()))); 55 m_caches = CacheStorage::create(GlobalFetch::ScopedFetcher::from(fet chingScope), Platform::current()->cacheStorage(WebSecurityOrigin(context->getSec urityOrigin())));
56 } 56 }
57 return m_caches; 57 return m_caches;
58 } 58 }
59 59
60 // Promptly dispose of associated CacheStorage. 60 // Promptly dispose of associated CacheStorage.
61 EAGERLY_FINALIZE(); 61 EAGERLY_FINALIZE();
62 DEFINE_INLINE_VIRTUAL_TRACE() 62 DEFINE_INLINE_VIRTUAL_TRACE()
63 { 63 {
64 visitor->trace(m_caches); 64 visitor->trace(m_caches);
65 HeapSupplement<T>::trace(visitor); 65 Supplement<T>::trace(visitor);
66 } 66 }
67 67
68 private: 68 private:
69 GlobalCacheStorageImpl() 69 GlobalCacheStorageImpl()
70 { 70 {
71 } 71 }
72 72
73 static const char* name() { return "CacheStorage"; } 73 static const char* name() { return "CacheStorage"; }
74 74
75 Member<CacheStorage> m_caches; 75 Member<CacheStorage> m_caches;
76 }; 76 };
77 77
78 } // namespace 78 } // namespace
79 79
80 CacheStorage* GlobalCacheStorage::caches(DOMWindow& window, ExceptionState& exce ptionState) 80 CacheStorage* GlobalCacheStorage::caches(DOMWindow& window, ExceptionState& exce ptionState)
81 { 81 {
82 return GlobalCacheStorageImpl<LocalDOMWindow>::from(toLocalDOMWindow(window) , window.getExecutionContext()).caches(toLocalDOMWindow(window), exceptionState) ; 82 return GlobalCacheStorageImpl<LocalDOMWindow>::from(toLocalDOMWindow(window) , window.getExecutionContext()).caches(toLocalDOMWindow(window), exceptionState) ;
83 } 83 }
84 84
85 CacheStorage* GlobalCacheStorage::caches(WorkerGlobalScope& worker, ExceptionSta te& exceptionState) 85 CacheStorage* GlobalCacheStorage::caches(WorkerGlobalScope& worker, ExceptionSta te& exceptionState)
86 { 86 {
87 return GlobalCacheStorageImpl<WorkerGlobalScope>::from(worker, worker.getExe cutionContext()).caches(worker, exceptionState); 87 return GlobalCacheStorageImpl<WorkerGlobalScope>::from(worker, worker.getExe cutionContext()).caches(worker, exceptionState);
88 } 88 }
89 89
90 } // namespace blink 90 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698