Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / dom_storage / dom_storage_context_impl.h
bloba418ea37689c2f6892e0256c6a7c5431d3627106
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"
11 namespace base {
12 class FilePath;
15 namespace dom_storage {
16 class DomStorageContext;
19 namespace quota {
20 class SpecialStoragePolicy;
23 namespace content {
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> {
30 public:
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.
49 void PurgeMemory();
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.
58 void Shutdown();
60 private:
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_