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 "chrome/browser/ui/webui/history_ui.h" | 5 #include "chrome/browser/ui/webui/history_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
814 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { | 814 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() { |
815 Profile* profile = Profile::FromWebUI(web_ui()); | 815 Profile* profile = Profile::FromWebUI(web_ui()); |
816 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile); | 816 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile); |
817 ManagedUserService* managed_user_service = NULL; | 817 ManagedUserService* managed_user_service = NULL; |
818 #if defined(ENABLE_MANAGED_USERS) | 818 #if defined(ENABLE_MANAGED_USERS) |
819 managed_user_service = ManagedUserServiceFactory::GetForProfile(profile); | 819 managed_user_service = ManagedUserServiceFactory::GetForProfile(profile); |
820 #endif | 820 #endif |
821 | 821 |
822 // Combine the local and remote results into |query_results_|, and remove | 822 // Combine the local and remote results into |query_results_|, and remove |
823 // any duplicates. | 823 // any duplicates. |
824 if (query_results_.size() && web_history_query_results_.size()) { | 824 if (web_history_query_results_.size()) { |
825 // Each result set covers a particular time range. Determine the | |
826 // intersection of the two time ranges, discard any entries from either | |
827 // set the are older than that, and then combine the results. | |
828 base::Time cutoff_time = std::max(query_results_.back().time, | |
829 web_history_query_results_.back().time); | |
830 RemoveOlderEntries(&query_results_, cutoff_time); | |
831 RemoveOlderEntries(&web_history_query_results_, cutoff_time); | |
832 | |
833 int local_result_count = query_results_.size(); | 825 int local_result_count = query_results_.size(); |
Joao da Silva
2013/03/25 13:13:59
|local_result_count| used to be calculated after r
Patrick Dubroy
2013/03/25 14:30:51
Good catch, fixed.
| |
826 if (local_result_count) { | |
827 // Each result set covers a particular time range. Determine the | |
828 // intersection of the two time ranges, discard any entries from either | |
829 // set the are older than that, and then combine the results. | |
Joao da Silva
2013/03/25 13:13:59
"from either set the are older than that" -> "from
Patrick Dubroy
2013/03/25 14:30:51
Done.
| |
830 base::Time cutoff_time = std::max( | |
831 query_results_.back().time, | |
832 web_history_query_results_.back().time); | |
833 RemoveOlderEntries(&query_results_, cutoff_time); | |
834 RemoveOlderEntries(&web_history_query_results_, cutoff_time); | |
835 } | |
834 query_results_.insert(query_results_.end(), | 836 query_results_.insert(query_results_.end(), |
835 web_history_query_results_.begin(), | 837 web_history_query_results_.begin(), |
836 web_history_query_results_.end()); | 838 web_history_query_results_.end()); |
837 RemoveDuplicateResults(&query_results_); | 839 if (local_result_count) { |
840 RemoveDuplicateResults(&query_results_); | |
838 | 841 |
839 // In the best case, we expect that all local results are duplicated on the | 842 // In the best case, we expect that all local results are duplicated on |
840 // server. Keep track of how many are missing. | 843 // the server. Keep track of how many are missing. |
841 if (local_result_count) { | |
842 int missing_count = std::count_if( | 844 int missing_count = std::count_if( |
843 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); | 845 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); |
844 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", | 846 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", |
845 missing_count * 100.0 / local_result_count); | 847 missing_count * 100.0 / local_result_count); |
846 } | 848 } |
847 } | 849 } |
848 | 850 |
849 // Convert the result vector into a ListValue. | 851 // Convert the result vector into a ListValue. |
850 ListValue results_value; | 852 ListValue results_value; |
851 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = | 853 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1109 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 1111 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
1110 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 1112 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
1111 } | 1113 } |
1112 | 1114 |
1113 // static | 1115 // static |
1114 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 1116 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
1115 ui::ScaleFactor scale_factor) { | 1117 ui::ScaleFactor scale_factor) { |
1116 return ResourceBundle::GetSharedInstance(). | 1118 return ResourceBundle::GetSharedInstance(). |
1117 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 1119 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
1118 } | 1120 } |
OLD | NEW |