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

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

Issue 9817011: DomStorage data deletion and memory purging. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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"
(...skipping 11 matching lines...) Expand all
22 22
23 // Container for a per-origin Map of key/value pairs potentially 23 // Container for a per-origin Map of key/value pairs potentially
24 // backed by storage on disk and lazily commits changes to disk. 24 // backed by storage on disk and lazily commits changes to disk.
25 // See class comments for DomStorageContext for a larger overview. 25 // See class comments for DomStorageContext for a larger overview.
26 class DomStorageArea 26 class DomStorageArea
27 : public base::RefCountedThreadSafe<DomStorageArea> { 27 : public base::RefCountedThreadSafe<DomStorageArea> {
28 28
29 public: 29 public:
30 static const FilePath::CharType kDatabaseFileExtension[]; 30 static const FilePath::CharType kDatabaseFileExtension[];
31 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); 31 static FilePath DatabaseFileNameFromOrigin(const GURL& origin);
32 static GURL OriginFromDatabaseFileName(const FilePath& file_name);
32 33
33 DomStorageArea(int64 namespace_id, 34 DomStorageArea(int64 namespace_id,
34 const GURL& origin, 35 const GURL& origin,
35 const FilePath& directory, 36 const FilePath& directory,
36 DomStorageTaskRunner* task_runner); 37 DomStorageTaskRunner* task_runner);
37 38
38 const GURL& origin() const { return origin_; } 39 const GURL& origin() const { return origin_; }
39 int64 namespace_id() const { return namespace_id_; } 40 int64 namespace_id() const { return namespace_id_; }
40 41
41 unsigned Length(); 42 unsigned Length();
42 NullableString16 Key(unsigned index); 43 NullableString16 Key(unsigned index);
43 NullableString16 GetItem(const string16& key); 44 NullableString16 GetItem(const string16& key);
44 bool SetItem(const string16& key, const string16& value, 45 bool SetItem(const string16& key, const string16& value,
45 NullableString16* old_value); 46 NullableString16* old_value);
46 bool RemoveItem(const string16& key, string16* old_value); 47 bool RemoveItem(const string16& key, string16* old_value);
47 bool Clear(); 48 bool Clear();
48 49
49 DomStorageArea* ShallowCopy(int64 destination_namespace_id); 50 DomStorageArea* ShallowCopy(int64 destination_namespace_id);
50 51
52 bool HasUncommittedChanges() const;
53
54 // Similar to Clear() but more optimized for just deleting
55 // without raising events.
56 void DeleteOrigin();
57
58 // Frees up memory when possible. Typically, this method returns
59 // the object to its just constructed state, however if uncommitted
60 // changes are pending, it does nothing.
61 void PurgeMemory();
62
51 // Schedules the commit of any unsaved changes and enters a 63 // Schedules the commit of any unsaved changes and enters a
52 // shutdown state such that the value getters and setters will 64 // shutdown state such that the value getters and setters will
53 // no longer do anything. 65 // no longer do anything.
54 void Shutdown(); 66 void Shutdown();
55 67
56 private: 68 private:
57 friend class DomStorageAreaTest; 69 friend class DomStorageAreaTest;
58 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DomStorageAreaBasics); 70 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DomStorageAreaBasics);
59 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, BackingDatabaseOpened); 71 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, BackingDatabaseOpened);
60 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, TestDatabaseFilePath); 72 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, TestDatabaseFilePath);
61 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitTasks); 73 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitTasks);
62 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitChangesAtShutdown); 74 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, CommitChangesAtShutdown);
75 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, DeleteOrigin);
76 FRIEND_TEST_ALL_PREFIXES(DomStorageAreaTest, PurgeMemory);
63 friend class base::RefCountedThreadSafe<DomStorageArea>; 77 friend class base::RefCountedThreadSafe<DomStorageArea>;
64 78
65 struct CommitBatch { 79 struct CommitBatch {
66 bool clear_all_first; 80 bool clear_all_first;
67 ValuesMap changed_values; 81 ValuesMap changed_values;
68 CommitBatch(); 82 CommitBatch();
69 ~CommitBatch(); 83 ~CommitBatch();
70 }; 84 };
71 85
72 ~DomStorageArea(); 86 ~DomStorageArea();
(...skipping 21 matching lines...) Expand all
94 scoped_ptr<DomStorageDatabase> backing_; 108 scoped_ptr<DomStorageDatabase> backing_;
95 bool is_initial_import_done_; 109 bool is_initial_import_done_;
96 bool is_shutdown_; 110 bool is_shutdown_;
97 scoped_ptr<CommitBatch> commit_batch_; 111 scoped_ptr<CommitBatch> commit_batch_;
98 scoped_ptr<CommitBatch> in_flight_commit_batch_; 112 scoped_ptr<CommitBatch> in_flight_commit_batch_;
99 }; 113 };
100 114
101 } // namespace dom_storage 115 } // namespace dom_storage
102 116
103 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ 117 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_impl_new.cc ('k') | webkit/dom_storage/dom_storage_area.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698