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

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: code review Created 8 years, 5 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/memory/scoped_ptr.h"
13 #include "base/nullable_string16.h" 13 #include "base/nullable_string16.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "base/synchronization/lock.h"
michaeln 2012/07/10 19:04:13 is this still needed?
marja 2012/07/11 12:41:31 Done.
15 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.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
20 class DomStorageDatabaseAdapter; 21 class DomStorageDatabaseAdapter;
21 class DomStorageMap; 22 class DomStorageMap;
22 class DomStorageTaskRunner; 23 class DomStorageTaskRunner;
24 class SessionStorageDatabase;
23 25
24 // Container for a per-origin Map of key/value pairs potentially 26 // Container for a per-origin Map of key/value pairs potentially
25 // backed by storage on disk and lazily commits changes to disk. 27 // backed by storage on disk and lazily commits changes to disk.
26 // See class comments for DomStorageContext for a larger overview. 28 // See class comments for DomStorageContext for a larger overview.
27 class DomStorageArea 29 class DomStorageArea
28 : public base::RefCountedThreadSafe<DomStorageArea> { 30 : public base::RefCountedThreadSafe<DomStorageArea> {
29 31
30 public: 32 public:
31 static const FilePath::CharType kDatabaseFileExtension[]; 33 static const FilePath::CharType kDatabaseFileExtension[];
32 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); 34 static FilePath DatabaseFileNameFromOrigin(const GURL& origin);
33 static GURL OriginFromDatabaseFileName(const FilePath& file_name); 35 static GURL OriginFromDatabaseFileName(const FilePath& file_name);
34 36
35 // Local storage. Backed on disk if directory is nonempty. 37 // Local storage. Backed on disk if directory is nonempty.
36 DomStorageArea(const GURL& origin, 38 DomStorageArea(const GURL& origin,
37 const FilePath& directory, 39 const FilePath& directory,
38 DomStorageTaskRunner* task_runner); 40 DomStorageTaskRunner* task_runner);
39 41
40 // Session storage. 42 // Session storage. Backed on disk if |session_storage_backing| is not NULL.
41 DomStorageArea(int64 namespace_id, 43 DomStorageArea(int64 namespace_id,
42 const std::string& persistent_namespace_id, 44 const std::string& persistent_namespace_id,
43 const GURL& origin, 45 const GURL& origin,
46 SessionStorageDatabase* session_storage_backing,
44 DomStorageTaskRunner* task_runner); 47 DomStorageTaskRunner* task_runner);
45 48
46 const GURL& origin() const { return origin_; } 49 const GURL& origin() const { return origin_; }
47 int64 namespace_id() const { return namespace_id_; } 50 int64 namespace_id() const { return namespace_id_; }
48 51
49 // 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|.
50 void ExtractValues(ValuesMap* map); 53 void ExtractValues(ValuesMap* map);
51 54
52 unsigned Length(); 55 unsigned Length();
53 NullableString16 Key(unsigned index); 56 NullableString16 Key(unsigned index);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 void InitialImportIfNeeded(); 107 void InitialImportIfNeeded();
105 108
106 // Post tasks to defer writing a batch of changed values to 109 // Post tasks to defer writing a batch of changed values to
107 // disk on the commit sequence, and to call back on the primary 110 // disk on the commit sequence, and to call back on the primary
108 // task sequence when complete. 111 // task sequence when complete.
109 CommitBatch* CreateCommitBatchIfNeeded(); 112 CommitBatch* CreateCommitBatchIfNeeded();
110 void OnCommitTimer(); 113 void OnCommitTimer();
111 void CommitChanges(const CommitBatch* commit_batch); 114 void CommitChanges(const CommitBatch* commit_batch);
112 void OnCommitComplete(); 115 void OnCommitComplete();
113 116
117 void DeleteOriginInCommitSequence();
michaeln 2012/07/10 19:04:13 and this?
marja 2012/07/11 12:41:31 Done.
118
114 void ShutdownInCommitSequence(); 119 void ShutdownInCommitSequence();
115 120
116 int64 namespace_id_; 121 int64 namespace_id_;
117 std::string persistent_namespace_id_; 122 std::string persistent_namespace_id_;
118 GURL origin_; 123 GURL origin_;
119 FilePath directory_; 124 FilePath directory_;
120 scoped_refptr<DomStorageTaskRunner> task_runner_; 125 scoped_refptr<DomStorageTaskRunner> task_runner_;
121 scoped_refptr<DomStorageMap> map_; 126 scoped_refptr<DomStorageMap> map_;
122 scoped_ptr<DomStorageDatabaseAdapter> backing_; 127 scoped_ptr<DomStorageDatabaseAdapter> backing_;
128 scoped_refptr<SessionStorageDatabase> session_storage_backing_;
123 bool is_initial_import_done_; 129 bool is_initial_import_done_;
124 bool is_shutdown_; 130 bool is_shutdown_;
125 scoped_ptr<CommitBatch> commit_batch_; 131 scoped_ptr<CommitBatch> commit_batch_;
126 int commit_batches_in_flight_; 132 int commit_batches_in_flight_;
127 }; 133 };
128 134
129 } // namespace dom_storage 135 } // namespace dom_storage
130 136
131 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ 137 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698