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

Side by Side Diff: webkit/dom_storage/dom_storage_context.cc

Issue 13165005: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge, fixes Created 7 years, 7 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
« no previous file with comments | « webkit/database/database_tracker.cc ('k') | webkit/fileapi/file_system_database_test_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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"
10 #include "base/guid.h" 11 #include "base/guid.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "webkit/dom_storage/dom_storage_area.h" 14 #include "webkit/dom_storage/dom_storage_area.h"
14 #include "webkit/dom_storage/dom_storage_database.h" 15 #include "webkit/dom_storage/dom_storage_database.h"
15 #include "webkit/dom_storage/dom_storage_namespace.h" 16 #include "webkit/dom_storage/dom_storage_namespace.h"
16 #include "webkit/dom_storage/dom_storage_task_runner.h" 17 #include "webkit/dom_storage/dom_storage_task_runner.h"
17 #include "webkit/dom_storage/dom_storage_types.h" 18 #include "webkit/dom_storage/dom_storage_types.h"
18 #include "webkit/dom_storage/session_storage_database.h" 19 #include "webkit/dom_storage/session_storage_database.h"
19 #include "webkit/quota/special_storage_policy.h" 20 #include "webkit/quota/special_storage_policy.h"
20 21
21 using file_util::FileEnumerator;
22
23 namespace dom_storage { 22 namespace dom_storage {
24 23
25 static const int kSessionStoraceScavengingSeconds = 60; 24 static const int kSessionStoraceScavengingSeconds = 60;
26 25
27 DomStorageContext::DomStorageContext( 26 DomStorageContext::DomStorageContext(
28 const base::FilePath& localstorage_directory, 27 const base::FilePath& localstorage_directory,
29 const base::FilePath& sessionstorage_directory, 28 const base::FilePath& sessionstorage_directory,
30 quota::SpecialStoragePolicy* special_storage_policy, 29 quota::SpecialStoragePolicy* special_storage_policy,
31 DomStorageTaskRunner* task_runner) 30 DomStorageTaskRunner* task_runner)
32 : localstorage_directory_(localstorage_directory), 31 : localstorage_directory_(localstorage_directory),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return NULL; 79 return NULL;
81 } 80 }
82 return found->second; 81 return found->second;
83 } 82 }
84 83
85 void DomStorageContext::GetLocalStorageUsage( 84 void DomStorageContext::GetLocalStorageUsage(
86 std::vector<LocalStorageUsageInfo>* infos, 85 std::vector<LocalStorageUsageInfo>* infos,
87 bool include_file_info) { 86 bool include_file_info) {
88 if (localstorage_directory_.empty()) 87 if (localstorage_directory_.empty())
89 return; 88 return;
90 FileEnumerator enumerator(localstorage_directory_, false, 89 base::FileEnumerator enumerator(localstorage_directory_, false,
91 FileEnumerator::FILES); 90 base::FileEnumerator::FILES);
92 for (base::FilePath path = enumerator.Next(); !path.empty(); 91 for (base::FilePath path = enumerator.Next(); !path.empty();
93 path = enumerator.Next()) { 92 path = enumerator.Next()) {
94 if (path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)) { 93 if (path.MatchesExtension(DomStorageArea::kDatabaseFileExtension)) {
95 LocalStorageUsageInfo info; 94 LocalStorageUsageInfo info;
96 info.origin = DomStorageArea::OriginFromDatabaseFileName(path); 95 info.origin = DomStorageArea::OriginFromDatabaseFileName(path);
97 if (include_file_info) { 96 if (include_file_info) {
98 FileEnumerator::FindInfo find_info; 97 base::FileEnumerator::FileInfo find_info = enumerator.GetInfo();
99 enumerator.GetFindInfo(&find_info); 98 info.data_size = find_info.GetSize();
100 info.data_size = FileEnumerator::GetFilesize(find_info); 99 info.last_modified = find_info.GetLastModifiedTime();
101 info.last_modified = FileEnumerator::GetLastModifiedTime(find_info);
102 } 100 }
103 infos->push_back(info); 101 infos->push_back(info);
104 } 102 }
105 } 103 }
106 } 104 }
107 105
108 void DomStorageContext::GetSessionStorageUsage( 106 void DomStorageContext::GetSessionStorageUsage(
109 std::vector<SessionStorageUsageInfo>* infos) { 107 std::vector<SessionStorageUsageInfo>* infos) {
110 if (!session_storage_database_.get()) 108 if (!session_storage_database_.get())
111 return; 109 return;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 if (!deletable_persistent_namespace_ids_.empty()) { 413 if (!deletable_persistent_namespace_ids_.empty()) {
416 task_runner_->PostDelayedTask( 414 task_runner_->PostDelayedTask(
417 FROM_HERE, base::Bind( 415 FROM_HERE, base::Bind(
418 &DomStorageContext::DeleteNextUnusedNamespace, 416 &DomStorageContext::DeleteNextUnusedNamespace,
419 this), 417 this),
420 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds)); 418 base::TimeDelta::FromSeconds(kSessionStoraceScavengingSeconds));
421 } 419 }
422 } 420 }
423 421
424 } // namespace dom_storage 422 } // namespace dom_storage
OLDNEW
« no previous file with comments | « webkit/database/database_tracker.cc ('k') | webkit/fileapi/file_system_database_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698