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

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

Issue 8929007: Restore sessionStorage when chrome restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix: cloning storage areas. Created 8 years, 11 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_NAMESPACE_H_ 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/file_path.h"
9 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/string16.h" 12 #include "base/string16.h"
12 #include "content/common/dom_storage_common.h" 13 #include "content/common/dom_storage_common.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
14 15
15 class DOMStorageArea; 16 class DOMStorageArea;
16 class DOMStorageContext; 17 class DOMStorageContext;
17 class FilePath; 18 class FilePath;
18 19
19 namespace WebKit { 20 namespace WebKit {
20 class WebStorageArea; 21 class WebStorageArea;
21 class WebStorageNamespace; 22 class WebStorageNamespace;
22 } 23 }
23 24
24 // Only to be used on the WebKit thread. 25 // Only to be used on the WebKit thread.
25 class DOMStorageNamespace { 26 class DOMStorageNamespace {
26 public: 27 public:
27 static DOMStorageNamespace* CreateLocalStorageNamespace( 28 static DOMStorageNamespace* CreateLocalStorageNamespace(
28 DOMStorageContext* dom_storage_context, const FilePath& data_dir_path); 29 DOMStorageContext* dom_storage_context, const FilePath& data_dir_path);
29 static DOMStorageNamespace* CreateSessionStorageNamespace( 30 static DOMStorageNamespace* CreateSessionStorageNamespace(
30 DOMStorageContext* dom_storage_context, int64 namespace_id); 31 DOMStorageContext* dom_storage_context, const FilePath& data_dir_path,
32 int64 namespace_id);
31 33
32 ~DOMStorageNamespace(); 34 ~DOMStorageNamespace();
33 35
34 DOMStorageArea* GetStorageArea(const string16& origin); 36 DOMStorageArea* GetStorageArea(const string16& origin);
35 DOMStorageNamespace* Copy(int64 clone_namespace_id); 37 DOMStorageNamespace* Copy(int64 clone_namespace_id);
36 38
37 void PurgeMemory(); 39 void PurgeMemory();
38 40
39 const DOMStorageContext* dom_storage_context() const { 41 const DOMStorageContext* dom_storage_context() const {
40 return dom_storage_context_; 42 return dom_storage_context_;
41 } 43 }
42 int64 id() const { return id_; } 44 int64 id() const { return id_; }
43 const WebKit::WebString& data_dir_path() const { return data_dir_path_; } 45 const WebKit::WebString& data_dir_path() const { return data_dir_path_; }
44 DOMStorageType dom_storage_type() const { return dom_storage_type_; } 46 DOMStorageType dom_storage_type() const { return dom_storage_type_; }
47 FilePath session_storage_directory() const {
48 return session_storage_directory_;
49 }
45 50
46 // Creates a WebStorageArea for the given origin. This should only be called 51 // Creates a WebStorageArea for the given origin. This should only be called
47 // by an owned DOMStorageArea. 52 // by an owned DOMStorageArea.
48 WebKit::WebStorageArea* CreateWebStorageArea(const string16& origin); 53 WebKit::WebStorageArea* CreateWebStorageArea(const string16& origin);
49 54
55 void CopyDataTo(DOMStorageNamespace* other);
56
50 private: 57 private:
51 // Called by the static factory methods above. 58 // Called by the static factory methods above.
52 DOMStorageNamespace(DOMStorageContext* dom_storage_context, 59 DOMStorageNamespace(DOMStorageContext* dom_storage_context,
53 int64 id, 60 int64 id,
61 const FilePath& session_storage_directory,
54 const WebKit::WebString& data_dir_path, 62 const WebKit::WebString& data_dir_path,
55 DOMStorageType storage_type); 63 DOMStorageType storage_type);
56 64
57 // Creates the underlying WebStorageNamespace on demand. 65 // Creates the underlying WebStorageNamespace on demand.
58 void CreateWebStorageNamespaceIfNecessary(); 66 void CreateWebStorageNamespaceIfNecessary();
59 67
60 // All the storage areas we own. 68 // All the storage areas we own.
61 typedef base::hash_map<string16, DOMStorageArea*> OriginToStorageAreaMap; 69 typedef base::hash_map<string16, DOMStorageArea*> OriginToStorageAreaMap;
62 OriginToStorageAreaMap origin_to_storage_area_; 70 OriginToStorageAreaMap origin_to_storage_area_;
63 71
64 // The DOMStorageContext that owns us. 72 // The DOMStorageContext that owns us.
65 DOMStorageContext* dom_storage_context_; 73 DOMStorageContext* dom_storage_context_;
66 74
67 // The WebKit storage namespace we manage. 75 // The WebKit storage namespace we manage.
68 scoped_ptr<WebKit::WebStorageNamespace> storage_namespace_; 76 scoped_ptr<WebKit::WebStorageNamespace> storage_namespace_;
69 77
70 // Our id. Unique to our parent WebKitContext class. 78 // Our id. Unique to our parent WebKitContext class.
71 int64 id_; 79 int64 id_;
72 80
81 // Identifies the directory where the sessionStorage databases reside. Empty
82 // for localStorage.
83 FilePath session_storage_directory_;
84
73 // The path used to create us, so we can recreate our WebStorageNamespace on 85 // The path used to create us, so we can recreate our WebStorageNamespace on
74 // demand. 86 // demand.
75 WebKit::WebString data_dir_path_; 87 WebKit::WebString data_dir_path_;
76 88
77 // SessionStorage vs. LocalStorage. 89 // SessionStorage vs. LocalStorage.
78 const DOMStorageType dom_storage_type_; 90 const DOMStorageType dom_storage_type_;
79 91
80 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageNamespace); 92 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageNamespace);
81 }; 93 };
82 94
95 struct SessionStorageCreatedDetails {
96 int64 id;
97 FilePath session_storage_directory;
98 SessionStorageCreatedDetails();
99 SessionStorageCreatedDetails(int64 id,
100 const FilePath& session_storage_directory);
101 ~SessionStorageCreatedDetails();
102 };
103
83 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ 104 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698