| 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 |
| 19 DomStorageArea::DomStorageArea( | 33 DomStorageArea::DomStorageArea( |
| 20 int64 namespace_id, const GURL& origin, | 34 int64 namespace_id, const GURL& origin, |
| 21 const FilePath& directory, DomStorageTaskRunner* task_runner) | 35 const FilePath& directory, DomStorageTaskRunner* task_runner) |
| 22 : namespace_id_(namespace_id), origin_(origin), | 36 : namespace_id_(namespace_id), origin_(origin), |
| 23 directory_(directory), | 37 directory_(directory), |
| 24 task_runner_(task_runner), | 38 task_runner_(task_runner), |
| 25 map_(new DomStorageMap(kPerAreaQuota)), | 39 map_(new DomStorageMap(kPerAreaQuota)), |
| 26 backing_(NULL), | 40 backing_(NULL), |
| 27 initial_import_done_(false), | 41 initial_import_done_(false), |
| 28 clear_all_next_commit_(false), | 42 clear_all_next_commit_(false), |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 171 |
| 158 void DomStorageArea::CommitChanges() { | 172 void DomStorageArea::CommitChanges() { |
| 159 DCHECK(backing_.get()); | 173 DCHECK(backing_.get()); |
| 160 if (backing_->CommitChanges(clear_all_next_commit_, changed_values_)) { | 174 if (backing_->CommitChanges(clear_all_next_commit_, changed_values_)) { |
| 161 clear_all_next_commit_ = false; | 175 clear_all_next_commit_ = false; |
| 162 changed_values_.clear(); | 176 changed_values_.clear(); |
| 163 } | 177 } |
| 164 commit_in_flight_ = false; | 178 commit_in_flight_ = false; |
| 165 } | 179 } |
| 166 | 180 |
| 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 | |
| 174 } // namespace dom_storage | 181 } // namespace dom_storage |
| OLD | NEW |