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 "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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 TableBuilder(VisitedLinkMaster* master, | 143 TableBuilder(VisitedLinkMaster* master, |
144 const uint8 salt[LINK_SALT_LENGTH]); | 144 const uint8 salt[LINK_SALT_LENGTH]); |
145 | 145 |
146 // Called on the main thread when the master is being destroyed. This will | 146 // Called on the main thread when the master is being destroyed. This will |
147 // prevent a crash when the query completes and the master is no longer | 147 // prevent a crash when the query completes and the master is no longer |
148 // around. We can not actually do anything but mark this fact, since the | 148 // around. We can not actually do anything but mark this fact, since the |
149 // table will be being rebuilt simultaneously on the other thread. | 149 // table will be being rebuilt simultaneously on the other thread. |
150 void DisownMaster(); | 150 void DisownMaster(); |
151 | 151 |
152 // HistoryService::URLEnumerator | 152 // HistoryService::URLEnumerator |
153 virtual void OnURL(const history::URLRow& url_row); | 153 virtual void OnURL(const GURL& url); |
154 virtual void OnComplete(bool succeed); | 154 virtual void OnComplete(bool succeed); |
155 | 155 |
156 private: | 156 private: |
157 friend class base::RefCountedThreadSafe<TableBuilder>; | 157 friend class base::RefCountedThreadSafe<TableBuilder>; |
158 | 158 |
159 ~TableBuilder() {} | 159 ~TableBuilder() {} |
160 | 160 |
161 // OnComplete mashals to this function on the main thread to do the | 161 // OnComplete mashals to this function on the main thread to do the |
162 // notification. | 162 // notification. |
163 void OnCompleteMainThread(); | 163 void OnCompleteMainThread(); |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 fingerprints_.reserve(4096); | 949 fingerprints_.reserve(4096); |
950 memcpy(salt_, salt, LINK_SALT_LENGTH * sizeof(uint8)); | 950 memcpy(salt_, salt, LINK_SALT_LENGTH * sizeof(uint8)); |
951 } | 951 } |
952 | 952 |
953 // TODO(brettw): Do we want to try to cancel the request if this happens? It | 953 // TODO(brettw): Do we want to try to cancel the request if this happens? It |
954 // could delay shutdown if there are a lot of URLs. | 954 // could delay shutdown if there are a lot of URLs. |
955 void VisitedLinkMaster::TableBuilder::DisownMaster() { | 955 void VisitedLinkMaster::TableBuilder::DisownMaster() { |
956 master_ = NULL; | 956 master_ = NULL; |
957 } | 957 } |
958 | 958 |
959 void VisitedLinkMaster::TableBuilder::OnURL(const history::URLRow& url_row) { | 959 void VisitedLinkMaster::TableBuilder::OnURL(const GURL& url) { |
960 const GURL& url((url_row.url())); | |
961 if (!url.is_empty()) { | 960 if (!url.is_empty()) { |
962 fingerprints_.push_back(VisitedLinkMaster::ComputeURLFingerprint( | 961 fingerprints_.push_back(VisitedLinkMaster::ComputeURLFingerprint( |
963 url.spec().data(), url.spec().length(), salt_)); | 962 url.spec().data(), url.spec().length(), salt_)); |
964 } | 963 } |
965 } | 964 } |
966 | 965 |
967 void VisitedLinkMaster::TableBuilder::OnComplete(bool success) { | 966 void VisitedLinkMaster::TableBuilder::OnComplete(bool success) { |
968 success_ = success; | 967 success_ = success; |
969 DLOG_IF(WARNING, !success) << "Unable to rebuild visited links"; | 968 DLOG_IF(WARNING, !success) << "Unable to rebuild visited links"; |
970 | 969 |
971 // Marshal to the main thread to notify the VisitedLinkMaster that the | 970 // Marshal to the main thread to notify the VisitedLinkMaster that the |
972 // rebuild is complete. | 971 // rebuild is complete. |
973 BrowserThread::PostTask( | 972 BrowserThread::PostTask( |
974 BrowserThread::UI, FROM_HERE, | 973 BrowserThread::UI, FROM_HERE, |
975 base::Bind(&TableBuilder::OnCompleteMainThread, this)); | 974 base::Bind(&TableBuilder::OnCompleteMainThread, this)); |
976 } | 975 } |
977 | 976 |
978 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() { | 977 void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() { |
979 if (master_) | 978 if (master_) |
980 master_->OnTableRebuildComplete(success_, fingerprints_); | 979 master_->OnTableRebuildComplete(success_, fingerprints_); |
981 | 980 |
982 // WILL (generally) DELETE THIS! This balances the AddRef in | 981 // WILL (generally) DELETE THIS! This balances the AddRef in |
983 // VisitedLinkMaster::RebuildTableFromHistory. | 982 // VisitedLinkMaster::RebuildTableFromHistory. |
984 Release(); | 983 Release(); |
985 } | 984 } |
OLD | NEW |