summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/cookie_store/global_cookie_store_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/cookie_store/global_cookie_store_impl.h')
-rw-r--r--chromium/third_party/blink/renderer/modules/cookie_store/global_cookie_store_impl.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/modules/cookie_store/global_cookie_store_impl.h b/chromium/third_party/blink/renderer/modules/cookie_store/global_cookie_store_impl.h
new file mode 100644
index 00000000000..fa8c46e84e9
--- /dev/null
+++ b/chromium/third_party/blink/renderer/modules/cookie_store/global_cookie_store_impl.h
@@ -0,0 +1,71 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_COOKIE_STORE_GLOBAL_COOKIE_STORE_IMPL_H_
+#define THIRD_PARTY_BLINK_RENDERER_MODULES_COOKIE_STORE_GLOBAL_COOKIE_STORE_IMPL_H_
+
+#include <utility>
+
+#include "services/service_manager/public/cpp/interface_provider.h"
+#include "third_party/blink/renderer/modules/cookie_store/cookie_store.h"
+#include "third_party/blink/renderer/platform/heap/handle.h"
+#include "third_party/blink/renderer/platform/supplementable.h"
+
+namespace blink {
+
+template <typename T>
+class GlobalCookieStoreImpl final
+ : public GarbageCollected<GlobalCookieStoreImpl<T>>,
+ public Supplement<T> {
+ USING_GARBAGE_COLLECTED_MIXIN(GlobalCookieStoreImpl);
+
+ public:
+ static const char kSupplementName[];
+
+ static GlobalCookieStoreImpl& From(T& supplementable) {
+ GlobalCookieStoreImpl* supplement =
+ Supplement<T>::template From<GlobalCookieStoreImpl>(supplementable);
+ if (!supplement) {
+ supplement = new GlobalCookieStoreImpl(supplementable);
+ Supplement<T>::ProvideTo(supplementable, supplement);
+ }
+ return *supplement;
+ }
+
+ CookieStore* GetCookieStore(T& scope) {
+ if (!cookie_store_) {
+ ExecutionContext* execution_context = scope.GetExecutionContext();
+
+ service_manager::InterfaceProvider* interface_provider =
+ execution_context->GetInterfaceProvider();
+ if (!interface_provider)
+ return nullptr;
+ cookie_store_ = BuildCookieStore(execution_context, interface_provider);
+ }
+ return cookie_store_;
+ }
+
+ CookieStore* BuildCookieStore(ExecutionContext*,
+ service_manager::InterfaceProvider*);
+
+ void Trace(blink::Visitor* visitor) override {
+ visitor->Trace(cookie_store_);
+ Supplement<T>::Trace(visitor);
+ }
+
+ private:
+ explicit GlobalCookieStoreImpl(T& supplementable)
+ : Supplement<T>(supplementable) {}
+
+ Member<CookieStore> cookie_store_;
+};
+
+// static
+template <typename T>
+const char GlobalCookieStoreImpl<T>::kSupplementName[] =
+ "GlobalCookieStoreImpl";
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_COOKIE_STORE_GLOBAL_COOKIE_STORE_IMPL_H_