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

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 compilation Created 6 years, 4 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 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 *url, favicon_base::FAVICON, NULL)) { 1908 *url, favicon_base::FAVICON, NULL)) {
1910 // URL is present in history, update the favicon *only* if it is not 1909 // URL is present in history, update the favicon *only* if it is not
1911 // set already. 1910 // set already.
1912 thumbnail_db_->AddIconMapping(*url, favicon_id); 1911 thumbnail_db_->AddIconMapping(*url, favicon_id);
1913 favicons_changed.insert(*url); 1912 favicons_changed.insert(*url);
1914 } 1913 }
1915 } 1914 }
1916 } 1915 }
1917 } 1916 }
1918 1917
1919 if (!favicons_changed.empty()) { 1918 if (!favicons_changed.empty() && delegate_) {
1920 // Send the notification about the changed favicon URLs. 1919 // Send the notification about the changed favicon URLs.
1921 scoped_ptr<FaviconChangedDetails> changed_details( 1920 delegate_->NotifyFaviconChanged(favicons_changed);
1922 new FaviconChangedDetails);
1923 changed_details->urls.swap(favicons_changed);
1924 BroadcastNotifications(chrome::NOTIFICATION_FAVICON_CHANGED,
1925 changed_details.PassAs<HistoryDetails>());
1926 } 1921 }
1927 } 1922 }
1928 1923
1929 void HistoryBackend::UpdateFaviconMappingsAndFetchImpl( 1924 void HistoryBackend::UpdateFaviconMappingsAndFetchImpl(
1930 const GURL* page_url, 1925 const GURL* page_url,
1931 const std::vector<GURL>& icon_urls, 1926 const std::vector<GURL>& icon_urls,
1932 int icon_types, 1927 int icon_types,
1933 const std::vector<int>& desired_sizes, 1928 const std::vector<int>& desired_sizes,
1934 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { 1929 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) {
1935 // If |page_url| is specified, |icon_types| must be either a single icon 1930 // If |page_url| is specified, |icon_types| must be either a single icon
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2278 } else { 2273 } else {
2279 // No known redirects, construct mock redirect chain containing |page_url|. 2274 // No known redirects, construct mock redirect chain containing |page_url|.
2280 redirect_list->push_back(page_url); 2275 redirect_list->push_back(page_url);
2281 } 2276 }
2282 } 2277 }
2283 2278
2284 void HistoryBackend::SendFaviconChangedNotificationForPageAndRedirects( 2279 void HistoryBackend::SendFaviconChangedNotificationForPageAndRedirects(
2285 const GURL& page_url) { 2280 const GURL& page_url) {
2286 history::RedirectList redirect_list; 2281 history::RedirectList redirect_list;
2287 GetCachedRecentRedirects(page_url, &redirect_list); 2282 GetCachedRecentRedirects(page_url, &redirect_list);
2288 2283 if (!redirect_list.empty() && delegate_) {
2289 scoped_ptr<FaviconChangedDetails> changed_details(new FaviconChangedDetails); 2284 std::set<GURL> favicons_changed(redirect_list.begin(), redirect_list.end());
2290 for (size_t i = 0; i < redirect_list.size(); ++i) 2285 delegate_->NotifyFaviconChanged(favicons_changed);
2291 changed_details->urls.insert(redirect_list[i]); 2286 }
2292
2293 BroadcastNotifications(chrome::NOTIFICATION_FAVICON_CHANGED,
2294 changed_details.PassAs<HistoryDetails>());
2295 } 2287 }
2296 2288
2297 void HistoryBackend::Commit() { 2289 void HistoryBackend::Commit() {
2298 if (!db_) 2290 if (!db_)
2299 return; 2291 return;
2300 2292
2301 // Note that a commit may not actually have been scheduled if a caller 2293 // Note that a commit may not actually have been scheduled if a caller
2302 // explicitly calls this instead of using ScheduleCommit. Likewise, we 2294 // explicitly calls this instead of using ScheduleCommit. Likewise, we
2303 // may reset the flag written by a pending commit. But this is OK! It 2295 // may reset the flag written by a pending commit. But this is OK! It
2304 // will merely cause extra commits (which is kind of the idea). We 2296 // will merely cause extra commits (which is kind of the idea). We
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2754 int rank = kPageVisitStatsMaxTopSites; 2746 int rank = kPageVisitStatsMaxTopSites;
2755 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url); 2747 std::map<GURL, int>::const_iterator it = most_visited_urls_map_.find(url);
2756 if (it != most_visited_urls_map_.end()) 2748 if (it != most_visited_urls_map_.end())
2757 rank = (*it).second; 2749 rank = (*it).second;
2758 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank", 2750 UMA_HISTOGRAM_ENUMERATION("History.TopSitesVisitsByRank",
2759 rank, kPageVisitStatsMaxTopSites + 1); 2751 rank, kPageVisitStatsMaxTopSites + 1);
2760 } 2752 }
2761 #endif 2753 #endif
2762 2754
2763 } // namespace history 2755 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698