Chromium Code Reviews| 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 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1525 return; | 1525 return; |
| 1526 } | 1526 } |
| 1527 | 1527 |
| 1528 base::Time last_updated; | 1528 base::Time last_updated; |
| 1529 favicon_base::FaviconRawBitmapResult bitmap_result; | 1529 favicon_base::FaviconRawBitmapResult bitmap_result; |
| 1530 bitmap_result.icon_url = icon_url; | 1530 bitmap_result.icon_url = icon_url; |
| 1531 bitmap_result.icon_type = icon_type; | 1531 bitmap_result.icon_type = icon_type; |
| 1532 if (!thumbnail_db_->GetFaviconBitmap(largest_icon.bitmap_id, | 1532 if (!thumbnail_db_->GetFaviconBitmap(largest_icon.bitmap_id, |
| 1533 &last_updated, nullptr, | 1533 &last_updated, nullptr, |
| 1534 &bitmap_result.bitmap_data, | 1534 &bitmap_result.bitmap_data, |
| 1535 &bitmap_result.pixel_size)) { | 1535 &bitmap_result.pixel_size_in_db)) { |
| 1536 return; | 1536 return; |
| 1537 } | 1537 } |
| 1538 | 1538 |
| 1539 // Before the bitmap gets resized, the real size is the same as the DB size. | |
| 1540 bitmap_result.pixel_size = bitmap_result.pixel_size_in_db; | |
| 1541 | |
| 1539 bitmap_result.expired = | 1542 bitmap_result.expired = |
| 1540 (Time::Now() - last_updated) > TimeDelta::FromDays(kFaviconRefetchDays); | 1543 (Time::Now() - last_updated) > TimeDelta::FromDays(kFaviconRefetchDays); |
| 1541 if (bitmap_result.is_valid()) | 1544 if (bitmap_result.is_valid()) |
| 1542 *favicon_bitmap_result = bitmap_result; | 1545 *favicon_bitmap_result = bitmap_result; |
| 1543 | 1546 |
| 1544 LOCAL_HISTOGRAM_TIMES("History.GetLargestFaviconForURL", | 1547 LOCAL_HISTOGRAM_TIMES("History.GetLargestFaviconForURL", |
| 1545 TimeTicks::Now() - beginning_time); | 1548 TimeTicks::Now() - beginning_time); |
| 1546 } | 1549 } |
| 1547 | 1550 |
| 1548 void HistoryBackend::GetFaviconsForURL( | 1551 void HistoryBackend::GetFaviconsForURL( |
| 1549 const GURL& page_url, | 1552 const GURL& page_url, |
| 1550 int icon_types, | 1553 int icon_types, |
| 1551 const std::vector<int>& desired_sizes, | 1554 const std::vector<int>& desired_sizes, |
| 1552 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { | 1555 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { |
| 1553 TRACE_EVENT0("browser", "HistoryBackend::GetFaviconsForURL"); | 1556 TRACE_EVENT0("browser", "HistoryBackend::GetFaviconsForURL"); |
| 1554 DCHECK(bitmap_results); | 1557 DCHECK(bitmap_results); |
| 1555 GetFaviconsFromDB(page_url, icon_types, desired_sizes, bitmap_results); | 1558 GetFaviconsFromDB(page_url, icon_types, desired_sizes, bitmap_results); |
| 1556 | 1559 |
| 1557 if (desired_sizes.size() == 1) | 1560 if (desired_sizes.size() == 1) |
| 1558 bitmap_results->assign(1, favicon_base::ResizeFaviconBitmapResult( | 1561 bitmap_results->assign(1, favicon_base::ResizeFaviconBitmapResult( |
| 1559 *bitmap_results, desired_sizes[0])); | 1562 *bitmap_results, desired_sizes[0])); |
|
pkotwicz
2016/12/19 00:03:29
You need to update ResizeFaviconBitmapResult() in
jkrcal
2016/12/19 17:07:19
Isn't the struct copied in favicon_util.cc:209 inc
pkotwicz
2016/12/20 02:33:01
You are right ResizeFaviconBitmapResult() does a c
jkrcal
2017/02/06 19:01:22
Added a simple unit-test.
| |
| 1560 } | 1563 } |
| 1561 | 1564 |
| 1562 void HistoryBackend::GetFaviconForID( | 1565 void HistoryBackend::GetFaviconForID( |
| 1563 favicon_base::FaviconID favicon_id, | 1566 favicon_base::FaviconID favicon_id, |
| 1564 int desired_size, | 1567 int desired_size, |
| 1565 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { | 1568 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { |
| 1566 TRACE_EVENT0("browser", "HistoryBackend::GetFaviconForID"); | 1569 TRACE_EVENT0("browser", "HistoryBackend::GetFaviconForID"); |
| 1567 std::vector<favicon_base::FaviconID> favicon_ids; | 1570 std::vector<favicon_base::FaviconID> favicon_ids; |
| 1568 favicon_ids.push_back(favicon_id); | 1571 favicon_ids.push_back(favicon_id); |
| 1569 std::vector<int> desired_sizes; | 1572 std::vector<int> desired_sizes; |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2065 return false; | 2068 return false; |
| 2066 } | 2069 } |
| 2067 | 2070 |
| 2068 for (size_t i = 0; i < best_bitmap_ids.size(); ++i) { | 2071 for (size_t i = 0; i < best_bitmap_ids.size(); ++i) { |
| 2069 base::Time last_updated; | 2072 base::Time last_updated; |
| 2070 favicon_base::FaviconRawBitmapResult bitmap_result; | 2073 favicon_base::FaviconRawBitmapResult bitmap_result; |
| 2071 bitmap_result.icon_url = icon_url; | 2074 bitmap_result.icon_url = icon_url; |
| 2072 bitmap_result.icon_type = icon_type; | 2075 bitmap_result.icon_type = icon_type; |
| 2073 if (!thumbnail_db_->GetFaviconBitmap(best_bitmap_ids[i], &last_updated, | 2076 if (!thumbnail_db_->GetFaviconBitmap(best_bitmap_ids[i], &last_updated, |
| 2074 nullptr, &bitmap_result.bitmap_data, | 2077 nullptr, &bitmap_result.bitmap_data, |
| 2075 &bitmap_result.pixel_size)) { | 2078 &bitmap_result.pixel_size_in_db)) { |
| 2076 return false; | 2079 return false; |
| 2077 } | 2080 } |
| 2078 | 2081 |
| 2082 // Before the bitmap gets resized, the real size is the same as the DB size. | |
| 2083 bitmap_result.pixel_size = bitmap_result.pixel_size_in_db; | |
| 2084 | |
| 2079 bitmap_result.expired = | 2085 bitmap_result.expired = |
| 2080 (Time::Now() - last_updated) > TimeDelta::FromDays(kFaviconRefetchDays); | 2086 (Time::Now() - last_updated) > TimeDelta::FromDays(kFaviconRefetchDays); |
| 2081 if (bitmap_result.is_valid()) | 2087 if (bitmap_result.is_valid()) |
| 2082 favicon_bitmap_results->push_back(bitmap_result); | 2088 favicon_bitmap_results->push_back(bitmap_result); |
| 2083 } | 2089 } |
| 2084 return true; | 2090 return true; |
| 2085 } | 2091 } |
| 2086 | 2092 |
| 2087 bool HistoryBackend::SetFaviconMappingsForPageAndRedirects( | 2093 bool HistoryBackend::SetFaviconMappingsForPageAndRedirects( |
| 2088 const GURL& page_url, | 2094 const GURL& page_url, |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2646 // transaction is currently open. | 2652 // transaction is currently open. |
| 2647 db_->CommitTransaction(); | 2653 db_->CommitTransaction(); |
| 2648 db_->Vacuum(); | 2654 db_->Vacuum(); |
| 2649 db_->BeginTransaction(); | 2655 db_->BeginTransaction(); |
| 2650 db_->GetStartDate(&first_recorded_time_); | 2656 db_->GetStartDate(&first_recorded_time_); |
| 2651 | 2657 |
| 2652 return true; | 2658 return true; |
| 2653 } | 2659 } |
| 2654 | 2660 |
| 2655 } // namespace history | 2661 } // namespace history |
| OLD | NEW |