| 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 "components/history/core/browser/history_backend.h" | 5 #include "components/history/core/browser/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> |
| (...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 favicon_base::IconType icon_type; | 1502 favicon_base::IconType icon_type; |
| 1503 if (!thumbnail_db_->GetFaviconHeader(largest_icon.icon_id, &icon_url, | 1503 if (!thumbnail_db_->GetFaviconHeader(largest_icon.icon_id, &icon_url, |
| 1504 &icon_type)) { | 1504 &icon_type)) { |
| 1505 return; | 1505 return; |
| 1506 } | 1506 } |
| 1507 | 1507 |
| 1508 base::Time last_updated; | 1508 base::Time last_updated; |
| 1509 favicon_base::FaviconRawBitmapResult bitmap_result; | 1509 favicon_base::FaviconRawBitmapResult bitmap_result; |
| 1510 bitmap_result.icon_url = icon_url; | 1510 bitmap_result.icon_url = icon_url; |
| 1511 bitmap_result.icon_type = icon_type; | 1511 bitmap_result.icon_type = icon_type; |
| 1512 if (!thumbnail_db_->GetFaviconBitmap(largest_icon.bitmap_id, | 1512 if (!thumbnail_db_->GetFaviconBitmap( |
| 1513 &last_updated, nullptr, | 1513 largest_icon.bitmap_id, /*access_time=*/Time::Now(), &last_updated, |
| 1514 &bitmap_result.bitmap_data, | 1514 &bitmap_result.bitmap_data, &bitmap_result.pixel_size)) { |
| 1515 &bitmap_result.pixel_size)) { | |
| 1516 return; | 1515 return; |
| 1517 } | 1516 } |
| 1518 | 1517 |
| 1519 bitmap_result.expired = | 1518 bitmap_result.expired = |
| 1520 (Time::Now() - last_updated) > TimeDelta::FromDays(kFaviconRefetchDays); | 1519 (Time::Now() - last_updated) > TimeDelta::FromDays(kFaviconRefetchDays); |
| 1521 if (bitmap_result.is_valid()) | 1520 if (bitmap_result.is_valid()) |
| 1522 *favicon_bitmap_result = bitmap_result; | 1521 *favicon_bitmap_result = bitmap_result; |
| 1523 | 1522 |
| 1524 LOCAL_HISTOGRAM_TIMES("History.GetLargestFaviconForURL", | 1523 LOCAL_HISTOGRAM_TIMES("History.GetLargestFaviconForURL", |
| 1525 TimeTicks::Now() - beginning_time); | 1524 TimeTicks::Now() - beginning_time); |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 return favicon_bitmaps_changed; | 1960 return favicon_bitmaps_changed; |
| 1962 } | 1961 } |
| 1963 | 1962 |
| 1964 bool HistoryBackend::IsFaviconBitmapDataEqual( | 1963 bool HistoryBackend::IsFaviconBitmapDataEqual( |
| 1965 FaviconBitmapID bitmap_id, | 1964 FaviconBitmapID bitmap_id, |
| 1966 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data) { | 1965 const scoped_refptr<base::RefCountedMemory>& new_bitmap_data) { |
| 1967 if (!new_bitmap_data) | 1966 if (!new_bitmap_data) |
| 1968 return false; | 1967 return false; |
| 1969 | 1968 |
| 1970 scoped_refptr<base::RefCountedMemory> original_bitmap_data; | 1969 scoped_refptr<base::RefCountedMemory> original_bitmap_data; |
| 1971 thumbnail_db_->GetFaviconBitmap(bitmap_id, nullptr, nullptr, | 1970 thumbnail_db_->GetFaviconBitmap(bitmap_id, /*access_time=*/Time::Now(), |
| 1972 &original_bitmap_data, nullptr); | 1971 nullptr, &original_bitmap_data, nullptr); |
| 1973 return new_bitmap_data->Equals(original_bitmap_data); | 1972 return new_bitmap_data->Equals(original_bitmap_data); |
| 1974 } | 1973 } |
| 1975 | 1974 |
| 1976 bool HistoryBackend::GetFaviconsFromDB( | 1975 bool HistoryBackend::GetFaviconsFromDB( |
| 1977 const GURL& page_url, | 1976 const GURL& page_url, |
| 1978 int icon_types, | 1977 int icon_types, |
| 1979 const std::vector<int>& desired_sizes, | 1978 const std::vector<int>& desired_sizes, |
| 1980 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results) { | 1979 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results) { |
| 1981 DCHECK(favicon_bitmap_results); | 1980 DCHECK(favicon_bitmap_results); |
| 1982 favicon_bitmap_results->clear(); | 1981 favicon_bitmap_results->clear(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 if (!thumbnail_db_->GetFaviconHeader(best_favicon_id, &icon_url, | 2049 if (!thumbnail_db_->GetFaviconHeader(best_favicon_id, &icon_url, |
| 2051 &icon_type)) { | 2050 &icon_type)) { |
| 2052 return false; | 2051 return false; |
| 2053 } | 2052 } |
| 2054 | 2053 |
| 2055 for (size_t i = 0; i < best_bitmap_ids.size(); ++i) { | 2054 for (size_t i = 0; i < best_bitmap_ids.size(); ++i) { |
| 2056 base::Time last_updated; | 2055 base::Time last_updated; |
| 2057 favicon_base::FaviconRawBitmapResult bitmap_result; | 2056 favicon_base::FaviconRawBitmapResult bitmap_result; |
| 2058 bitmap_result.icon_url = icon_url; | 2057 bitmap_result.icon_url = icon_url; |
| 2059 bitmap_result.icon_type = icon_type; | 2058 bitmap_result.icon_type = icon_type; |
| 2060 if (!thumbnail_db_->GetFaviconBitmap(best_bitmap_ids[i], &last_updated, | 2059 if (!thumbnail_db_->GetFaviconBitmap( |
| 2061 nullptr, &bitmap_result.bitmap_data, | 2060 best_bitmap_ids[i], /*access_time=*/Time::Now(), &last_updated, |
| 2062 &bitmap_result.pixel_size)) { | 2061 &bitmap_result.bitmap_data, &bitmap_result.pixel_size)) { |
| 2063 return false; | 2062 return false; |
| 2064 } | 2063 } |
| 2065 | 2064 |
| 2066 bitmap_result.expired = | 2065 bitmap_result.expired = |
| 2067 (Time::Now() - last_updated) > TimeDelta::FromDays(kFaviconRefetchDays); | 2066 (Time::Now() - last_updated) > TimeDelta::FromDays(kFaviconRefetchDays); |
| 2068 if (bitmap_result.is_valid()) | 2067 if (bitmap_result.is_valid()) |
| 2069 favicon_bitmap_results->push_back(bitmap_result); | 2068 favicon_bitmap_results->push_back(bitmap_result); |
| 2070 } | 2069 } |
| 2071 return true; | 2070 return true; |
| 2072 } | 2071 } |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2635 // transaction is currently open. | 2634 // transaction is currently open. |
| 2636 db_->CommitTransaction(); | 2635 db_->CommitTransaction(); |
| 2637 db_->Vacuum(); | 2636 db_->Vacuum(); |
| 2638 db_->BeginTransaction(); | 2637 db_->BeginTransaction(); |
| 2639 db_->GetStartDate(&first_recorded_time_); | 2638 db_->GetStartDate(&first_recorded_time_); |
| 2640 | 2639 |
| 2641 return true; | 2640 return true; |
| 2642 } | 2641 } |
| 2643 | 2642 |
| 2644 } // namespace history | 2643 } // namespace history |
| OLD | NEW |