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

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

Issue 7480041: Adding session-only localStorage. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Un-blocking the WebKit thread, delayed answering to the DOMStorageHostMsg_StorageAreaId. 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/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/time.h" 15 #include "base/time.h"
16 #include "content/browser/resource_context.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 {
23 class SpecialStoragePolicy; 24 class SpecialStoragePolicy;
24 } 25 }
25 26
26 // This is owned by WebKitContext and is all the dom storage information that's 27 // This is owned by WebKitContext and is all the dom storage information that's
27 // shared by all the DOMStorageMessageFilters that share the same profile. The 28 // shared by all the DOMStorageMessageFilters that share the same profile. The
28 // specifics of responsibilities are fairly well documented here and in 29 // specifics of responsibilities are fairly well documented here and in
29 // StorageNamespace and StorageArea. Everything is only to be accessed on the 30 // StorageNamespace and StorageArea. Everything is only to be accessed on the
30 // WebKit thread unless noted otherwise. 31 // WebKit thread unless noted otherwise.
31 // 32 //
32 // NOTE: Virtual methods facilitate mocking functions for testing. 33 // NOTE: Virtual methods facilitate mocking functions for testing.
33 class DOMStorageContext { 34 class DOMStorageContext {
34 public: 35 public:
35 DOMStorageContext(WebKitContext* webkit_context, 36 DOMStorageContext(WebKitContext* webkit_context,
36 quota::SpecialStoragePolicy* special_storage_policy); 37 quota::SpecialStoragePolicy* special_storage_policy,
38 const content::ResourceContext& resource_context);
37 virtual ~DOMStorageContext(); 39 virtual ~DOMStorageContext();
38 40
39 // Invalid storage id. No storage session will ever report this value. 41 // Invalid storage id. No storage session will ever report this value.
40 // Used in DOMStorageMessageFilter::OnStorageAreaId when coping with 42 // Used in DOMStorageMessageFilter::OnStorageAreaId when coping with
41 // interactions with non-existent storage sessions. 43 // interactions with non-existent storage sessions.
42 static const int64 kInvalidStorageId = -1; 44 static const int64 kInvalidStorageId = -1;
43 45
44 // Allocate a new storage area id. Only call on the WebKit thread. 46 // Allocate a new storage area id. Only call on the WebKit thread.
45 int64 AllocateStorageAreaId(); 47 int64 AllocateStorageAreaId();
46 48
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 102
101 void set_clear_local_state_on_exit_(bool clear_local_state) { 103 void set_clear_local_state_on_exit_(bool clear_local_state) {
102 clear_local_state_on_exit_ = clear_local_state; 104 clear_local_state_on_exit_ = clear_local_state;
103 } 105 }
104 106
105 #ifdef UNIT_TEST 107 #ifdef UNIT_TEST
106 // For unit tests allow to override the |data_path_|. 108 // For unit tests allow to override the |data_path_|.
107 void set_data_path(const FilePath& data_path) { data_path_ = data_path; } 109 void set_data_path(const FilePath& data_path) { data_path_ = data_path; }
108 #endif 110 #endif
109 111
112 const content::ResourceContext& GetResourceContext() const;
113
110 private: 114 private:
111 // Get the local storage instance. The object is owned by this class. 115 // Get the local storage instance. The object is owned by this class.
112 DOMStorageNamespace* CreateLocalStorage(); 116 DOMStorageNamespace* CreateLocalStorage();
113 117
114 // Get a new session storage namespace. The object is owned by this class. 118 // Get a new session storage namespace. The object is owned by this class.
115 DOMStorageNamespace* CreateSessionStorage(int64 namespace_id); 119 DOMStorageNamespace* CreateSessionStorage(int64 namespace_id);
116 120
117 // Used internally to register storage namespaces we create. 121 // Used internally to register storage namespaces we create.
118 void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace); 122 void RegisterStorageNamespace(DOMStorageNamespace* storage_namespace);
119 123
(...skipping 30 matching lines...) Expand all
150 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace 154 // Maps ids to StorageAreas. We do NOT own these objects. StorageNamespace
151 // (which does own them) will notify us when we should remove the entries. 155 // (which does own them) will notify us when we should remove the entries.
152 typedef std::map<int64, DOMStorageArea*> StorageAreaMap; 156 typedef std::map<int64, DOMStorageArea*> StorageAreaMap;
153 StorageAreaMap storage_area_map_; 157 StorageAreaMap storage_area_map_;
154 158
155 // Maps ids to StorageNamespaces. We own these objects. 159 // Maps ids to StorageNamespaces. We own these objects.
156 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap; 160 typedef std::map<int64, DOMStorageNamespace*> StorageNamespaceMap;
157 StorageNamespaceMap storage_namespace_map_; 161 StorageNamespaceMap storage_namespace_map_;
158 162
159 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 163 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
164 const content::ResourceContext& resource_context_;
160 165
161 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext); 166 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageContext);
162 }; 167 };
163 168
164 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_ 169 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698