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

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

Issue 336633004: Code cleanup in HistoryService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 5 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 | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_marshaling.h » ('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 "chrome/browser/history/history_backend.h" 5 #include "chrome/browser/history/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 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 const GURL& url) { 1325 const GURL& url) {
1326 if (request->canceled()) 1326 if (request->canceled())
1327 return; 1327 return;
1328 int count = 0; 1328 int count = 0;
1329 Time first_visit; 1329 Time first_visit;
1330 const bool success = db_.get() && 1330 const bool success = db_.get() &&
1331 db_->GetVisibleVisitCountToHost(url, &count, &first_visit); 1331 db_->GetVisibleVisitCountToHost(url, &count, &first_visit);
1332 request->ForwardResult(request->handle(), success, count, first_visit); 1332 request->ForwardResult(request->handle(), success, count, first_visit);
1333 } 1333 }
1334 1334
1335 void HistoryBackend::QueryTopURLsAndRedirects(
1336 scoped_refptr<QueryTopURLsAndRedirectsRequest> request,
1337 int result_count) {
1338 if (request->canceled())
1339 return;
1340
1341 if (!db_) {
1342 request->ForwardResult(request->handle(), false, NULL, NULL);
1343 return;
1344 }
1345
1346 std::vector<GURL>* top_urls = &request->value.a;
1347 history::RedirectMap* redirects = &request->value.b;
1348
1349 ScopedVector<PageUsageData> data;
1350 db_->QuerySegmentUsage(base::Time::Now() - base::TimeDelta::FromDays(90),
1351 result_count, &data.get());
1352
1353 for (size_t i = 0; i < data.size(); ++i) {
1354 top_urls->push_back(data[i]->GetURL());
1355 RefCountedVector<GURL>* list = new RefCountedVector<GURL>;
1356 QueryRedirectsFrom(top_urls->back(), &list->data);
1357 (*redirects)[top_urls->back()] = list;
1358 }
1359
1360 request->ForwardResult(request->handle(), true, top_urls, redirects);
1361 }
1362
1363 // Will replace QueryTopURLsAndRedirectsRequest.
1364 void HistoryBackend::QueryMostVisitedURLs( 1335 void HistoryBackend::QueryMostVisitedURLs(
1365 scoped_refptr<QueryMostVisitedURLsRequest> request, 1336 scoped_refptr<QueryMostVisitedURLsRequest> request,
1366 int result_count, 1337 int result_count,
1367 int days_back) { 1338 int days_back) {
1368 if (request->canceled()) 1339 if (request->canceled())
1369 return; 1340 return;
1370 1341
1371 if (!db_) { 1342 if (!db_) {
1372 // No History Database - return an empty list. 1343 // No History Database - return an empty list.
1373 request->ForwardResult(request->handle(), MostVisitedURLList()); 1344 request->ForwardResult(request->handle(), MostVisitedURLList());
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2813 int rank = kPageVisitStatsMaxTopSites; 2784 int rank = kPageVisitStatsMaxTopSites;
2814 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); 2785 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url);
2815 if (it != most_visited_urls_map_.end()) 2786 if (it != most_visited_urls_map_.end())
2816 rank = (*it).second; 2787 rank = (*it).second;
2817 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", 2788 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank",
2818 rank, kPageVisitStatsMaxTopSites + 1); 2789 rank, kPageVisitStatsMaxTopSites + 1);
2819 } 2790 }
2820 #endif 2791 #endif
2821 2792
2822 } // namespace history 2793 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_marshaling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698