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

Side by Side Diff: chrome/browser/visitedlink/visitedlink_master.cc

Issue 10837244: Replace HistoryQuickProvider protobuf-based caching with an SQLite-based database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Tweak suppression. Created 8 years, 4 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
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/visitedlink/visitedlink_master.h" 5 #include "chrome/browser/visitedlink/visitedlink_master.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <io.h> 9 #include <io.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 TableBuilder(VisitedLinkMaster* master, 140 TableBuilder(VisitedLinkMaster* master,
141 const uint8 salt[LINK_SALT_LENGTH]); 141 const uint8 salt[LINK_SALT_LENGTH]);
142 142
143 // Called on the main thread when the master is being destroyed. This will 143 // Called on the main thread when the master is being destroyed. This will
144 // prevent a crash when the query completes and the master is no longer 144 // prevent a crash when the query completes and the master is no longer
145 // around. We can not actually do anything but mark this fact, since the 145 // around. We can not actually do anything but mark this fact, since the
146 // table will be being rebuilt simultaneously on the other thread. 146 // table will be being rebuilt simultaneously on the other thread.
147 void DisownMaster(); 147 void DisownMaster();
148 148
149 // HistoryService::URLEnumerator 149 // HistoryService::URLEnumerator
150 virtual void OnURL(const GURL& url); 150 virtual void OnURL(const history::URLRow& url_row);
151 virtual void OnComplete(bool succeed); 151 virtual void OnComplete(bool succeed);
152 152
153 private: 153 private:
154 friend class base::RefCountedThreadSafe<TableBuilder>; 154 friend class base::RefCountedThreadSafe<TableBuilder>;
155 155
156 ~TableBuilder() {} 156 ~TableBuilder() {}
157 157
158 // OnComplete mashals to this function on the main thread to do the 158 // OnComplete mashals to this function on the main thread to do the
159 // notification. 159 // notification.
160 void OnCompleteMainThread(); 160 void OnCompleteMainThread();
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 fingerprints_.reserve(4096); 946 fingerprints_.reserve(4096);
947 memcpy(salt_, salt, LINK_SALT_LENGTH * sizeof(uint8)); 947 memcpy(salt_, salt, LINK_SALT_LENGTH * sizeof(uint8));
948 } 948 }
949 949
950 // TODO(brettw): Do we want to try to cancel the request if this happens? It 950 // TODO(brettw): Do we want to try to cancel the request if this happens? It
951 // could delay shutdown if there are a lot of URLs. 951 // could delay shutdown if there are a lot of URLs.
952 void VisitedLinkMaster::TableBuilder::DisownMaster() { 952 void VisitedLinkMaster::TableBuilder::DisownMaster() {
953 master_ = NULL; 953 master_ = NULL;
954 } 954 }
955 955
956 void VisitedLinkMaster::TableBuilder::OnURL(const GURL& url) { 956 void VisitedLinkMaster::TableBuilder::OnURL(const history::URLRow& url_row) {
957 const GURL& url((url_row.url()));
957 if (!url.is_empty()) { 958 if (!url.is_empty()) {
958 fingerprints_.push_back(VisitedLinkMaster::ComputeURLFingerprint( 959 fingerprints_.push_back(VisitedLinkMaster::ComputeURLFingerprint(
959 url.spec().data(), url.spec().length(), salt_)); 960 url.spec().data(), url.spec().length(), salt_));
960 } 961 }
961 } 962 }
962 963
963 void VisitedLinkMaster::TableBuilder::OnComplete(bool success) { 964 void VisitedLinkMaster::TableBuilder::OnComplete(bool success) {
964 success_ = success; 965 success_ = success;
965 DLOG_IF(WARNING, !success) << "Unable to rebuild visited links"; 966 DLOG_IF(WARNING, !success) << "Unable to rebuild visited links";
966 967
967 // Marshal to the main thread to notify the VisitedLinkMaster that the 968 // Marshal to the main thread to notify the VisitedLinkMaster that the
968 // rebuild is complete. 969 // rebuild is complete.
969 BrowserThread::PostTask( 970 BrowserThread::PostTask(
970 BrowserThread::UI, FROM_HERE, 971 BrowserThread::UI, FROM_HERE,
971 base::Bind(&TableBuilder::OnCompleteMainThread, this)); 972 base::Bind(&TableBuilder::OnCompleteMainThread, this));
972 } 973 }
973 974
974 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() { 975 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() {
975 if (master_) 976 if (master_)
976 master_->OnTableRebuildComplete(success_, fingerprints_); 977 master_->OnTableRebuildComplete(success_, fingerprints_);
977 978
978 // WILL (generally) DELETE THIS! This balances the AddRef in 979 // WILL (generally) DELETE THIS! This balances the AddRef in
979 // VisitedLinkMaster::RebuildTableFromHistory. 980 // VisitedLinkMaster::RebuildTableFromHistory.
980 Release(); 981 Release();
981 } 982 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698