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 "components/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/history_backend.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 data.reserve(score_map.size()); | 1360 data.reserve(score_map.size()); |
1361 for (std::map<URLID, double>::iterator it = score_map.begin(); | 1361 for (std::map<URLID, double>::iterator it = score_map.begin(); |
1362 it != score_map.end(); ++it) { | 1362 it != score_map.end(); ++it) { |
1363 PageUsageData* pud = new PageUsageData(it->first); | 1363 PageUsageData* pud = new PageUsageData(it->first); |
1364 pud->SetScore(it->second); | 1364 pud->SetScore(it->second); |
1365 data.push_back(pud); | 1365 data.push_back(pud); |
1366 } | 1366 } |
1367 | 1367 |
1368 // Limit to the top |result_count| results. | 1368 // Limit to the top |result_count| results. |
1369 std::sort(data.begin(), data.end(), PageUsageData::Predicate); | 1369 std::sort(data.begin(), data.end(), PageUsageData::Predicate); |
1370 if (result_count && implicit_cast<int>(data.size()) > result_count) | 1370 DCHECK_GE(result_count, 0); |
| 1371 if (result_count && data.size() > static_cast<size_t>(result_count)) |
1371 data.resize(result_count); | 1372 data.resize(result_count); |
1372 | 1373 |
1373 for (size_t i = 0; i < data.size(); ++i) { | 1374 for (size_t i = 0; i < data.size(); ++i) { |
1374 URLRow info; | 1375 URLRow info; |
1375 if (db_->GetURLRow(data[i]->GetID(), &info)) { | 1376 if (db_->GetURLRow(data[i]->GetID(), &info)) { |
1376 data[i]->SetURL(info.url()); | 1377 data[i]->SetURL(info.url()); |
1377 data[i]->SetTitle(info.title()); | 1378 data[i]->SetTitle(info.title()); |
1378 } | 1379 } |
1379 } | 1380 } |
1380 | 1381 |
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2697 // transaction is currently open. | 2698 // transaction is currently open. |
2698 db_->CommitTransaction(); | 2699 db_->CommitTransaction(); |
2699 db_->Vacuum(); | 2700 db_->Vacuum(); |
2700 db_->BeginTransaction(); | 2701 db_->BeginTransaction(); |
2701 db_->GetStartDate(&first_recorded_time_); | 2702 db_->GetStartDate(&first_recorded_time_); |
2702 | 2703 |
2703 return true; | 2704 return true; |
2704 } | 2705 } |
2705 | 2706 |
2706 } // namespace history | 2707 } // namespace history |
OLD | NEW |