Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Side by Side Diff: content/browser/in_process_webkit/dom_storage_context.h

Issue 7619010: Session-only local storage cleared on exit. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Code review comments (tiny). Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 11
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/gtest_prod_util.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/string16.h" 15 #include "base/string16.h"
15 #include "base/time.h" 16 #include "base/time.h"
16 17
17 class DOMStorageArea; 18 class DOMStorageArea;
18 class DOMStorageMessageFilter; 19 class DOMStorageMessageFilter;
19 class DOMStorageNamespace; 20 class DOMStorageNamespace;
20 class WebKitContext; 21 class WebKitContext;
21 22
22 namespace quota { 23 namespace quota {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 const MessageFilterSet* GetMessageFilterSet() const; 74 const MessageFilterSet* GetMessageFilterSet() const;
74 75
75 // Tells storage namespaces to purge any memory they do not need. 76 // Tells storage namespaces to purge any memory they do not need.
76 virtual void PurgeMemory(); 77 virtual void PurgeMemory();
77 78
78 // Delete any local storage files that have been touched since the cutoff 79 // Delete any local storage files that have been touched since the cutoff
79 // date that's supplied. Protected origins, per the SpecialStoragePolicy, 80 // date that's supplied. Protected origins, per the SpecialStoragePolicy,
80 // are not deleted by this method. 81 // are not deleted by this method.
81 void DeleteDataModifiedSince(const base::Time& cutoff); 82 void DeleteDataModifiedSince(const base::Time& cutoff);
82 83
84 // Delete any local storage files which are allowed to be stored only until
85 // the end of the session. Protected origins, per the SpecialStoragePolicy,
86 // are not deleted by this method.
87 void DeleteSessionOnlyData();
88
83 // Deletes a single local storage file. 89 // Deletes a single local storage file.
84 void DeleteLocalStorageFile(const FilePath& file_path); 90 void DeleteLocalStorageFile(const FilePath& file_path);
85 91
86 // Deletes the local storage file for the given origin. 92 // Deletes the local storage file for the given origin.
87 void DeleteLocalStorageForOrigin(const string16& origin_id); 93 void DeleteLocalStorageForOrigin(const string16& origin_id);
88 94
89 // Deletes all local storage files. 95 // Deletes all local storage files.
90 void DeleteAllLocalStorageFiles(); 96 void DeleteAllLocalStorageFiles();
91 97
92 // The local storage directory. 98 // The local storage directory.
93 static const FilePath::CharType kLocalStorageDirectory[]; 99 static const FilePath::CharType kLocalStorageDirectory[];
94 100
95 // The local storage file extension. 101 // The local storage file extension.
96 static const FilePath::CharType kLocalStorageExtension[]; 102 static const FilePath::CharType kLocalStorageExtension[];
97 103
98 // Get the file name of the local storage file for the given origin. 104 // Get the file name of the local storage file for the given origin.
99 FilePath GetLocalStorageFilePath(const string16& origin_id) const; 105 FilePath GetLocalStorageFilePath(const string16& origin_id) const;
100 106
101 void set_clear_local_state_on_exit_(bool clear_local_state) { 107 void set_clear_local_state_on_exit_(bool clear_local_state) {
102 clear_local_state_on_exit_ = clear_local_state; 108 clear_local_state_on_exit_ = clear_local_state;
103 } 109 }
104 110
105 #ifdef UNIT_TEST 111 #ifdef UNIT_TEST
106 // For unit tests allow to override the |data_path_|. 112 // For unit tests allow to override the |data_path_|.
107 void set_data_path(const FilePath& data_path) { data_path_ = data_path; } 113 void set_data_path(const FilePath& data_path) { data_path_ = data_path; }
108 #endif 114 #endif
109 115
110 private: 116 private:
117
118 FRIEND_TEST_ALL_PREFIXES(DOMStorageTest, SessionOnly);
119
111 // Get the local storage instance. The object is owned by this class. 120 // Get the local storage instance. The object is owned by this class.
112 DOMStorageNamespace* CreateLocalStorage(); 121 DOMStorageNamespace* CreateLocalStorage();
113 122
114 // Get a new session storage namespace. The object is owned by this class. 123 // Get a new session storage namespace. The object is owned by this class.
115 DOMStorageNamespace* CreateSessionStorage(int64 namespace_id); 124 DOMStorageNamespace* CreateSessionStorage(int64 namespace_id);
116 125
117 // Used internally to register storage namespaces we create. 126 // Used internally to register storage namespaces we create.
118 void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace); 127 void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace);
119 128
120 // The WebKit thread half of CloneSessionStorage above. Static because 129 // The WebKit thread half of CloneSessionStorage above. Static because
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // Maps ids to StorageNamespaces. We own these objects. 164 // Maps ids to StorageNamespaces. We own these objects.
156 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; 165 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap;
157 StorageNamespaceMap storage_namespace_map_; 166 StorageNamespaceMap storage_namespace_map_;
158 167
159 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 168 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
160 169
161 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); 170 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext);
162 }; 171 };
163 172
164 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ 173 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | content/browser/in_process_webkit/dom_storage_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698