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/url_index_private_data.h" | 5 #include "chrome/browser/history/url_index_private_data.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <limits> | 9 #include <limits> |
10 #include <numeric> | 10 #include <numeric> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 URLID url_id) | 111 URLID url_id) |
112 : private_data_(private_data), | 112 : private_data_(private_data), |
113 url_id_(url_id), | 113 url_id_(url_id), |
114 succeeded_(false) { | 114 succeeded_(false) { |
115 } | 115 } |
116 | 116 |
117 bool UpdateRecentVisitsFromHistoryDBTask::RunOnDBThread( | 117 bool UpdateRecentVisitsFromHistoryDBTask::RunOnDBThread( |
118 HistoryBackend* backend, | 118 HistoryBackend* backend, |
119 HistoryDatabase* db) { | 119 HistoryDatabase* db) { |
120 // Make sure the private data is going to get as many recent visits as | 120 // Make sure the private data is going to get as many recent visits as |
121 // ScoredHistoryMatch::GetFrecency() hopes to use. | 121 // ScoredHistoryMatch::GetFrequency() hopes to use. |
122 DCHECK_GE(kMaxVisitsToStoreInCache, ScoredHistoryMatch::kMaxVisitsToScore); | 122 DCHECK_GE(kMaxVisitsToStoreInCache, ScoredHistoryMatch::kMaxVisitsToScore); |
123 succeeded_ = db->GetMostRecentVisitsForURL(url_id_, | 123 succeeded_ = db->GetMostRecentVisitsForURL(url_id_, |
124 kMaxVisitsToStoreInCache, | 124 kMaxVisitsToStoreInCache, |
125 &recent_visits_); | 125 &recent_visits_); |
126 if (!succeeded_) | 126 if (!succeeded_) |
127 recent_visits_.clear(); | 127 recent_visits_.clear(); |
128 return true; // Always claim to be done; do not retry failures. | 128 return true; // Always claim to be done; do not retry failures. |
129 } | 129 } |
130 | 130 |
131 void UpdateRecentVisitsFromHistoryDBTask::DoneRunOnMainThread() { | 131 void UpdateRecentVisitsFromHistoryDBTask::DoneRunOnMainThread() { |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 data_copy->word_id_history_map_ = word_id_history_map_; | 482 data_copy->word_id_history_map_ = word_id_history_map_; |
483 data_copy->history_id_word_map_ = history_id_word_map_; | 483 data_copy->history_id_word_map_ = history_id_word_map_; |
484 data_copy->history_info_map_ = history_info_map_; | 484 data_copy->history_info_map_ = history_info_map_; |
485 data_copy->word_starts_map_ = word_starts_map_; | 485 data_copy->word_starts_map_ = word_starts_map_; |
486 return data_copy; | 486 return data_copy; |
487 // Not copied: | 487 // Not copied: |
488 // search_term_cache_ | 488 // search_term_cache_ |
489 // pre_filter_item_count_ | 489 // pre_filter_item_count_ |
490 // post_filter_item_count_ | 490 // post_filter_item_count_ |
491 // post_scoring_item_count_ | 491 // post_scoring_item_count_ |
492 }; | 492 } |
493 | 493 |
494 bool URLIndexPrivateData::Empty() const { | 494 bool URLIndexPrivateData::Empty() const { |
495 return history_info_map_.empty(); | 495 return history_info_map_.empty(); |
496 } | 496 } |
497 | 497 |
498 void URLIndexPrivateData::Clear() { | 498 void URLIndexPrivateData::Clear() { |
499 last_time_rebuilt_from_history_ = base::Time(); | 499 last_time_rebuilt_from_history_ = base::Time(); |
500 word_list_.clear(); | 500 word_list_.clear(); |
501 available_words_.clear(); | 501 available_words_.clear(); |
502 word_map_.clear(); | 502 word_map_.clear(); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 word_starts_map_[history_id] = word_starts; | 716 word_starts_map_[history_id] = word_starts; |
717 | 717 |
718 // Update the recent visits information or schedule the update | 718 // Update the recent visits information or schedule the update |
719 // as appropriate. | 719 // as appropriate. |
720 if (history_db) { | 720 if (history_db) { |
721 // We'd like to check that we're on the history DB thread. | 721 // We'd like to check that we're on the history DB thread. |
722 // However, unittest code actually calls this on the UI thread. | 722 // However, unittest code actually calls this on the UI thread. |
723 // So we don't do any thread checks. | 723 // So we don't do any thread checks. |
724 VisitVector recent_visits; | 724 VisitVector recent_visits; |
725 // Make sure the private data is going to get as many recent visits as | 725 // Make sure the private data is going to get as many recent visits as |
726 // ScoredHistoryMatch::GetFrecency() hopes to use. | 726 // ScoredHistoryMatch::GetFrequency() hopes to use. |
727 DCHECK_GE(kMaxVisitsToStoreInCache, ScoredHistoryMatch::kMaxVisitsToScore); | 727 DCHECK_GE(kMaxVisitsToStoreInCache, ScoredHistoryMatch::kMaxVisitsToScore); |
728 if (history_db->GetMostRecentVisitsForURL(row_id, | 728 if (history_db->GetMostRecentVisitsForURL(row_id, |
729 kMaxVisitsToStoreInCache, | 729 kMaxVisitsToStoreInCache, |
730 &recent_visits)) | 730 &recent_visits)) |
731 UpdateRecentVisits(row_id, recent_visits); | 731 UpdateRecentVisits(row_id, recent_visits); |
732 } else { | 732 } else { |
733 DCHECK(history_service); | 733 DCHECK(history_service); |
734 ScheduleUpdateRecentVisits(history_service, row_id); | 734 ScheduleUpdateRecentVisits(history_service, row_id); |
735 } | 735 } |
736 | 736 |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 // recently visited (within the last 12/24 hours) as highly important. Get | 1337 // recently visited (within the last 12/24 hours) as highly important. Get |
1338 // input from mpearson. | 1338 // input from mpearson. |
1339 if (r1.typed_count() != r2.typed_count()) | 1339 if (r1.typed_count() != r2.typed_count()) |
1340 return (r1.typed_count() > r2.typed_count()); | 1340 return (r1.typed_count() > r2.typed_count()); |
1341 if (r1.visit_count() != r2.visit_count()) | 1341 if (r1.visit_count() != r2.visit_count()) |
1342 return (r1.visit_count() > r2.visit_count()); | 1342 return (r1.visit_count() > r2.visit_count()); |
1343 return (r1.last_visit() > r2.last_visit()); | 1343 return (r1.last_visit() > r2.last_visit()); |
1344 } | 1344 } |
1345 | 1345 |
1346 } // namespace history | 1346 } // namespace history |
OLD | NEW |