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_.size()) { |
|
Dan Beam
2013/03/25 21:09:19
size() -> !empty()
Patrick Dubroy
2013/03/25 21:18:49
Done.
| |
| 825 // Each result set covers a particular time range. Determine the | 825 if (query_results_.size()) { |
| 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); |
| 834 } | |
| 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()); |
| 837 RemoveDuplicateResults(&query_results_); | |
| 838 | 838 |
| 839 // In the best case, we expect that all local results are duplicated on the | 839 if (query_results_.size()) { |
|
Dan Beam
2013/03/25 21:09:19
^ wont this always be non-empty now?
Patrick Dubroy
2013/03/25 21:18:49
Nope, RemoveOlderEntries might actually make it em
Dan Beam
2013/03/25 21:27:02
but there's a "querty_results_.insert()" call righ
Patrick Dubroy
2013/03/25 21:31:56
Yeah, you're right. Fixed.
| |
| 840 // server. Keep track of how many are missing. | 840 RemoveDuplicateResults(&query_results_); |
| 841 if (local_result_count) { | 841 |
| 842 // In the best case, we expect that all local results are duplicated on | |
| 843 // the server. Keep track of how many are missing. | |
| 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 / query_results_.size()); |
| 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 = |
| 852 query_results_.begin(); it != query_results_.end(); ++it) { | 854 query_results_.begin(); it != query_results_.end(); ++it) { |
| 853 scoped_ptr<base::Value> value( | 855 scoped_ptr<base::Value> value( |
| 854 it->ToValue(bookmark_model, managed_user_service)); | 856 it->ToValue(bookmark_model, managed_user_service)); |
| 855 results_value.Append(value.release()); | 857 results_value.Append(value.release()); |
| (...skipping 253 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 |