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 #include "webkit/dom_storage/dom_storage_area.h" | 5 #include "webkit/dom_storage/dom_storage_area.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "base/tracked_objects.h" | 10 #include "base/tracked_objects.h" |
11 #include "webkit/dom_storage/dom_storage_map.h" | 11 #include "webkit/dom_storage/dom_storage_map.h" |
12 #include "webkit/dom_storage/dom_storage_namespace.h" | 12 #include "webkit/dom_storage/dom_storage_namespace.h" |
13 #include "webkit/dom_storage/dom_storage_task_runner.h" | 13 #include "webkit/dom_storage/dom_storage_task_runner.h" |
14 #include "webkit/dom_storage/dom_storage_types.h" | 14 #include "webkit/dom_storage/dom_storage_types.h" |
15 #include "webkit/fileapi/file_system_util.h" | 15 #include "webkit/fileapi/file_system_util.h" |
16 | 16 |
17 namespace dom_storage { | 17 namespace dom_storage { |
18 | 18 |
19 // static | |
20 const FilePath::CharType DomStorageArea::kDatabaseFileExtension[] = | |
21 FILE_PATH_LITERAL(".localstorage"); | |
22 | |
23 // static | |
24 FilePath DomStorageArea::DatabaseFileNameFromOrigin(const GURL& origin) { | |
25 std::string filename = fileapi::GetOriginIdentifierFromURL(origin); | |
26 // There is no FilePath.AppendExtension() method, so start with just the | |
27 // extension as the filename, and then InsertBeforeExtension the desired | |
28 // name. | |
29 return FilePath().Append(kDatabaseFileExtension). | |
30 InsertBeforeExtensionASCII(filename); | |
31 } | |
32 | |
33 DomStorageArea::DomStorageArea( | 19 DomStorageArea::DomStorageArea( |
34 int64 namespace_id, const GURL& origin, | 20 int64 namespace_id, const GURL& origin, |
35 const FilePath& directory, DomStorageTaskRunner* task_runner) | 21 const FilePath& directory, DomStorageTaskRunner* task_runner) |
36 : namespace_id_(namespace_id), origin_(origin), | 22 : namespace_id_(namespace_id), origin_(origin), |
37 directory_(directory), | 23 directory_(directory), |
38 task_runner_(task_runner), | 24 task_runner_(task_runner), |
39 map_(new DomStorageMap(kPerAreaQuota)), | 25 map_(new DomStorageMap(kPerAreaQuota)), |
40 backing_(NULL), | 26 backing_(NULL), |
41 initial_import_done_(false), | 27 initial_import_done_(false), |
42 clear_all_next_commit_(false), | 28 clear_all_next_commit_(false), |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 157 |
172 void DomStorageArea::CommitChanges() { | 158 void DomStorageArea::CommitChanges() { |
173 DCHECK(backing_.get()); | 159 DCHECK(backing_.get()); |
174 if (backing_->CommitChanges(clear_all_next_commit_, changed_values_)) { | 160 if (backing_->CommitChanges(clear_all_next_commit_, changed_values_)) { |
175 clear_all_next_commit_ = false; | 161 clear_all_next_commit_ = false; |
176 changed_values_.clear(); | 162 changed_values_.clear(); |
177 } | 163 } |
178 commit_in_flight_ = false; | 164 commit_in_flight_ = false; |
179 } | 165 } |
180 | 166 |
| 167 // static |
| 168 FilePath DomStorageArea::DatabaseFileNameFromOrigin(const GURL& origin) { |
| 169 std::string filename = fileapi::GetOriginIdentifierFromURL(origin) |
| 170 + ".localstorage"; |
| 171 return FilePath().AppendASCII(filename); |
| 172 } |
| 173 |
181 } // namespace dom_storage | 174 } // namespace dom_storage |
OLD | NEW |