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

Side by Side Diff: chrome/browser/history/history_backend.cc

Issue 484213002: Refactor HistoryService to not send NOTIFICATION_FAVICON_CHANGED (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix android unit tests Created 6 years, 3 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/history/history_backend.h" 5 #include "chrome/browser/history/history_backend.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/files/file_enumerator.h" 17 #include "base/files/file_enumerator.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/scoped_vector.h" 19 #include "base/memory/scoped_vector.h"
20 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
21 #include "base/metrics/histogram.h" 21 #include "base/metrics/histogram.h"
22 #include "base/rand_util.h" 22 #include "base/rand_util.h"
23 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "base/time/time.h" 25 #include "base/time/time.h"
26 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
27 #include "chrome/browser/favicon/favicon_changed_details.h"
28 #include "chrome/browser/history/download_row.h" 27 #include "chrome/browser/history/download_row.h"
29 #include "chrome/browser/history/history_db_task.h" 28 #include "chrome/browser/history/history_db_task.h"
30 #include "chrome/browser/history/history_db_task.h" 29 #include "chrome/browser/history/history_db_task.h"
31 #include "chrome/browser/history/history_notifications.h" 30 #include "chrome/browser/history/history_notifications.h"
32 #include "chrome/browser/history/in_memory_history_backend.h" 31 #include "chrome/browser/history/in_memory_history_backend.h"
33 #include "chrome/browser/history/in_memory_history_backend.h" 32 #include "chrome/browser/history/in_memory_history_backend.h"
34 #include "chrome/browser/history/top_sites.h" 33 #include "chrome/browser/history/top_sites.h"
35 #include "chrome/browser/history/typed_url_syncable_service.h" 34 #include "chrome/browser/history/typed_url_syncable_service.h"
36 #include "chrome/browser/history/typed_url_syncable_service.h" 35 #include "chrome/browser/history/typed_url_syncable_service.h"
37 #include "chrome/browser/history/visit_filter.h" 36 #include "chrome/browser/history/visit_filter.h"
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 *url, favicon_base::FAVICON, NULL)) { 1889 *url, favicon_base::FAVICON, NULL)) {
1891 // URL is present in history, update the favicon *only* if it is not 1890 // URL is present in history, update the favicon *only* if it is not
1892 // set already. 1891 // set already.
1893 thumbnail_db_->AddIconMapping(*url, favicon_id); 1892 thumbnail_db_->AddIconMapping(*url, favicon_id);
1894 favicons_changed.insert(*url); 1893 favicons_changed.insert(*url);
1895 } 1894 }
1896 } 1895 }
1897 } 1896 }
1898 } 1897 }
1899 1898
1900 if (!favicons_changed.empty()) { 1899 if (!favicons_changed.empty() && delegate_) {
1901 // Send the notification about the changed favicon URLs. 1900 // Send the notification about the changed favicon URLs.
1902 scoped_ptr<FaviconChangedDetails> changed_details( 1901 delegate_->NotifyFaviconChanged(favicons_changed);
1903 new FaviconChangedDetails);
1904 changed_details->urls.swap(favicons_changed);
1905 BroadcastNotifications(chrome::NOTIFICATION_FAVICON_CHANGED,
1906 changed_details.PassAs<HistoryDetails>());
1907 } 1902 }
1908 } 1903 }
1909 1904
1910 void HistoryBackend::UpdateFaviconMappingsAndFetchImpl( 1905 void HistoryBackend::UpdateFaviconMappingsAndFetchImpl(
1911 const GURL* page_url, 1906 const GURL* page_url,
1912 const std::vector<GURL>& icon_urls, 1907 const std::vector<GURL>& icon_urls,
1913 int icon_types, 1908 int icon_types,
1914 const std::vector<int>& desired_sizes, 1909 const std::vector<int>& desired_sizes,
1915 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { 1910 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) {
1916 // If |page_url| is specified, |icon_types| must be either a single icon 1911 // If |page_url| is specified, |icon_types| must be either a single icon
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 } else { 2230 } else {
2236 // No known redirects, construct mock redirect chain containing |page_url|. 2231 // No known redirects, construct mock redirect chain containing |page_url|.
2237 redirect_list->push_back(page_url); 2232 redirect_list->push_back(page_url);
2238 } 2233 }
2239 } 2234 }
2240 2235
2241 void HistoryBackend::SendFaviconChangedNotificationForPageAndRedirects( 2236 void HistoryBackend::SendFaviconChangedNotificationForPageAndRedirects(
2242 const GURL& page_url) { 2237 const GURL& page_url) {
2243 history::RedirectList redirect_list; 2238 history::RedirectList redirect_list;
2244 GetCachedRecentRedirects(page_url, &redirect_list); 2239 GetCachedRecentRedirects(page_url, &redirect_list);
2245 2240 if (!redirect_list.empty() && delegate_) {
2246 scoped_ptr<FaviconChangedDetails> changed_details(new FaviconChangedDetails); 2241 std::set<GURL> favicons_changed(redirect_list.begin(), redirect_list.end());
2247 for (size_t i = 0; i < redirect_list.size(); ++i) 2242 delegate_->NotifyFaviconChanged(favicons_changed);
2248 changed_details->urls.insert(redirect_list[i]); 2243 }
2249
2250 BroadcastNotifications(chrome::NOTIFICATION_FAVICON_CHANGED,
2251 changed_details.PassAs<HistoryDetails>());
2252 } 2244 }
2253 2245
2254 void HistoryBackend::Commit() { 2246 void HistoryBackend::Commit() {
2255 if (!db_) 2247 if (!db_)
2256 return; 2248 return;
2257 2249
2258 // Note that a commit may not actually have been scheduled if a caller 2250 // Note that a commit may not actually have been scheduled if a caller
2259 // explicitly calls this instead of using ScheduleCommit. Likewise, we 2251 // explicitly calls this instead of using ScheduleCommit. Likewise, we
2260 // may reset the flag written by a pending commit. But this is OK! It 2252 // may reset the flag written by a pending commit. But this is OK! It
2261 // will merely cause extra commits (which is kind of the idea). We 2253 // will merely cause extra commits (which is kind of the idea). We
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 int rank = kPageVisitStatsMaxTopSites; 2703 int rank = kPageVisitStatsMaxTopSites;
2712 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); 2704 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url);
2713 if (it != most_visited_urls_map_.end()) 2705 if (it != most_visited_urls_map_.end())
2714 rank = (*it).second; 2706 rank = (*it).second;
2715 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", 2707 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank",
2716 rank, kPageVisitStatsMaxTopSites + 1); 2708 rank, kPageVisitStatsMaxTopSites + 1);
2717 } 2709 }
2718 #endif 2710 #endif
2719 2711
2720 } // namespace history 2712 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698