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

Side by Side Diff: webkit/dom_storage/dom_storage_area.h

Issue 9963107: Persist sessionStorage on disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test update. Created 8 years, 7 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) 2012 The Chromium Authors. All rights reserved. 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 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 WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_
6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
12 #include "base/nullable_string16.h" 13 #include "base/nullable_string16.h"
13 #include "base/string16.h" 14 #include "base/string16.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 #include "webkit/dom_storage/dom_storage_database.h" 16 #include "webkit/dom_storage/dom_storage_database_adapter.h"
16 #include "webkit/dom_storage/dom_storage_types.h" 17 #include "webkit/dom_storage/dom_storage_types.h"
17 18
18 namespace dom_storage { 19 namespace dom_storage {
19 20
21 class DomStorageDatabaseAdapter;
20 class DomStorageMap; 22 class DomStorageMap;
21 class DomStorageTaskRunner; 23 class DomStorageTaskRunner;
24 class SessionStorageDatabase;
22 25
23 // Container for a per-origin Map of key/value pairs potentially 26 // Container for a per-origin Map of key/value pairs potentially
24 // backed by storage on disk and lazily commits changes to disk. 27 // backed by storage on disk and lazily commits changes to disk.
25 // See class comments for DomStorageContext for a larger overview. 28 // See class comments for DomStorageContext for a larger overview.
26 class DomStorageArea 29 class DomStorageArea
27 : public base::RefCountedThreadSafe<DomStorageArea> { 30 : public base::RefCountedThreadSafe<DomStorageArea> {
28 31
29 public: 32 public:
30 static const FilePath::CharType kDatabaseFileExtension[]; 33 static const FilePath::CharType kDatabaseFileExtension[];
31 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); 34 static FilePath DatabaseFileNameFromOrigin(const GURL& origin);
32 static GURL OriginFromDatabaseFileName(const FilePath& file_name); 35 static GURL OriginFromDatabaseFileName(const FilePath& file_name);
33 36
37 // Local storage. Backed on disk if directory is nonempty.
34 DomStorageArea(int64 namespace_id, 38 DomStorageArea(int64 namespace_id,
35 const GURL& origin, 39 const GURL& origin,
36 const FilePath& directory, 40 const FilePath& directory,
37 DomStorageTaskRunner* task_runner); 41 DomStorageTaskRunner* task_runner);
38 42
43 // Session storage. Backed on disk if |session_storage_backing| is not NULL.
44 DomStorageArea(int64 namespace_id,
45 const GURL& origin,
46 SessionStorageDatabase* session_storage_backing,
47 DomStorageTaskRunner* task_runner);
48
39 const GURL& origin() const { return origin_; } 49 const GURL& origin() const { return origin_; }
40 int64 namespace_id() const { return namespace_id_; } 50 int64 namespace_id() const { return namespace_id_; }
41 51
42 // Writes a copy of the current set of values in the area to the |map|. 52 // Writes a copy of the current set of values in the area to the |map|.
43 void ExtractValues(ValuesMap* map); 53 void ExtractValues(ValuesMap* map);
44 54
45 unsigned Length(); 55 unsigned Length();
46 NullableString16 Key(unsigned index); 56 NullableString16 Key(unsigned index);
47 NullableString16 GetItem(const string16& key); 57 NullableString16 GetItem(const string16& key);
48 bool SetItem(const string16& key, const string16& value, 58 bool SetItem(const string16& key, const string16& value,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void CommitChanges(const CommitBatch* commit_batch); 111 void CommitChanges(const CommitBatch* commit_batch);
102 void OnCommitComplete(); 112 void OnCommitComplete();
103 113
104 void ShutdownInCommitSequence(); 114 void ShutdownInCommitSequence();
105 115
106 int64 namespace_id_; 116 int64 namespace_id_;
107 GURL origin_; 117 GURL origin_;
108 FilePath directory_; 118 FilePath directory_;
109 scoped_refptr<DomStorageTaskRunner> task_runner_; 119 scoped_refptr<DomStorageTaskRunner> task_runner_;
110 scoped_refptr<DomStorageMap> map_; 120 scoped_refptr<DomStorageMap> map_;
111 scoped_ptr<DomStorageDatabase> backing_; 121 scoped_ptr<DomStorageDatabaseAdapter> backing_;
122 scoped_refptr<SessionStorageDatabase> session_storage_backing_;
112 bool is_initial_import_done_; 123 bool is_initial_import_done_;
113 bool is_shutdown_; 124 bool is_shutdown_;
114 scoped_ptr<CommitBatch> commit_batch_; 125 scoped_ptr<CommitBatch> commit_batch_;
115 int commit_batches_in_flight_; 126 int commit_batches_in_flight_;
116 }; 127 };
117 128
118 } // namespace dom_storage 129 } // namespace dom_storage
119 130
120 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ 131 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698