OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/top_sites.h" | 5 #include "chrome/browser/history/top_sites.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 213 } |
214 | 214 |
215 return SetPageThumbnailEncoded(url, thumbnail_data, score); | 215 return SetPageThumbnailEncoded(url, thumbnail_data, score); |
216 } | 216 } |
217 | 217 |
218 void TopSites::GetMostVisitedURLs(CancelableRequestConsumer* consumer, | 218 void TopSites::GetMostVisitedURLs(CancelableRequestConsumer* consumer, |
219 GetTopSitesCallback* callback) { | 219 GetTopSitesCallback* callback) { |
220 // WARNING: this may be invoked on any thread. | 220 // WARNING: this may be invoked on any thread. |
221 scoped_refptr<CancelableRequest<GetTopSitesCallback> > request( | 221 scoped_refptr<CancelableRequest<GetTopSitesCallback> > request( |
222 new CancelableRequest<GetTopSitesCallback>(callback)); | 222 new CancelableRequest<GetTopSitesCallback>(callback)); |
223 // This ensures cancelation of requests when either the consumer or the | 223 // This ensures cancellation of requests when either the consumer or the |
224 // provider is deleted. Deletion of requests is also guaranteed. | 224 // provider is deleted. Deletion of requests is also guaranteed. |
225 AddRequest(request, consumer); | 225 AddRequest(request, consumer); |
226 MostVisitedURLList filtered_urls; | 226 MostVisitedURLList filtered_urls; |
227 { | 227 { |
228 AutoLock lock(lock_); | 228 AutoLock lock(lock_); |
229 if (!loaded_) { | 229 if (!loaded_) { |
230 // A request came in before we finished loading. Put the request in | 230 // A request came in before we finished loading. Put the request in |
231 // pending_callbacks_ and we'll notify it when we finish loading. | 231 // pending_callbacks_ and we'll notify it when we finish loading. |
232 pending_callbacks_.insert(request); | 232 pending_callbacks_.insert(request); |
233 return; | 233 return; |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 SetTopSites(pages); | 910 SetTopSites(pages); |
911 | 911 |
912 // Used only in testing. | 912 // Used only in testing. |
913 NotificationService::current()->Notify( | 913 NotificationService::current()->Notify( |
914 NotificationType::TOP_SITES_UPDATED, | 914 NotificationType::TOP_SITES_UPDATED, |
915 Source<TopSites>(this), | 915 Source<TopSites>(this), |
916 Details<CancelableRequestProvider::Handle>(&handle)); | 916 Details<CancelableRequestProvider::Handle>(&handle)); |
917 } | 917 } |
918 | 918 |
919 } // namespace history | 919 } // namespace history |
OLD | NEW |