| 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/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/file_util.h" | 17 #include "base/file_util.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.h" | 20 #include "base/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/string_util.h" | 23 #include "base/string_util.h" |
| 24 #include "base/time.h" | 24 #include "base/time.h" |
| 25 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
| 26 #include "chrome/browser/autocomplete/history_url_provider.h" | 26 #include "chrome/browser/autocomplete/history_url_provider.h" |
| 27 #include "chrome/browser/bookmarks/bookmark_service.h" | 27 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 28 #include "chrome/browser/favicon/favicon_changed_details.h" |
| 28 #include "chrome/browser/favicon/imported_favicon_usage.h" | 29 #include "chrome/browser/favicon/imported_favicon_usage.h" |
| 29 #include "chrome/browser/history/download_row.h" | 30 #include "chrome/browser/history/download_row.h" |
| 30 #include "chrome/browser/history/history_db_task.h" | 31 #include "chrome/browser/history/history_db_task.h" |
| 31 #include "chrome/browser/history/history_notifications.h" | 32 #include "chrome/browser/history/history_notifications.h" |
| 32 #include "chrome/browser/history/history_publisher.h" | 33 #include "chrome/browser/history/history_publisher.h" |
| 33 #include "chrome/browser/history/in_memory_history_backend.h" | 34 #include "chrome/browser/history/in_memory_history_backend.h" |
| 34 #include "chrome/browser/history/page_usage_data.h" | 35 #include "chrome/browser/history/page_usage_data.h" |
| 35 #include "chrome/browser/history/select_favicon_frames.h" | 36 #include "chrome/browser/history/select_favicon_frames.h" |
| 36 #include "chrome/browser/history/top_sites.h" | 37 #include "chrome/browser/history/top_sites.h" |
| 37 #include "chrome/browser/history/typed_url_syncable_service.h" | 38 #include "chrome/browser/history/typed_url_syncable_service.h" |
| (...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 // set already. | 2231 // set already. |
| 2231 thumbnail_db_->AddIconMapping(*url, favicon_id); | 2232 thumbnail_db_->AddIconMapping(*url, favicon_id); |
| 2232 favicons_changed.insert(*url); | 2233 favicons_changed.insert(*url); |
| 2233 } | 2234 } |
| 2234 } | 2235 } |
| 2235 } | 2236 } |
| 2236 } | 2237 } |
| 2237 | 2238 |
| 2238 if (!favicons_changed.empty()) { | 2239 if (!favicons_changed.empty()) { |
| 2239 // Send the notification about the changed favicon URLs. | 2240 // Send the notification about the changed favicon URLs. |
| 2240 FaviconChangeDetails* changed_details = new FaviconChangeDetails; | 2241 FaviconChangedDetails* changed_details = new FaviconChangedDetails; |
| 2241 changed_details->urls.swap(favicons_changed); | 2242 changed_details->urls.swap(favicons_changed); |
| 2242 BroadcastNotifications(chrome::NOTIFICATION_FAVICON_CHANGED, | 2243 BroadcastNotifications(chrome::NOTIFICATION_FAVICON_CHANGED, |
| 2243 changed_details); | 2244 changed_details); |
| 2244 } | 2245 } |
| 2245 } | 2246 } |
| 2246 | 2247 |
| 2247 void HistoryBackend::UpdateFaviconMappingsAndFetchImpl( | 2248 void HistoryBackend::UpdateFaviconMappingsAndFetchImpl( |
| 2248 const GURL* page_url, | 2249 const GURL* page_url, |
| 2249 const std::vector<GURL>& icon_urls, | 2250 const std::vector<GURL>& icon_urls, |
| 2250 int icon_types, | 2251 int icon_types, |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2597 // No known redirects, construct mock redirect chain containing |page_url|. | 2598 // No known redirects, construct mock redirect chain containing |page_url|. |
| 2598 redirect_list->push_back(page_url); | 2599 redirect_list->push_back(page_url); |
| 2599 } | 2600 } |
| 2600 } | 2601 } |
| 2601 | 2602 |
| 2602 void HistoryBackend::SendFaviconChangedNotificationForPageAndRedirects( | 2603 void HistoryBackend::SendFaviconChangedNotificationForPageAndRedirects( |
| 2603 const GURL& page_url) { | 2604 const GURL& page_url) { |
| 2604 history::RedirectList redirect_list; | 2605 history::RedirectList redirect_list; |
| 2605 GetCachedRecentRedirects(page_url, &redirect_list); | 2606 GetCachedRecentRedirects(page_url, &redirect_list); |
| 2606 | 2607 |
| 2607 FaviconChangeDetails* changed_details = new FaviconChangeDetails; | 2608 FaviconChangedDetails* changed_details = new FaviconChangedDetails; |
| 2608 for (size_t i = 0; i < redirect_list.size(); ++i) | 2609 for (size_t i = 0; i < redirect_list.size(); ++i) |
| 2609 changed_details->urls.insert(redirect_list[i]); | 2610 changed_details->urls.insert(redirect_list[i]); |
| 2610 | 2611 |
| 2611 BroadcastNotifications(chrome::NOTIFICATION_FAVICON_CHANGED, | 2612 BroadcastNotifications(chrome::NOTIFICATION_FAVICON_CHANGED, |
| 2612 changed_details); | 2613 changed_details); |
| 2613 } | 2614 } |
| 2614 | 2615 |
| 2615 void HistoryBackend::Commit() { | 2616 void HistoryBackend::Commit() { |
| 2616 if (!db_) | 2617 if (!db_) |
| 2617 return; | 2618 return; |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3097 info.url_id = visit.url_id; | 3098 info.url_id = visit.url_id; |
| 3098 info.time = visit.visit_time; | 3099 info.time = visit.visit_time; |
| 3099 info.transition = visit.transition; | 3100 info.transition = visit.transition; |
| 3100 // If we don't have a delegate yet during setup or shutdown, we will drop | 3101 // If we don't have a delegate yet during setup or shutdown, we will drop |
| 3101 // these notifications. | 3102 // these notifications. |
| 3102 if (delegate_) | 3103 if (delegate_) |
| 3103 delegate_->NotifyVisitDBObserversOnAddVisit(info); | 3104 delegate_->NotifyVisitDBObserversOnAddVisit(info); |
| 3104 } | 3105 } |
| 3105 | 3106 |
| 3106 } // namespace history | 3107 } // namespace history |
| OLD | NEW |