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 "chrome/browser/history/text_database_manager.h" | 5 #include "chrome/browser/history/text_database_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/files/file_enumerator.h" | |
14 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
15 #include "base/logging.h" | 14 #include "base/logging.h" |
16 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
17 #include "base/string_util.h" | 16 #include "base/string_util.h" |
18 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
19 #include "chrome/browser/history/history_publisher.h" | 18 #include "chrome/browser/history/history_publisher.h" |
20 #include "chrome/browser/history/visit_database.h" | 19 #include "chrome/browser/history/visit_database.h" |
21 | 20 |
22 using base::Time; | 21 using base::Time; |
23 using base::TimeDelta; | 22 using base::TimeDelta; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 153 |
155 void TextDatabaseManager::InitDBList() { | 154 void TextDatabaseManager::InitDBList() { |
156 if (present_databases_loaded_) | 155 if (present_databases_loaded_) |
157 return; | 156 return; |
158 | 157 |
159 present_databases_loaded_ = true; | 158 present_databases_loaded_ = true; |
160 | 159 |
161 // Find files on disk matching our pattern so we can quickly test for them. | 160 // Find files on disk matching our pattern so we can quickly test for them. |
162 base::FilePath::StringType filepattern(TextDatabase::file_base()); | 161 base::FilePath::StringType filepattern(TextDatabase::file_base()); |
163 filepattern.append(FILE_PATH_LITERAL("*")); | 162 filepattern.append(FILE_PATH_LITERAL("*")); |
164 base::FileEnumerator enumerator( | 163 file_util::FileEnumerator enumerator( |
165 dir_, false, base::FileEnumerator::FILES, filepattern); | 164 dir_, false, file_util::FileEnumerator::FILES, filepattern); |
166 base::FilePath cur_file; | 165 base::FilePath cur_file; |
167 while (!(cur_file = enumerator.Next()).empty()) { | 166 while (!(cur_file = enumerator.Next()).empty()) { |
168 // Convert to the number representing this file. | 167 // Convert to the number representing this file. |
169 TextDatabase::DBIdent id = TextDatabase::FileNameToID(cur_file); | 168 TextDatabase::DBIdent id = TextDatabase::FileNameToID(cur_file); |
170 if (id) // Will be 0 on error. | 169 if (id) // Will be 0 on error. |
171 present_databases_.insert(id); | 170 present_databases_.insert(id); |
172 } | 171 } |
173 } | 172 } |
174 | 173 |
175 void TextDatabaseManager::AddPageURL(const GURL& url, | 174 void TextDatabaseManager::AddPageURL(const GURL& url, |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 while (i != recent_changes_.rend() && i->second.Expired(now)) { | 577 while (i != recent_changes_.rend() && i->second.Expired(now)) { |
579 AddPageData(i->first, i->second.url_id(), i->second.visit_id(), | 578 AddPageData(i->first, i->second.url_id(), i->second.visit_id(), |
580 i->second.visit_time(), i->second.title(), i->second.body()); | 579 i->second.visit_time(), i->second.title(), i->second.body()); |
581 i = recent_changes_.Erase(i); | 580 i = recent_changes_.Erase(i); |
582 } | 581 } |
583 | 582 |
584 ScheduleFlushOldChanges(); | 583 ScheduleFlushOldChanges(); |
585 } | 584 } |
586 | 585 |
587 } // namespace history | 586 } // namespace history |
OLD | NEW |