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

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

Issue 314293005: Change HistoryService::QueryURL to use CancelableTaskTracker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 6 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 <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 146
147 private: 147 private:
148 friend class base::RefCounted<CommitLaterTask>; 148 friend class base::RefCounted<CommitLaterTask>;
149 149
150 ~CommitLaterTask() {} 150 ~CommitLaterTask() {}
151 151
152 scoped_refptr<HistoryBackend> history_backend_; 152 scoped_refptr<HistoryBackend> history_backend_;
153 }; 153 };
154 154
155 // HistoryBackend::QueryURLResult ----------------------------------------------
156
157 HistoryBackend::QueryURLResult::QueryURLResult() : success(false) {
158 }
159
160 HistoryBackend::QueryURLResult::~QueryURLResult() {
161 }
162
155 // HistoryBackend -------------------------------------------------------------- 163 // HistoryBackend --------------------------------------------------------------
156 164
157 HistoryBackend::HistoryBackend(const base::FilePath& history_dir, 165 HistoryBackend::HistoryBackend(const base::FilePath& history_dir,
158 Delegate* delegate, 166 Delegate* delegate,
159 HistoryClient* history_client) 167 HistoryClient* history_client)
160 : delegate_(delegate), 168 : delegate_(delegate),
161 history_dir_(history_dir), 169 history_dir_(history_dir),
162 scheduled_kill_db_(false), 170 scheduled_kill_db_(false),
163 expirer_(this, history_client), 171 expirer_(this, history_client),
164 recent_redirects_(kMaxRedirectCount), 172 recent_redirects_(kMaxRedirectCount),
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 db_->GetVisitsSource(visits, sources); 991 db_->GetVisitsSource(visits, sources);
984 return true; 992 return true;
985 } 993 }
986 994
987 bool HistoryBackend::GetURL(const GURL& url, history::URLRow* url_row) { 995 bool HistoryBackend::GetURL(const GURL& url, history::URLRow* url_row) {
988 if (db_) 996 if (db_)
989 return db_->GetRowForURL(url, url_row) != 0; 997 return db_->GetRowForURL(url, url_row) != 0;
990 return false; 998 return false;
991 } 999 }
992 1000
993 void HistoryBackend::QueryURL(scoped_refptr<QueryURLRequest> request, 1001 HistoryBackend::QueryURLResult HistoryBackend::QueryURL(const GURL& url,
994 const GURL& url, 1002 bool want_visits) {
995 bool want_visits) { 1003 QueryURLResult result;
996 if (request->canceled()) 1004 result.success = db_ && db_->GetRowForURL(url, &result.row);
997 return; 1005 // Optionally query the visits.
998 1006 if (result.success && want_visits) {
999 bool success = false; 1007 db_->GetVisitsForURL(result.row.id(), &result.visits);
1000 URLRow* row = &request->value.a;
1001 VisitVector* visits = &request->value.b;
1002 if (db_) {
1003 if (db_->GetRowForURL(url, row)) {
1004 // Have a row.
1005 success = true;
1006
1007 // Optionally query the visits.
1008 if (want_visits)
1009 db_->GetVisitsForURL(row->id(), visits);
1010 }
1011 } 1008 }
1012 request->ForwardResult(request->handle(), success, row, visits); 1009 return result;
1013 } 1010 }
1014 1011
1015 TypedUrlSyncableService* HistoryBackend::GetTypedUrlSyncableService() const { 1012 TypedUrlSyncableService* HistoryBackend::GetTypedUrlSyncableService() const {
1016 return typed_url_syncable_service_.get(); 1013 return typed_url_syncable_service_.get();
1017 } 1014 }
1018 1015
1019 // Segment usage --------------------------------------------------------------- 1016 // Segment usage ---------------------------------------------------------------
1020 1017
1021 void HistoryBackend::DeleteOldSegmentData() { 1018 void HistoryBackend::DeleteOldSegmentData() {
1022 if (db_) 1019 if (db_)
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 int rank = kPageVisitStatsMaxTopSites; 2845 int rank = kPageVisitStatsMaxTopSites;
2849 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); 2846 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url);
2850 if (it != most_visited_urls_map_.end()) 2847 if (it != most_visited_urls_map_.end())
2851 rank = (*it).second; 2848 rank = (*it).second;
2852 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", 2849 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank",
2853 rank, kPageVisitStatsMaxTopSites + 1); 2850 rank, kPageVisitStatsMaxTopSites + 1);
2854 } 2851 }
2855 #endif 2852 #endif
2856 2853
2857 } // namespace history 2854 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698