blob: 7ec0899a0230884cd8609dbe561d0f2592f2dbca (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// Copyright 2013 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 CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_
#define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_
#include <map>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "content/common/storage_partition_service.mojom.h"
#include "content/public/browser/dom_storage_context.h"
#include "url/origin.h"
namespace base {
class FilePath;
}
namespace storage {
class SpecialStoragePolicy;
}
namespace content {
class DOMStorageContextImpl;
class LevelDBWrapperImpl;
// This is owned by Storage Partition and encapsulates all its dom storage
// state.
class CONTENT_EXPORT DOMStorageContextWrapper :
NON_EXPORTED_BASE(public DOMStorageContext),
public base::RefCountedThreadSafe<DOMStorageContextWrapper> {
public:
// If |data_path| is empty, nothing will be saved to disk.
DOMStorageContextWrapper(
const base::FilePath& data_path,
storage::SpecialStoragePolicy* special_storage_policy);
// DOMStorageContext implementation.
void GetLocalStorageUsage(
const GetLocalStorageUsageCallback& callback) override;
void GetSessionStorageUsage(
const GetSessionStorageUsageCallback& callback) override;
void DeleteLocalStorage(const GURL& origin) override;
void DeleteSessionStorage(const SessionStorageUsageInfo& usage_info) override;
void SetSaveSessionStorageOnDisk() override;
scoped_refptr<SessionStorageNamespace> RecreateSessionStorage(
const std::string& persistent_id) override;
void StartScavengingUnusedSessionStorage() override;
// Used by content settings to alter the behavior around
// what data to keep and what data to discard at shutdown.
// The policy is not so straight forward to describe, see
// the implementation for details.
void SetForceKeepSessionState();
// Called when the BrowserContext/Profile is going away.
void Shutdown();
void Flush();
// See StoragePartitionService interface.
void OpenLocalStorage(
const url::Origin& origin,
mojo::InterfaceRequest<LevelDBWrapper> request);
private:
friend class DOMStorageMessageFilter; // for access to context()
friend class SessionStorageNamespaceImpl; // ditto
friend class base::RefCountedThreadSafe<DOMStorageContextWrapper>;
~DOMStorageContextWrapper() override;
DOMStorageContextImpl* context() const { return context_.get(); }
void LevelDBWrapperImplHasNoBindings(const url::Origin& origin);
// Used for mojo-based LocalStorage implementation (behind
// --mojo-local-storage for now). Maps between an origin and its prefixed
// LevelDB view.
std::map<url::Origin, scoped_ptr<LevelDBWrapperImpl>> level_db_wrappers_;
scoped_refptr<DOMStorageContextImpl> context_;
DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextWrapper);
};
} // namespace content
#endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_
|