Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / browser / dom_storage / dom_storage_context_wrapper.h
blob6ef2abf84f01cf9d8e144d89017a598748bbabf6
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "content/common/content_export.h"
12 #include "content/public/browser/dom_storage_context.h"
14 namespace base {
15 class FilePath;
18 namespace storage {
19 class SpecialStoragePolicy;
22 namespace content {
24 class DOMStorageContextImpl;
26 // This is owned by BrowserContext (aka Profile) and encapsulates all
27 // per-profile dom storage state.
28 class CONTENT_EXPORT DOMStorageContextWrapper :
29 NON_EXPORTED_BASE(public DOMStorageContext),
30 public base::RefCountedThreadSafe<DOMStorageContextWrapper> {
31 public:
32 // If |data_path| is empty, nothing will be saved to disk.
33 DOMStorageContextWrapper(
34 const base::FilePath& data_path,
35 storage::SpecialStoragePolicy* special_storage_policy);
37 // DOMStorageContext implementation.
38 void GetLocalStorageUsage(
39 const GetLocalStorageUsageCallback& callback) override;
40 void GetSessionStorageUsage(
41 const GetSessionStorageUsageCallback& callback) override;
42 void DeleteLocalStorage(const GURL& origin) override;
43 void DeleteSessionStorage(const SessionStorageUsageInfo& usage_info) override;
44 void SetSaveSessionStorageOnDisk() override;
45 scoped_refptr<SessionStorageNamespace> RecreateSessionStorage(
46 const std::string& persistent_id) override;
47 void StartScavengingUnusedSessionStorage() override;
49 // Used by content settings to alter the behavior around
50 // what data to keep and what data to discard at shutdown.
51 // The policy is not so straight forward to describe, see
52 // the implementation for details.
53 void SetForceKeepSessionState();
55 // Called when the BrowserContext/Profile is going away.
56 void Shutdown();
58 void Flush();
60 private:
61 friend class DOMStorageMessageFilter; // for access to context()
62 friend class SessionStorageNamespaceImpl; // ditto
63 friend class base::RefCountedThreadSafe<DOMStorageContextWrapper>;
65 ~DOMStorageContextWrapper() override;
66 DOMStorageContextImpl* context() const { return context_.get(); }
68 scoped_refptr<DOMStorageContextImpl> context_;
70 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextWrapper);
73 } // namespace content
75 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_WRAPPER_H_