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

Side by Side Diff: chrome/browser/history/history_backend.cc

Issue 10115001: Added page score to the ntp suggestions tab. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comment Created 8 years, 8 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
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 "chrome/browser/history/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 request->ForwardResult(request->handle(), MostVisitedURLList()); 1424 request->ForwardResult(request->handle(), MostVisitedURLList());
1425 return; 1425 return;
1426 } 1426 }
1427 1427
1428 MostVisitedURLList* result = &request->value; 1428 MostVisitedURLList* result = &request->value;
1429 QueryMostVisitedURLsImpl(result_count, days_back, result); 1429 QueryMostVisitedURLsImpl(result_count, days_back, result);
1430 request->ForwardResult(request->handle(), *result); 1430 request->ForwardResult(request->handle(), *result);
1431 } 1431 }
1432 1432
1433 void HistoryBackend::QueryFilteredURLs( 1433 void HistoryBackend::QueryFilteredURLs(
1434 scoped_refptr<QueryMostVisitedURLsRequest> request, 1434 scoped_refptr<QueryFilteredURLsRequest> request,
1435 int result_count, 1435 int result_count,
1436 const history::VisitFilter& filter) { 1436 const history::VisitFilter& filter) {
1437 if (request->canceled()) 1437 if (request->canceled())
1438 return; 1438 return;
1439 1439
1440 base::Time request_start = base::Time::Now(); 1440 base::Time request_start = base::Time::Now();
1441 1441
1442 if (!db_.get()) { 1442 if (!db_.get()) {
1443 // No History Database - return an empty list. 1443 // No History Database - return an empty list.
1444 request->ForwardResult(request->handle(), MostVisitedURLList()); 1444 request->ForwardResult(request->handle(),FilteredURLList());
1445 return; 1445 return;
1446 } 1446 }
1447 1447
1448 VisitVector visits; 1448 VisitVector visits;
1449 db_->GetVisibleVisitsDuringTimes(filter, 0, &visits); 1449 db_->GetVisibleVisitsDuringTimes(filter, 0, &visits);
1450 1450
1451 std::map<VisitID, std::pair<VisitID, URLID> > segment_ids; 1451 std::map<VisitID, std::pair<VisitID, URLID> > segment_ids;
1452 for (size_t i = 0; i < visits.size(); ++i) { 1452 for (size_t i = 0; i < visits.size(); ++i) {
1453 segment_ids[visits[i].visit_id] = 1453 segment_ids[visits[i].visit_id] =
1454 std::make_pair(visits[i].referring_visit, visits[i].segment_id); 1454 std::make_pair(visits[i].referring_visit, visits[i].segment_id);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 // Get URL data. 1524 // Get URL data.
1525 for (size_t i = 0; i < data.size(); ++i) { 1525 for (size_t i = 0; i < data.size(); ++i) {
1526 URLID url_id = db_->GetSegmentRepresentationURL(data[i]->GetID()); 1526 URLID url_id = db_->GetSegmentRepresentationURL(data[i]->GetID());
1527 URLRow info; 1527 URLRow info;
1528 if (db_->GetURLRow(url_id, &info)) { 1528 if (db_->GetURLRow(url_id, &info)) {
1529 data[i]->SetURL(info.url()); 1529 data[i]->SetURL(info.url());
1530 data[i]->SetTitle(info.title()); 1530 data[i]->SetTitle(info.title());
1531 } 1531 }
1532 } 1532 }
1533 1533
1534 MostVisitedURLList& result = request->value; 1534 FilteredURLList& result = request->value;
1535 for (size_t i = 0; i < data.size(); ++i) { 1535 for (size_t i = 0; i < data.size(); ++i) {
1536 PageUsageData* current_data = data[i]; 1536 PageUsageData* current_data = data[i];
1537 RedirectList redirects; 1537 FilteredURL url(*current_data);
1538 GetMostRecentRedirectsFrom(current_data->GetURL(), &redirects);
1539 MostVisitedURL url = MakeMostVisitedURL(*current_data, redirects);
1540 result.push_back(url); 1538 result.push_back(url);
1541 } 1539 }
1542 1540
1543 int delta_time = std::max(1, std::min(999, 1541 int delta_time = std::max(1, std::min(999,
1544 static_cast<int>((base::Time::Now() - request_start).InMilliseconds()))); 1542 static_cast<int>((base::Time::Now() - request_start).InMilliseconds())));
1545 STATIC_HISTOGRAM_POINTER_BLOCK( 1543 STATIC_HISTOGRAM_POINTER_BLOCK(
1546 "NewTabPage.SuggestedSitesLoadTime", 1544 "NewTabPage.SuggestedSitesLoadTime",
1547 Add(delta_time), 1545 Add(delta_time),
1548 base::LinearHistogram::FactoryGet("NewTabPage.SuggestedSitesLoadTime", 1546 base::LinearHistogram::FactoryGet("NewTabPage.SuggestedSitesLoadTime",
1549 1, 1000, 100, base::Histogram::kUmaTargetedHistogramFlag)); 1547 1, 1000, 100, base::Histogram::kUmaTargetedHistogramFlag));
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 info.url_id = visit.url_id; 2482 info.url_id = visit.url_id;
2485 info.time = visit.visit_time; 2483 info.time = visit.visit_time;
2486 info.transition = visit.transition; 2484 info.transition = visit.transition;
2487 // If we don't have a delegate yet during setup or shutdown, we will drop 2485 // If we don't have a delegate yet during setup or shutdown, we will drop
2488 // these notifications. 2486 // these notifications.
2489 if (delegate_.get()) 2487 if (delegate_.get())
2490 delegate_->NotifyVisitDBObserversOnAddVisit(info); 2488 delegate_->NotifyVisitDBObserversOnAddVisit(info);
2491 } 2489 }
2492 2490
2493 } // namespace history 2491 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698