| 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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/files/file_enumerator.h" | 18 #include "base/files/file_enumerator.h" |
| 19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 20 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
| 21 #include "base/rand_util.h" | 21 #include "base/rand_util.h" |
| 22 #include "base/sequenced_task_runner.h" | 22 #include "base/sequenced_task_runner.h" |
| 23 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
| 24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| 26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 27 #include "base/trace_event/trace_event.h" |
| 27 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 29 #include "components/favicon_base/favicon_util.h" |
| 28 #include "components/favicon_base/select_favicon_frames.h" | 30 #include "components/favicon_base/select_favicon_frames.h" |
| 29 #include "components/history/core/browser/download_constants.h" | 31 #include "components/history/core/browser/download_constants.h" |
| 30 #include "components/history/core/browser/download_row.h" | 32 #include "components/history/core/browser/download_row.h" |
| 31 #include "components/history/core/browser/history_backend_client.h" | 33 #include "components/history/core/browser/history_backend_client.h" |
| 32 #include "components/history/core/browser/history_backend_observer.h" | 34 #include "components/history/core/browser/history_backend_observer.h" |
| 33 #include "components/history/core/browser/history_constants.h" | 35 #include "components/history/core/browser/history_constants.h" |
| 34 #include "components/history/core/browser/history_database.h" | 36 #include "components/history/core/browser/history_database.h" |
| 35 #include "components/history/core/browser/history_database_params.h" | 37 #include "components/history/core/browser/history_database_params.h" |
| 36 #include "components/history/core/browser/history_db_task.h" | 38 #include "components/history/core/browser/history_db_task.h" |
| 37 #include "components/history/core/browser/in_memory_history_backend.h" | 39 #include "components/history/core/browser/in_memory_history_backend.h" |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 | 1564 |
| 1563 LOCAL_HISTOGRAM_TIMES("History.GetLargestFaviconForURL", | 1565 LOCAL_HISTOGRAM_TIMES("History.GetLargestFaviconForURL", |
| 1564 TimeTicks::Now() - beginning_time); | 1566 TimeTicks::Now() - beginning_time); |
| 1565 } | 1567 } |
| 1566 | 1568 |
| 1567 void HistoryBackend::GetFaviconsForURL( | 1569 void HistoryBackend::GetFaviconsForURL( |
| 1568 const GURL& page_url, | 1570 const GURL& page_url, |
| 1569 int icon_types, | 1571 int icon_types, |
| 1570 const std::vector<int>& desired_sizes, | 1572 const std::vector<int>& desired_sizes, |
| 1571 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { | 1573 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { |
| 1574 TRACE_EVENT0("browser", "HistoryBackend::GetFaviconsForURL"); |
| 1572 DCHECK(bitmap_results); | 1575 DCHECK(bitmap_results); |
| 1573 GetFaviconsFromDB(page_url, icon_types, desired_sizes, bitmap_results); | 1576 GetFaviconsFromDB(page_url, icon_types, desired_sizes, bitmap_results); |
| 1577 |
| 1578 if (desired_sizes.size() == 1) |
| 1579 bitmap_results->assign(1, favicon_base::ResizeFaviconBitmapResult( |
| 1580 *bitmap_results, desired_sizes[0])); |
| 1574 } | 1581 } |
| 1575 | 1582 |
| 1576 void HistoryBackend::GetFaviconForID( | 1583 void HistoryBackend::GetFaviconForID( |
| 1577 favicon_base::FaviconID favicon_id, | 1584 favicon_base::FaviconID favicon_id, |
| 1578 int desired_size, | 1585 int desired_size, |
| 1579 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { | 1586 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { |
| 1587 TRACE_EVENT0("browser", "HistoryBackend::GetFaviconForID"); |
| 1580 std::vector<favicon_base::FaviconID> favicon_ids; | 1588 std::vector<favicon_base::FaviconID> favicon_ids; |
| 1581 favicon_ids.push_back(favicon_id); | 1589 favicon_ids.push_back(favicon_id); |
| 1582 std::vector<int> desired_sizes; | 1590 std::vector<int> desired_sizes; |
| 1583 desired_sizes.push_back(desired_size); | 1591 desired_sizes.push_back(desired_size); |
| 1584 | 1592 |
| 1585 // Get results from DB. | 1593 // Get results from DB. |
| 1586 GetFaviconBitmapResultsForBestMatch(favicon_ids, desired_sizes, | 1594 GetFaviconBitmapResultsForBestMatch(favicon_ids, desired_sizes, |
| 1587 bitmap_results); | 1595 bitmap_results); |
| 1596 |
| 1597 bitmap_results->assign(1, favicon_base::ResizeFaviconBitmapResult( |
| 1598 *bitmap_results, desired_size)); |
| 1588 } | 1599 } |
| 1589 | 1600 |
| 1590 void HistoryBackend::UpdateFaviconMappingsAndFetch( | 1601 void HistoryBackend::UpdateFaviconMappingsAndFetch( |
| 1591 const GURL& page_url, | 1602 const GURL& page_url, |
| 1592 const std::vector<GURL>& icon_urls, | 1603 const std::vector<GURL>& icon_urls, |
| 1593 int icon_types, | 1604 int icon_types, |
| 1594 const std::vector<int>& desired_sizes, | 1605 const std::vector<int>& desired_sizes, |
| 1595 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { | 1606 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { |
| 1596 UpdateFaviconMappingsAndFetchImpl(&page_url, icon_urls, icon_types, | 1607 UpdateFaviconMappingsAndFetchImpl(&page_url, icon_urls, icon_types, |
| 1597 desired_sizes, bitmap_results); | 1608 desired_sizes, bitmap_results); |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2657 // transaction is currently open. | 2668 // transaction is currently open. |
| 2658 db_->CommitTransaction(); | 2669 db_->CommitTransaction(); |
| 2659 db_->Vacuum(); | 2670 db_->Vacuum(); |
| 2660 db_->BeginTransaction(); | 2671 db_->BeginTransaction(); |
| 2661 db_->GetStartDate(&first_recorded_time_); | 2672 db_->GetStartDate(&first_recorded_time_); |
| 2662 | 2673 |
| 2663 return true; | 2674 return true; |
| 2664 } | 2675 } |
| 2665 | 2676 |
| 2666 } // namespace history | 2677 } // namespace history |
| OLD | NEW |