OLD | NEW |
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/nullable_string16.h" | 12 #include "base/nullable_string16.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "webkit/dom_storage/dom_storage_database.h" | 15 #include "webkit/dom_storage/dom_storage_database.h" |
16 #include "webkit/dom_storage/dom_storage_types.h" | 16 #include "webkit/dom_storage/dom_storage_types.h" |
17 | 17 |
18 namespace dom_storage { | 18 namespace dom_storage { |
19 | 19 |
20 class DomStorageMap; | 20 class DomStorageMap; |
21 class DomStorageTaskRunner; | 21 class DomStorageTaskRunner; |
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[]; | |
31 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); | |
32 | |
33 DomStorageArea(int64 namespace_id, | 30 DomStorageArea(int64 namespace_id, |
34 const GURL& origin, | 31 const GURL& origin, |
35 const FilePath& directory, | 32 const FilePath& directory, |
36 DomStorageTaskRunner* task_runner); | 33 DomStorageTaskRunner* task_runner); |
37 | 34 |
38 const GURL& origin() const { return origin_; } | 35 const GURL& origin() const { return origin_; } |
39 int64 namespace_id() const { return namespace_id_; } | 36 int64 namespace_id() const { return namespace_id_; } |
40 | 37 |
41 unsigned Length(); | 38 unsigned Length(); |
42 NullableString16 Key(unsigned index); | 39 NullableString16 Key(unsigned index); |
(...skipping 13 matching lines...) Expand all Loading... |
56 | 53 |
57 // If we haven't done so already and this is a local storage area, | 54 // If we haven't done so already and this is a local storage area, |
58 // will attempt to read any values for this origin currently | 55 // will attempt to read any values for this origin currently |
59 // stored on disk. | 56 // stored on disk. |
60 void InitialImportIfNeeded(); | 57 void InitialImportIfNeeded(); |
61 | 58 |
62 // Posts a task to write the set of changed values to disk. | 59 // Posts a task to write the set of changed values to disk. |
63 void ScheduleCommitChanges(); | 60 void ScheduleCommitChanges(); |
64 void CommitChanges(); | 61 void CommitChanges(); |
65 | 62 |
| 63 static FilePath DatabaseFileNameFromOrigin(const GURL& origin); |
| 64 |
66 ~DomStorageArea(); | 65 ~DomStorageArea(); |
67 | 66 |
68 int64 namespace_id_; | 67 int64 namespace_id_; |
69 GURL origin_; | 68 GURL origin_; |
70 FilePath directory_; | 69 FilePath directory_; |
71 scoped_refptr<DomStorageTaskRunner> task_runner_; | 70 scoped_refptr<DomStorageTaskRunner> task_runner_; |
72 scoped_refptr<DomStorageMap> map_; | 71 scoped_refptr<DomStorageMap> map_; |
73 scoped_ptr<DomStorageDatabase> backing_; | 72 scoped_ptr<DomStorageDatabase> backing_; |
74 bool initial_import_done_; | 73 bool initial_import_done_; |
75 ValuesMap changed_values_; | 74 ValuesMap changed_values_; |
76 bool clear_all_next_commit_; | 75 bool clear_all_next_commit_; |
77 bool commit_in_flight_; | 76 bool commit_in_flight_; |
78 }; | 77 }; |
79 | 78 |
80 } // namespace dom_storage | 79 } // namespace dom_storage |
81 | 80 |
82 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ | 81 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
OLD | NEW |