OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | |
7 #pragma once | |
8 | |
9 #include "base/file_path.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/string16.h" | |
12 #include "base/time.h" | |
13 #include "content/public/browser/dom_storage_context.h" | |
14 #include "webkit/dom_storage/dom_storage_types.h" | |
15 | |
16 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND | |
17 | |
18 namespace dom_storage { | |
19 class DomStorageContext; | |
20 } | |
21 | |
22 namespace quota { | |
23 class SpecialStoragePolicy; | |
24 } | |
25 | |
26 // This is owned by BrowserContext (aka Profile) and encapsulates all | |
27 // per-profile dom storage state. | |
28 class CONTENT_EXPORT DOMStorageContextImpl : | |
29 NON_EXPORTED_BASE(public content::DOMStorageContext), | |
30 public base::RefCountedThreadSafe<DOMStorageContextImpl> { | |
31 public: | |
32 // If |data_path| is empty, nothing will be saved to disk. | |
33 DOMStorageContextImpl(const FilePath& data_path, | |
34 quota::SpecialStoragePolicy* special_storage_policy); | |
35 | |
36 // DOMStorageContext implementation. | |
37 virtual void GetAllStorageFiles( | |
38 const GetAllStorageFilesCallback& callback) OVERRIDE; | |
39 virtual FilePath GetFilePath(const string16& origin_id) const OVERRIDE; | |
40 virtual void DeleteForOrigin(const string16& origin_id) OVERRIDE; | |
41 virtual void DeleteLocalStorageFile(const FilePath& file_path) OVERRIDE; | |
42 virtual void DeleteDataModifiedSince(const base::Time& cutoff) OVERRIDE; | |
43 | |
44 // Called to free up memory that's not strictly needed. | |
45 void PurgeMemory(); | |
46 | |
47 // Used by content settings to alter the behavior around | |
48 // what data to keep and what data to discard at shutdown. | |
49 // The policy is not so straight forward to describe, see | |
50 // the implementation for details. | |
51 void SetClearLocalState(bool clear_local_state); | |
52 void SaveSessionState(); | |
53 | |
54 // Called when the BrowserContext/Profile is going away. | |
55 void Shutdown(); | |
56 | |
57 // See render_message_filter.cc for details. | |
58 // TODO(michaeln): Remove this method when that bug is fixed. | |
59 int64 LeakyCloneSessionStorage(int64 existing_namespace_id); | |
60 | |
61 private: | |
62 friend class DOMStorageMessageFilter; // for access to context() | |
63 friend class SessionStorageNamespaceImpl; // ditto | |
64 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>; | |
65 | |
66 virtual ~DOMStorageContextImpl(); | |
67 dom_storage::DomStorageContext* context() const { return context_.get(); } | |
68 | |
69 scoped_refptr<dom_storage::DomStorageContext> context_; | |
70 | |
71 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContextImpl); | |
72 }; | |
73 | |
74 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND | |
75 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | |
OLD | NEW |