1 // Copyright (c) 2012 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_IMPL_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "content/public/browser/dom_storage_context.h"
15 namespace dom_storage
{
16 class DomStorageContext
;
20 class SpecialStoragePolicy
;
25 // This is owned by BrowserContext (aka Profile) and encapsulates all
26 // per-profile dom storage state.
27 class CONTENT_EXPORT DOMStorageContextImpl
:
28 NON_EXPORTED_BASE(public DOMStorageContext
),
29 public base::RefCountedThreadSafe
<DOMStorageContextImpl
> {
31 // If |data_path| is empty, nothing will be saved to disk.
32 DOMStorageContextImpl(const base::FilePath
& data_path
,
33 quota::SpecialStoragePolicy
* special_storage_policy
);
35 // DOMStorageContext implementation.
36 virtual void GetLocalStorageUsage(
37 const GetLocalStorageUsageCallback
& callback
) OVERRIDE
;
38 virtual void GetSessionStorageUsage(
39 const GetSessionStorageUsageCallback
& callback
) OVERRIDE
;
40 virtual void DeleteLocalStorage(const GURL
& origin
) OVERRIDE
;
41 virtual void DeleteSessionStorage(
42 const dom_storage::SessionStorageUsageInfo
& usage_info
) OVERRIDE
;
43 virtual void SetSaveSessionStorageOnDisk() OVERRIDE
;
44 virtual scoped_refptr
<SessionStorageNamespace
>
45 RecreateSessionStorage(const std::string
& persistent_id
) OVERRIDE
;
46 virtual void StartScavengingUnusedSessionStorage() OVERRIDE
;
48 // Called to free up memory that's not strictly needed.
51 // Used by content settings to alter the behavior around
52 // what data to keep and what data to discard at shutdown.
53 // The policy is not so straight forward to describe, see
54 // the implementation for details.
55 void SetForceKeepSessionState();
57 // Called when the BrowserContext/Profile is going away.
61 friend class DOMStorageMessageFilter
; // for access to context()
62 friend class SessionStorageNamespaceImpl
; // ditto
63 friend class base::RefCountedThreadSafe
<DOMStorageContextImpl
>;
65 virtual ~DOMStorageContextImpl();
66 dom_storage::DomStorageContext
* context() const { return context_
.get(); }
68 scoped_refptr
<dom_storage::DomStorageContext
> context_
;
70 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextImpl
);
73 } // namespace content
75 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_