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 "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_.empty()) { |
| 825 // Each result set covers a particular time range. Determine the | 825 if (!query_results_.empty()) { |
| 826 // intersection of the two time ranges, discard any entries from either | 826 // Each result set covers a particular time range. Determine the |
| 827 // set the are older than that, and then combine the results. | 827 // intersection of the two time ranges, discard any entries from either |
| 828 base::Time cutoff_time = std::max(query_results_.back().time, | 828 // set that are older than that, and then combine the results. |
| 829 web_history_query_results_.back().time); | 829 base::Time cutoff_time = std::max( |
| 830 RemoveOlderEntries(&query_results_, cutoff_time); | 830 query_results_.back().time, |
| 831 RemoveOlderEntries(&web_history_query_results_, cutoff_time); | 831 web_history_query_results_.back().time); |
| 832 | 832 RemoveOlderEntries(&query_results_, cutoff_time); |
| 833 int local_result_count = query_results_.size(); | 833 RemoveOlderEntries(&web_history_query_results_, cutoff_time); |
|
Dan Beam
2013/03/25 21:38:58
^ it seems like this is the right logic, right? d
Patrick Dubroy
2013/03/25 21:46:29
Damn, you're right. Fixed.
| |
| 834 } | |
|
Dan Beam
2013/03/25 21:40:44
nit: \n after conditionals (from C++ style guide)
Patrick Dubroy
2013/03/25 21:46:29
Done.
| |
| 834 query_results_.insert(query_results_.end(), | 835 query_results_.insert(query_results_.end(), |
| 835 web_history_query_results_.begin(), | 836 web_history_query_results_.begin(), |
| 836 web_history_query_results_.end()); | 837 web_history_query_results_.end()); |
| 838 | |
| 837 RemoveDuplicateResults(&query_results_); | 839 RemoveDuplicateResults(&query_results_); |
| 838 | 840 |
| 839 // In the best case, we expect that all local results are duplicated on the | 841 // In the best case, we expect that all local results are duplicated on |
| 840 // server. Keep track of how many are missing. | 842 // the server. Keep track of how many are missing. |
| 841 if (local_result_count) { | 843 int missing_count = std::count_if( |
| 842 int missing_count = std::count_if( | 844 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); |
| 843 query_results_.begin(), query_results_.end(), IsLocalOnlyResult); | 845 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", |
| 844 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer", | 846 missing_count * 100.0 / query_results_.size()); |
| 845 missing_count * 100.0 / local_result_count); | |
| 846 } | |
| 847 } | 847 } |
| 848 | 848 |
| 849 // Convert the result vector into a ListValue. | 849 // Convert the result vector into a ListValue. |
| 850 ListValue results_value; | 850 ListValue results_value; |
| 851 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = | 851 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it = |
| 852 query_results_.begin(); it != query_results_.end(); ++it) { | 852 query_results_.begin(); it != query_results_.end(); ++it) { |
| 853 scoped_ptr<base::Value> value( | 853 scoped_ptr<base::Value> value( |
| 854 it->ToValue(bookmark_model, managed_user_service)); | 854 it->ToValue(bookmark_model, managed_user_service)); |
| 855 results_value.Append(value.release()); | 855 results_value.Append(value.release()); |
| 856 } | 856 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1109 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + | 1109 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + |
| 1110 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); | 1110 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); |
| 1111 } | 1111 } |
| 1112 | 1112 |
| 1113 // static | 1113 // static |
| 1114 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( | 1114 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( |
| 1115 ui::ScaleFactor scale_factor) { | 1115 ui::ScaleFactor scale_factor) { |
| 1116 return ResourceBundle::GetSharedInstance(). | 1116 return ResourceBundle::GetSharedInstance(). |
| 1117 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); | 1117 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); |
| 1118 } | 1118 } |
| OLD | NEW |