| 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 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 | 1536 |
| 1535 LOCAL_HISTOGRAM_TIMES("History.GetLargestFaviconForURL", | 1537 LOCAL_HISTOGRAM_TIMES("History.GetLargestFaviconForURL", |
| 1536 TimeTicks::Now() - beginning_time); | 1538 TimeTicks::Now() - beginning_time); |
| 1537 } | 1539 } |
| 1538 | 1540 |
| 1539 void HistoryBackend::GetFaviconsForURL( | 1541 void HistoryBackend::GetFaviconsForURL( |
| 1540 const GURL& page_url, | 1542 const GURL& page_url, |
| 1541 int icon_types, | 1543 int icon_types, |
| 1542 const std::vector<int>& desired_sizes, | 1544 const std::vector<int>& desired_sizes, |
| 1543 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { | 1545 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { |
| 1546 TRACE_EVENT0("browser", "HistoryBackend::GetFaviconsForURL"); |
| 1544 DCHECK(bitmap_results); | 1547 DCHECK(bitmap_results); |
| 1545 GetFaviconsFromDB(page_url, icon_types, desired_sizes, bitmap_results); | 1548 GetFaviconsFromDB(page_url, icon_types, desired_sizes, bitmap_results); |
| 1549 |
| 1550 if (desired_sizes.size() == 1) |
| 1551 bitmap_results->assign(1, favicon_base::ResizeFaviconBitmapResult( |
| 1552 *bitmap_results, desired_sizes[0])); |
| 1546 } | 1553 } |
| 1547 | 1554 |
| 1548 void HistoryBackend::GetFaviconForID( | 1555 void HistoryBackend::GetFaviconForID( |
| 1549 favicon_base::FaviconID favicon_id, | 1556 favicon_base::FaviconID favicon_id, |
| 1550 int desired_size, | 1557 int desired_size, |
| 1551 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { | 1558 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { |
| 1559 TRACE_EVENT0("browser", "HistoryBackend::GetFaviconForID"); |
| 1552 std::vector<favicon_base::FaviconID> favicon_ids; | 1560 std::vector<favicon_base::FaviconID> favicon_ids; |
| 1553 favicon_ids.push_back(favicon_id); | 1561 favicon_ids.push_back(favicon_id); |
| 1554 std::vector<int> desired_sizes; | 1562 std::vector<int> desired_sizes; |
| 1555 desired_sizes.push_back(desired_size); | 1563 desired_sizes.push_back(desired_size); |
| 1556 | 1564 |
| 1557 // Get results from DB. | 1565 // Get results from DB. |
| 1558 GetFaviconBitmapResultsForBestMatch(favicon_ids, desired_sizes, | 1566 GetFaviconBitmapResultsForBestMatch(favicon_ids, desired_sizes, |
| 1559 bitmap_results); | 1567 bitmap_results); |
| 1568 |
| 1569 bitmap_results->assign(1, favicon_base::ResizeFaviconBitmapResult( |
| 1570 *bitmap_results, desired_size)); |
| 1560 } | 1571 } |
| 1561 | 1572 |
| 1562 void HistoryBackend::UpdateFaviconMappingsAndFetch( | 1573 void HistoryBackend::UpdateFaviconMappingsAndFetch( |
| 1563 const GURL& page_url, | 1574 const GURL& page_url, |
| 1564 const std::vector<GURL>& icon_urls, | 1575 const std::vector<GURL>& icon_urls, |
| 1565 int icon_types, | 1576 int icon_types, |
| 1566 const std::vector<int>& desired_sizes, | 1577 const std::vector<int>& desired_sizes, |
| 1567 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { | 1578 std::vector<favicon_base::FaviconRawBitmapResult>* bitmap_results) { |
| 1568 UpdateFaviconMappingsAndFetchImpl(&page_url, icon_urls, icon_types, | 1579 UpdateFaviconMappingsAndFetchImpl(&page_url, icon_urls, icon_types, |
| 1569 desired_sizes, bitmap_results); | 1580 desired_sizes, bitmap_results); |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 // transaction is currently open. | 2640 // transaction is currently open. |
| 2630 db_->CommitTransaction(); | 2641 db_->CommitTransaction(); |
| 2631 db_->Vacuum(); | 2642 db_->Vacuum(); |
| 2632 db_->BeginTransaction(); | 2643 db_->BeginTransaction(); |
| 2633 db_->GetStartDate(&first_recorded_time_); | 2644 db_->GetStartDate(&first_recorded_time_); |
| 2634 | 2645 |
| 2635 return true; | 2646 return true; |
| 2636 } | 2647 } |
| 2637 | 2648 |
| 2638 } // namespace history | 2649 } // namespace history |
| OLD | NEW |