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

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

Issue 10869047: Fix HistoryBackend::SetFavicons (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 return; 1892 return;
1893 1893
1894 FaviconData favicon; 1894 FaviconData favicon;
1895 1895
1896 if (thumbnail_db_.get()) { 1896 if (thumbnail_db_.get()) {
1897 const FaviconID favicon_id = 1897 const FaviconID favicon_id =
1898 thumbnail_db_->GetFaviconIDForFaviconURL( 1898 thumbnail_db_->GetFaviconIDForFaviconURL(
1899 icon_url, icon_types, &favicon.icon_type); 1899 icon_url, icon_types, &favicon.icon_type);
1900 if (favicon_id) { 1900 if (favicon_id) {
1901 scoped_refptr<base::RefCountedMemory> data; 1901 scoped_refptr<base::RefCountedMemory> data;
1902 favicon.known_icon = true;
1903 Time last_updated; 1902 Time last_updated;
1904 if (thumbnail_db_->GetFavicon(favicon_id, &last_updated, &data, 1903 if (thumbnail_db_->GetFavicon(favicon_id, &last_updated, &data,
1905 NULL, NULL)) { 1904 NULL, NULL)) {
1905 favicon.known_icon = true;
1906 favicon.expired = (Time::Now() - last_updated) > 1906 favicon.expired = (Time::Now() - last_updated) >
1907 TimeDelta::FromDays(kFaviconRefetchDays); 1907 TimeDelta::FromDays(kFaviconRefetchDays);
1908 favicon.image_data = data; 1908 favicon.image_data = data;
1909 } 1909 }
1910 1910
1911 if (page_url) 1911 if (page_url)
1912 SetFaviconMapping(*page_url, favicon_id, favicon.icon_type); 1912 SetFaviconMapping(*page_url, favicon_id, favicon.icon_type);
1913 } 1913 }
1914 // else case, haven't cached entry yet. Caller is responsible for 1914 // else case, haven't cached entry yet. Caller is responsible for
1915 // downloading the favicon and invoking SetFavicon. 1915 // downloading the favicon and invoking SetFavicon.
(...skipping 30 matching lines...) Expand all
1946 const GURL& page_url, 1946 const GURL& page_url,
1947 const GURL& icon_url, 1947 const GURL& icon_url,
1948 scoped_refptr<base::RefCountedMemory> data, 1948 scoped_refptr<base::RefCountedMemory> data,
1949 IconType icon_type) { 1949 IconType icon_type) {
1950 DCHECK(data.get()); 1950 DCHECK(data.get());
1951 if (!thumbnail_db_.get() || !db_.get()) 1951 if (!thumbnail_db_.get() || !db_.get())
1952 return; 1952 return;
1953 1953
1954 FaviconID id = thumbnail_db_->GetFaviconIDForFaviconURL( 1954 FaviconID id = thumbnail_db_->GetFaviconIDForFaviconURL(
1955 icon_url, icon_type, NULL); 1955 icon_url, icon_type, NULL);
1956 if (id) 1956 if (!id) {
1957 id = thumbnail_db_->AddFavicon(icon_url,
1958 icon_type,
1959 "0 0",
1960 data,
1961 Time::Now(),
1962 gfx::Size());
1963 } else {
1957 thumbnail_db_->DeleteFaviconBitmapsForFavicon(id); 1964 thumbnail_db_->DeleteFaviconBitmapsForFavicon(id);
1958 1965 thumbnail_db_->AddFaviconBitmap(id, data, Time::Now(), gfx::Size());
1959 id = thumbnail_db_->AddFavicon(icon_url, 1966 }
1960 icon_type,
1961 "0 0",
1962 data,
1963 Time::Now(),
1964 gfx::Size());
1965 1967
1966 SetFaviconMapping(page_url, id, icon_type); 1968 SetFaviconMapping(page_url, id, icon_type);
1967 } 1969 }
1968 1970
1969 void HistoryBackend::SetFaviconMapping(const GURL& page_url, 1971 void HistoryBackend::SetFaviconMapping(const GURL& page_url,
1970 FaviconID id, 1972 FaviconID id,
1971 IconType icon_type) { 1973 IconType icon_type) {
1972 if (!thumbnail_db_.get()) 1974 if (!thumbnail_db_.get())
1973 return; 1975 return;
1974 1976
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2488 info.url_id = visit.url_id; 2490 info.url_id = visit.url_id;
2489 info.time = visit.visit_time; 2491 info.time = visit.visit_time;
2490 info.transition = visit.transition; 2492 info.transition = visit.transition;
2491 // If we don't have a delegate yet during setup or shutdown, we will drop 2493 // If we don't have a delegate yet during setup or shutdown, we will drop
2492 // these notifications. 2494 // these notifications.
2493 if (delegate_.get()) 2495 if (delegate_.get())
2494 delegate_->NotifyVisitDBObserversOnAddVisit(info); 2496 delegate_->NotifyVisitDBObserversOnAddVisit(info);
2495 } 2497 }
2496 2498
2497 } // namespace history 2499 } // 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