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

Side by Side Diff: components/history/core/browser/history_backend.cc

Issue 2347173002: Extend FaviconService to support fetching favicons from a Google server (Closed)
Patch Set: Peter's comments #2 Created 3 years, 10 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
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 "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
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(
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698