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/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 "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/md5.h" | 13 #include "base/md5.h" |
| 14 #include "base/memory/ref_counted_memory.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "chrome/browser/history/history_backend.h" | 18 #include "chrome/browser/history/history_backend.h" |
18 #include "chrome/browser/history/history_notifications.h" | 19 #include "chrome/browser/history/history_notifications.h" |
19 #include "chrome/browser/history/page_usage_data.h" | 20 #include "chrome/browser/history/page_usage_data.h" |
20 #include "chrome/browser/history/top_sites_backend.h" | 21 #include "chrome/browser/history/top_sites_backend.h" |
21 #include "chrome/browser/history/top_sites_cache.h" | 22 #include "chrome/browser/history/top_sites_cache.h" |
22 #include "chrome/browser/prefs/pref_service.h" | 23 #include "chrome/browser/prefs/pref_service.h" |
23 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 24 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 pending_callbacks_.insert(request); | 235 pending_callbacks_.insert(request); |
235 return; | 236 return; |
236 } | 237 } |
237 | 238 |
238 filtered_urls = thread_safe_cache_->top_sites(); | 239 filtered_urls = thread_safe_cache_->top_sites(); |
239 } | 240 } |
240 request->ForwardResult(filtered_urls); | 241 request->ForwardResult(filtered_urls); |
241 } | 242 } |
242 | 243 |
243 bool TopSites::GetPageThumbnail(const GURL& url, | 244 bool TopSites::GetPageThumbnail(const GURL& url, |
244 scoped_refptr<RefCountedMemory>* bytes) { | 245 scoped_refptr<base::RefCountedMemory>* bytes) { |
245 // WARNING: this may be invoked on any thread. | 246 // WARNING: this may be invoked on any thread. |
246 { | 247 { |
247 base::AutoLock lock(lock_); | 248 base::AutoLock lock(lock_); |
248 if (thread_safe_cache_->GetPageThumbnail(url, bytes)) | 249 if (thread_safe_cache_->GetPageThumbnail(url, bytes)) |
249 return true; | 250 return true; |
250 } | 251 } |
251 | 252 |
252 // Resource bundle is thread safe. | 253 // Resource bundle is thread safe. |
253 for (size_t i = 0; i < arraysize(kPrepopulatedPages); i++) { | 254 for (size_t i = 0; i < arraysize(kPrepopulatedPages); i++) { |
254 if (url.spec() == l10n_util::GetStringUTF8(kPrepopulatedPages[i].url_id)) { | 255 if (url.spec() == l10n_util::GetStringUTF8(kPrepopulatedPages[i].url_id)) { |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 SetTopSites(pages); | 896 SetTopSites(pages); |
896 | 897 |
897 // Used only in testing. | 898 // Used only in testing. |
898 content::NotificationService::current()->Notify( | 899 content::NotificationService::current()->Notify( |
899 chrome::NOTIFICATION_TOP_SITES_UPDATED, | 900 chrome::NOTIFICATION_TOP_SITES_UPDATED, |
900 content::Source<TopSites>(this), | 901 content::Source<TopSites>(this), |
901 content::Details<CancelableRequestProvider::Handle>(&handle)); | 902 content::Details<CancelableRequestProvider::Handle>(&handle)); |
902 } | 903 } |
903 | 904 |
904 } // namespace history | 905 } // namespace history |
OLD | NEW |