summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/storage/StorageNamespaceController.h
blob: 849bcb6163c501e4fbf027960adc20c6c31b3618 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2015 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 StorageNamespaceController_h
#define StorageNamespaceController_h

#include "core/page/Page.h"
#include "modules/ModulesExport.h"
#include "platform/Supplementable.h"
#include "wtf/PassOwnPtr.h"

namespace blink {

class InspectorDOMStorageAgent;
class StorageClient;
class StorageNamespace;

class MODULES_EXPORT StorageNamespaceController final : public NoBaseWillBeGarbageCollectedFinalized<StorageNamespaceController>, public WillBeHeapSupplement<Page> {
    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(StorageNamespaceController);
    USING_FAST_MALLOC_WILL_BE_REMOVED(StorageNamespaceController);
public:
    StorageNamespace* sessionStorage(bool optionalCreate = true);
    StorageClient* storageClient() { return m_client; }
    ~StorageNamespaceController();

    static void provideStorageNamespaceTo(Page&, StorageClient*);
    static StorageNamespaceController* from(Page* page) { return static_cast<StorageNamespaceController*>(WillBeHeapSupplement<Page>::from(page, supplementName())); }

    DECLARE_TRACE();

    InspectorDOMStorageAgent* inspectorAgent() { return m_inspectorAgent; }
    void setInspectorAgent(InspectorDOMStorageAgent* agent) { m_inspectorAgent = agent; }
private:
    explicit StorageNamespaceController(StorageClient*);
    static const char* supplementName();
    OwnPtr<StorageNamespace> m_sessionStorage;
    StorageClient* m_client;
    RawPtrWillBeMember<InspectorDOMStorageAgent> m_inspectorAgent;
};

} // namespace blink

#endif // StorageNamespaceController_h