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_context.h" | 5 #include "webkit/dom_storage/dom_storage_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | |
11 #include "base/guid.h" | 10 #include "base/guid.h" |
12 #include "base/location.h" | 11 #include "base/location.h" |
13 #include "base/time.h" | 12 #include "base/time.h" |
14 #include "webkit/dom_storage/dom_storage_area.h" | 13 #include "webkit/dom_storage/dom_storage_area.h" |
15 #include "webkit/dom_storage/dom_storage_database.h" | 14 #include "webkit/dom_storage/dom_storage_database.h" |
16 #include "webkit/dom_storage/dom_storage_namespace.h" | 15 #include "webkit/dom_storage/dom_storage_namespace.h" |
17 #include "webkit/dom_storage/dom_storage_task_runner.h" | 16 #include "webkit/dom_storage/dom_storage_task_runner.h" |
18 #include "webkit/dom_storage/dom_storage_types.h" | 17 #include "webkit/dom_storage/dom_storage_types.h" |
19 #include "webkit/dom_storage/session_storage_database.h" | 18 #include "webkit/dom_storage/session_storage_database.h" |
20 #include "webkit/quota/special_storage_policy.h" | 19 #include "webkit/quota/special_storage_policy.h" |
21 | 20 |
| 21 using file_util::FileEnumerator; |
| 22 |
22 namespace dom_storage { | 23 namespace dom_storage { |
23 | 24 |
24 static const int kSessionStoraceScavengingSeconds = 60; | 25 static const int kSessionStoraceScavengingSeconds = 60; |
25 | 26 |
26 DomStorageContext::DomStorageContext( | 27 DomStorageContext::DomStorageContext( |
27 const base::FilePath& localstorage_directory, | 28 const base::FilePath& localstorage_directory, |
28 const base::FilePath& sessionstorage_directory, | 29 const base::FilePath& sessionstorage_directory, |
29 quota::SpecialStoragePolicy* special_storage_policy, | 30 quota::SpecialStoragePolicy* special_storage_policy, |
30 DomStorageTaskRunner* task_runner) | 31 DomStorageTaskRunner* task_runner) |
31 : localstorage_directory_(localstorage_directory), | 32 : localstorage_directory_(localstorage_directory), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return NULL; | 80 return NULL; |
80 } | 81 } |
81 return found->second; | 82 return found->second; |
82 } | 83 } |
83 | 84 |
84 void DomStorageContext::GetLocalStorageUsage( | 85 void DomStorageContext::GetLocalStorageUsage( |
85 std::vector<LocalStorageUsageInfo>* infos, | 86 std::vector<LocalStorageUsageInfo>* infos, |
86 bool include_file_info) { | 87 bool include_file_info) { |
87 if (localstorage_directory_.empty()) | 88 if (localstorage_directory_.empty()) |
88 return; | 89 return; |
89 base::FileEnumerator enumerator(localstorage_directory_, false, | 90 FileEnumerator enumerator(localstorage_directory_, false, |
90 base::FileEnumerator::FILES); | 91 FileEnumerator::FILES); |
91 for (base::FilePath path = enumerator.Next(); !path.empty(); | 92 for (base::FilePath path = enumerator.Next(); !path.empty(); |
92 path = enumerator.Next()) { | 93 path = enumerator.Next()) { |
93 if (path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)) { | 94 if (path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)) { |
94 LocalStorageUsageInfo info; | 95 LocalStorageUsageInfo info; |
95 info.origin = DomStorageArea::OriginFromDatabaseFileName(path); | 96 info.origin = DomStorageArea::OriginFromDatabaseFileName(path); |
96 if (include_file_info) { | 97 if (include_file_info) { |
97 base::FileEnumerator::FileInfo find_info = enumerator.GetInfo(); | 98 FileEnumerator::FindInfo find_info; |
98 info.data_size = find_info.GetSize(); | 99 enumerator.GetFindInfo(&find_info); |
99 info.last_modified = find_info.GetLastModifiedTime(); | 100 info.data_size = FileEnumerator::GetFilesize(find_info); |
| 101 info.last_modified = FileEnumerator::GetLastModifiedTime(find_info); |
100 } | 102 } |
101 infos->push_back(info); | 103 infos->push_back(info); |
102 } | 104 } |
103 } | 105 } |
104 } | 106 } |
105 | 107 |
106 void DomStorageContext::GetSessionStorageUsage( | 108 void DomStorageContext::GetSessionStorageUsage( |
107 std::vector<SessionStorageUsageInfo>* infos) { | 109 std::vector<SessionStorageUsageInfo>* infos) { |
108 if (!session_storage_database_.get()) | 110 if (!session_storage_database_.get()) |
109 return; | 111 return; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 if (!deletable_persistent_namespace_ids_.empty()) { | 415 if (!deletable_persistent_namespace_ids_.empty()) { |
414 task_runner_->PostDelayedTask( | 416 task_runner_->PostDelayedTask( |
415 FROM_HERE, base::Bind( | 417 FROM_HERE, base::Bind( |
416 &DomStorageContext::DeleteNextUnusedNamespace, | 418 &DomStorageContext::DeleteNextUnusedNamespace, |
417 this), | 419 this), |
418 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); | 420 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); |
419 } | 421 } |
420 } | 422 } |
421 | 423 |
422 } // namespace dom_storage | 424 } // namespace dom_storage |
OLD | NEW |