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" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 result_count_(result_count) { | 114 result_count_(result_count) { |
115 // l10n_util isn't thread safe, so cache for use on the db thread. | 115 // l10n_util isn't thread safe, so cache for use on the db thread. |
116 ignore_urls_.insert(l10n_util::GetStringUTF8(IDS_CHROME_WELCOME_URL)); | 116 ignore_urls_.insert(l10n_util::GetStringUTF8(IDS_CHROME_WELCOME_URL)); |
117 ignore_urls_.insert(l10n_util::GetStringUTF8(IDS_WEBSTORE_URL)); | 117 ignore_urls_.insert(l10n_util::GetStringUTF8(IDS_WEBSTORE_URL)); |
118 #if defined(OS_ANDROID) | 118 #if defined(OS_ANDROID) |
119 ignore_urls_.insert(l10n_util::GetStringUTF8(IDS_MOBILE_WELCOME_URL)); | 119 ignore_urls_.insert(l10n_util::GetStringUTF8(IDS_MOBILE_WELCOME_URL)); |
120 #endif | 120 #endif |
121 } | 121 } |
122 | 122 |
123 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 123 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
124 history::HistoryDatabase* db) { | 124 history::HistoryDatabase* db) OVERRIDE { |
125 // Get the most visited urls. | 125 // Get the most visited urls. |
126 backend->QueryMostVisitedURLsImpl(result_count_, | 126 backend->QueryMostVisitedURLsImpl(result_count_, |
127 kDaysOfHistory, | 127 kDaysOfHistory, |
128 &data_.most_visited); | 128 &data_.most_visited); |
129 | 129 |
130 // And fetch the thumbnails. | 130 // And fetch the thumbnails. |
131 for (size_t i = 0; i < data_.most_visited.size(); ++i) { | 131 for (size_t i = 0; i < data_.most_visited.size(); ++i) { |
132 const GURL& url = data_.most_visited[i].url; | 132 const GURL& url = data_.most_visited[i].url; |
133 if (ShouldFetchThumbnailFor(url)) { | 133 if (ShouldFetchThumbnailFor(url)) { |
134 scoped_refptr<base::RefCountedBytes> data; | 134 scoped_refptr<base::RefCountedBytes> data; |
135 backend->GetPageThumbnailDirectly(url, &data); | 135 backend->GetPageThumbnailDirectly(url, &data); |
136 data_.url_to_thumbnail_map[url] = data; | 136 data_.url_to_thumbnail_map[url] = data; |
137 } | 137 } |
138 } | 138 } |
139 return true; | 139 return true; |
140 } | 140 } |
141 | 141 |
142 virtual void DoneRunOnMainThread() { | 142 virtual void DoneRunOnMainThread() OVERRIDE { |
143 top_sites_->FinishHistoryMigration(data_); | 143 top_sites_->FinishHistoryMigration(data_); |
144 } | 144 } |
145 | 145 |
146 private: | 146 private: |
147 virtual ~LoadThumbnailsFromHistoryTask() {} | 147 virtual ~LoadThumbnailsFromHistoryTask() {} |
148 | 148 |
149 bool ShouldFetchThumbnailFor(const GURL& url) { | 149 bool ShouldFetchThumbnailFor(const GURL& url) { |
150 return ignore_urls_.find(url.spec()) == ignore_urls_.end(); | 150 return ignore_urls_.find(url.spec()) == ignore_urls_.end(); |
151 } | 151 } |
152 | 152 |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 SetTopSites(pages); | 914 SetTopSites(pages); |
915 | 915 |
916 // Used only in testing. | 916 // Used only in testing. |
917 content::NotificationService::current()->Notify( | 917 content::NotificationService::current()->Notify( |
918 chrome::NOTIFICATION_TOP_SITES_UPDATED, | 918 chrome::NOTIFICATION_TOP_SITES_UPDATED, |
919 content::Source<TopSites>(this), | 919 content::Source<TopSites>(this), |
920 content::Details<CancelableRequestProvider::Handle>(&handle)); | 920 content::Details<CancelableRequestProvider::Handle>(&handle)); |
921 } | 921 } |
922 | 922 |
923 } // namespace history | 923 } // namespace history |
OLD | NEW |