Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/webui/history_ui.cc

Issue 12381081: History: Add UMA collection for full history sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/history_ui.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/i18n/time_formatting.h" 13 #include "base/i18n/time_formatting.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/metrics/histogram.h"
16 #include "base/string16.h" 17 #include "base/string16.h"
17 #include "base/string_piece.h" 18 #include "base/string_piece.h"
18 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
19 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
20 #include "base/time.h" 21 #include "base/time.h"
21 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
22 #include "base/values.h" 23 #include "base/values.h"
23 #include "chrome/browser/bookmarks/bookmark_model.h" 24 #include "chrome/browser/bookmarks/bookmark_model.h"
24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
25 #include "chrome/browser/bookmarks/bookmark_utils.h" 26 #include "chrome/browser/bookmarks/bookmark_utils.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 using content::WebContents; 69 using content::WebContents;
69 70
70 static const char kStringsJsFile[] = "strings.js"; 71 static const char kStringsJsFile[] = "strings.js";
71 static const char kHistoryJsFile[] = "history.js"; 72 static const char kHistoryJsFile[] = "history.js";
72 73
73 // The amount of time to wait for a response from the WebHistoryService. 74 // The amount of time to wait for a response from the WebHistoryService.
74 static const int kWebHistoryTimeoutSeconds = 3; 75 static const int kWebHistoryTimeoutSeconds = 3;
75 76
76 namespace { 77 namespace {
77 78
79 // Buckets for UMA histograms.
80 enum WebHistoryQueryBuckets {
81 WEB_HISTORY_QUERY_FAILED = 0,
82 WEB_HISTORY_QUERY_SUCCEEDED,
83 WEB_HISTORY_QUERY_TIMED_OUT,
84 NUM_WEB_HISTORY_QUERY_BUCKETS
85 };
86
78 #if defined(OS_MACOSX) 87 #if defined(OS_MACOSX)
79 const char kIncognitoModeShortcut[] = "(" 88 const char kIncognitoModeShortcut[] = "("
80 "\xE2\x87\xA7" // Shift symbol (U+21E7 'UPWARDS WHITE ARROW'). 89 "\xE2\x87\xA7" // Shift symbol (U+21E7 'UPWARDS WHITE ARROW').
81 "\xE2\x8C\x98" // Command symbol (U+2318 'PLACE OF INTEREST SIGN'). 90 "\xE2\x8C\x98" // Command symbol (U+2318 'PLACE OF INTEREST SIGN').
82 "N)"; 91 "N)";
83 #elif defined(OS_WIN) 92 #elif defined(OS_WIN)
84 const char kIncognitoModeShortcut[] = "(Ctrl+Shift+N)"; 93 const char kIncognitoModeShortcut[] = "(Ctrl+Shift+N)";
85 #else 94 #else
86 const char kIncognitoModeShortcut[] = "(Shift+Ctrl+N)"; 95 const char kIncognitoModeShortcut[] = "(Shift+Ctrl+N)";
87 #endif 96 #endif
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 191
183 if (result->GetAsDictionary(&result_dict) && 192 if (result->GetAsDictionary(&result_dict) &&
184 result_dict->GetDouble("time", &timestamp) && 193 result_dict->GetDouble("time", &timestamp) &&
185 result_dict->GetString("url", url)) { 194 result_dict->GetString("url", url)) {
186 *time = base::Time::FromJsTime(timestamp); 195 *time = base::Time::FromJsTime(timestamp);
187 return true; 196 return true;
188 } 197 }
189 return false; 198 return false;
190 } 199 }
191 200
201 // Removes all entries in |entry_list| that are older than the |cutoff|.
202 // |entry_list| must already be sorted in reverse chronological order.
203 void RemoveOlderEntries(
204 std::vector<BrowsingHistoryHandler::HistoryEntry>* entry_list,
205 base::Time cutoff) {
206 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it =
207 entry_list->begin(); it != entry_list->end(); ++it) {
208 if (it->time < cutoff) {
209 entry_list->erase(it, entry_list->end());
210 break;
211 }
212 }
213 }
214
215 // Returns true if |entry| represents a local visit that had no corresponding
216 // visit on the server.
217 bool IsLocalOnlyResult(const BrowsingHistoryHandler::HistoryEntry& entry) {
218 return entry.entry_type == BrowsingHistoryHandler::HistoryEntry::LOCAL_ENTRY;
219 }
220
192 } // namespace 221 } // namespace
193 222
194 //////////////////////////////////////////////////////////////////////////////// 223 ////////////////////////////////////////////////////////////////////////////////
195 // 224 //
196 // BrowsingHistoryHandler 225 // BrowsingHistoryHandler
197 // 226 //
198 //////////////////////////////////////////////////////////////////////////////// 227 ////////////////////////////////////////////////////////////////////////////////
199 228
200 BrowsingHistoryHandler::HistoryEntry::HistoryEntry( 229 BrowsingHistoryHandler::HistoryEntry::HistoryEntry(
230 BrowsingHistoryHandler::HistoryEntry::EntryType entry_type,
201 const GURL& url, const string16& title, base::Time time, 231 const GURL& url, const string16& title, base::Time time,
202 const std::set<int64>& timestamps, bool is_search_result, 232 const std::set<int64>& timestamps,
203 const string16& snippet) : all_timestamps(timestamps) { 233 bool is_search_result, const string16& snippet)
234 : all_timestamps(timestamps) {
235 this->entry_type = entry_type;
204 this->url = url; 236 this->url = url;
205 this->title = title; 237 this->title = title;
206 this->time = time; 238 this->time = time;
207 this->is_search_result = is_search_result; 239 this->is_search_result = is_search_result;
208 this->snippet = snippet; 240 this->snippet = snippet;
209 } 241 }
210 242
211 BrowsingHistoryHandler::HistoryEntry::HistoryEntry() 243 BrowsingHistoryHandler::HistoryEntry::HistoryEntry()
212 : is_search_result(false) { 244 : is_search_result(false) {
213 } 245 }
214 246
215 BrowsingHistoryHandler::HistoryEntry::~HistoryEntry() { 247 BrowsingHistoryHandler::HistoryEntry::~HistoryEntry() {
216 } 248 }
217 249
218 void BrowsingHistoryHandler::HistoryEntry::SetUrlAndTitle( 250 void BrowsingHistoryHandler::HistoryEntry::SetUrlAndTitle(
219 DictionaryValue* result) { 251 DictionaryValue* result) const {
220 result->SetString("url", url.spec()); 252 result->SetString("url", url.spec());
221 253
222 bool using_url_as_the_title = false; 254 bool using_url_as_the_title = false;
223 string16 title_to_set(title); 255 string16 title_to_set(title);
224 if (title.empty()) { 256 if (title.empty()) {
225 using_url_as_the_title = true; 257 using_url_as_the_title = true;
226 title_to_set = UTF8ToUTF16(url.spec()); 258 title_to_set = UTF8ToUTF16(url.spec());
227 } 259 }
228 260
229 // Since the title can contain BiDi text, we need to mark the text as either 261 // Since the title can contain BiDi text, we need to mark the text as either
230 // RTL or LTR, depending on the characters in the string. If we use the URL 262 // RTL or LTR, depending on the characters in the string. If we use the URL
231 // as the title, we mark the title as LTR since URLs are always treated as 263 // as the title, we mark the title as LTR since URLs are always treated as
232 // left to right strings. 264 // left to right strings.
233 if (base::i18n::IsRTL()) { 265 if (base::i18n::IsRTL()) {
234 if (using_url_as_the_title) 266 if (using_url_as_the_title)
235 base::i18n::WrapStringWithLTRFormatting(&title_to_set); 267 base::i18n::WrapStringWithLTRFormatting(&title_to_set);
236 else 268 else
237 base::i18n::AdjustStringForLocaleDirection(&title_to_set); 269 base::i18n::AdjustStringForLocaleDirection(&title_to_set);
238 } 270 }
239 result->SetString("title", title_to_set); 271 result->SetString("title", title_to_set);
240 } 272 }
241 273
242 scoped_ptr<DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue( 274 scoped_ptr<DictionaryValue> BrowsingHistoryHandler::HistoryEntry::ToValue(
243 BookmarkModel* bookmark_model, ManagedUserService* managed_user_service) { 275 BookmarkModel* bookmark_model,
276 ManagedUserService* managed_user_service) const {
244 scoped_ptr<DictionaryValue> result(new DictionaryValue()); 277 scoped_ptr<DictionaryValue> result(new DictionaryValue());
245 SetUrlAndTitle(result.get()); 278 SetUrlAndTitle(result.get());
246 result->SetDouble("time", time.ToJsTime()); 279 result->SetDouble("time", time.ToJsTime());
247 280
248 // Pass the timestamps in a list. 281 // Pass the timestamps in a list.
249 scoped_ptr<ListValue> timestamps(new ListValue); 282 scoped_ptr<ListValue> timestamps(new ListValue);
250 for (std::set<int64>::const_iterator it = all_timestamps.begin(); 283 for (std::set<int64>::const_iterator it = all_timestamps.begin();
251 it != all_timestamps.end(); ++it) { 284 it != all_timestamps.end(); ++it) {
252 timestamps->AppendDouble(base::Time::FromInternalValue(*it).ToJsTime()); 285 timestamps->AppendDouble(base::Time::FromInternalValue(*it).ToJsTime());
253 } 286 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 *out_int = static_cast<int>(double_value); 393 *out_int = static_cast<int>(double_value);
361 return true; 394 return true;
362 } 395 }
363 NOTREACHED(); 396 NOTREACHED();
364 return false; 397 return false;
365 } 398 }
366 399
367 void BrowsingHistoryHandler::WebHistoryTimeout() { 400 void BrowsingHistoryHandler::WebHistoryTimeout() {
368 // TODO(dubroy): Communicate the failure to the front end. 401 // TODO(dubroy): Communicate the failure to the front end.
369 if (!results_info_value_.empty()) 402 if (!results_info_value_.empty())
370 ReturnResultsToFrontEnd(false, 0); 403 ReturnResultsToFrontEnd();
404
405 UMA_HISTOGRAM_ENUMERATION(
406 "WebHistory.QueryCompletion",
407 WEB_HISTORY_QUERY_TIMED_OUT, NUM_WEB_HISTORY_QUERY_BUCKETS);
371 } 408 }
372 409
373 void BrowsingHistoryHandler::QueryHistory( 410 void BrowsingHistoryHandler::QueryHistory(
374 string16 search_text, const history::QueryOptions& options) { 411 string16 search_text, const history::QueryOptions& options) {
375 Profile* profile = Profile::FromWebUI(web_ui()); 412 Profile* profile = Profile::FromWebUI(web_ui());
376 413
377 // Anything in-flight is invalid. 414 // Anything in-flight is invalid.
378 history_request_consumer_.CancelAllRequests(); 415 history_request_consumer_.CancelAllRequests();
379 web_history_request_.reset(); 416 web_history_request_.reset();
380 417
381 query_results_.clear(); 418 query_results_.clear();
382 results_info_value_.Clear(); 419 results_info_value_.Clear();
383 420
384 HistoryService* hs = HistoryServiceFactory::GetForProfile( 421 HistoryService* hs = HistoryServiceFactory::GetForProfile(
385 profile, Profile::EXPLICIT_ACCESS); 422 profile, Profile::EXPLICIT_ACCESS);
386 hs->QueryHistory(search_text, 423 hs->QueryHistory(search_text,
387 options, 424 options,
388 &history_request_consumer_, 425 &history_request_consumer_,
389 base::Bind(&BrowsingHistoryHandler::QueryComplete, 426 base::Bind(&BrowsingHistoryHandler::QueryComplete,
390 base::Unretained(this), search_text, options)); 427 base::Unretained(this), search_text, options));
391 428
392 history::WebHistoryService* web_history = 429 history::WebHistoryService* web_history =
393 WebHistoryServiceFactory::GetForProfile(profile); 430 WebHistoryServiceFactory::GetForProfile(profile);
394 if (web_history) { 431 if (web_history) {
432 web_history_query_results_.clear();
395 web_history_request_ = web_history->QueryHistory( 433 web_history_request_ = web_history->QueryHistory(
396 search_text, 434 search_text,
397 options, 435 options,
398 base::Bind(&BrowsingHistoryHandler::WebHistoryQueryComplete, 436 base::Bind(&BrowsingHistoryHandler::WebHistoryQueryComplete,
399 base::Unretained(this), search_text, options)); 437 base::Unretained(this),
438 search_text, options,
439 base::TimeTicks::Now()));
400 // Start a timer so we know when to give up. 440 // Start a timer so we know when to give up.
401 web_history_timer_.Start( 441 web_history_timer_.Start(
402 FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds), 442 FROM_HERE, base::TimeDelta::FromSeconds(kWebHistoryTimeoutSeconds),
403 this, &BrowsingHistoryHandler::WebHistoryTimeout); 443 this, &BrowsingHistoryHandler::WebHistoryTimeout);
404 } 444 }
405 } 445 }
406 446
407 void BrowsingHistoryHandler::HandleQueryHistory(const ListValue* args) { 447 void BrowsingHistoryHandler::HandleQueryHistory(const ListValue* args) {
408 history::QueryOptions options; 448 history::QueryOptions options;
409 449
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 current_day_midnight = it->time.LocalMidnight(); 780 current_day_midnight = it->time.LocalMidnight();
741 } 781 }
742 782
743 // Keep this visit if it's the first visit to this URL on the current day. 783 // Keep this visit if it's the first visit to this URL on the current day.
744 if (current_day_entries.count(it->url) == 0) { 784 if (current_day_entries.count(it->url) == 0) {
745 current_day_entries.insert( 785 current_day_entries.insert(
746 std::pair<GURL,BrowsingHistoryHandler::HistoryEntry>(it->url, *it)); 786 std::pair<GURL,BrowsingHistoryHandler::HistoryEntry>(it->url, *it));
747 new_results.push_back(*it); 787 new_results.push_back(*it);
748 } else { 788 } else {
749 // Keep track of the timestamps of all visits to the URL on the same day. 789 // Keep track of the timestamps of all visits to the URL on the same day.
750 current_day_entries[it->url].all_timestamps.insert( 790 BrowsingHistoryHandler::HistoryEntry* entry =
791 &current_day_entries[it->url];
792 entry->all_timestamps.insert(
751 it->all_timestamps.begin(), it->all_timestamps.end()); 793 it->all_timestamps.begin(), it->all_timestamps.end());
794
795 if (entry->entry_type != it->entry_type) {
796 entry->entry_type =
797 BrowsingHistoryHandler::HistoryEntry::COMBINED_ENTRY;
798 }
752 } 799 }
753 } 800 }
754 results->swap(new_results); 801 results->swap(new_results);
755 } 802 }
756 803
757 void BrowsingHistoryHandler::ReturnResultsToFrontEnd( 804 void BrowsingHistoryHandler::ReturnResultsToFrontEnd() {
758 bool results_need_merge, int max_count) {
759 Profile* profile = Profile::FromWebUI(web_ui()); 805 Profile* profile = Profile::FromWebUI(web_ui());
760 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile); 806 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile);
761 ManagedUserService* managed_user_service = NULL; 807 ManagedUserService* managed_user_service = NULL;
762 #if defined(ENABLE_MANAGED_USERS) 808 #if defined(ENABLE_MANAGED_USERS)
763 managed_user_service = ManagedUserServiceFactory::GetForProfile(profile); 809 managed_user_service = ManagedUserServiceFactory::GetForProfile(profile);
764 #endif 810 #endif
765 811
766 if (results_need_merge) 812 // Combine the local and remote results into |query_results_|, and remove
813 // any duplicates.
814 if (query_results_.size() && web_history_query_results_.size()) {
815 // Each result set covers a particular time range. Determine the
816 // intersection of the two time ranges, discard any entries from either
817 // set the are older than that, and then combine the results.
818 base::Time cutoff_time = std::max(query_results_.back().time,
819 web_history_query_results_.back().time);
820 RemoveOlderEntries(&query_results_, cutoff_time);
821 RemoveOlderEntries(&web_history_query_results_, cutoff_time);
822
823 int local_result_count = query_results_.size();
824 query_results_.insert(query_results_.end(),
825 web_history_query_results_.begin(),
826 web_history_query_results_.end());
767 RemoveDuplicateResults(&query_results_); 827 RemoveDuplicateResults(&query_results_);
768 828
769 // Convert the result vector into a ListValue with at most |max_count| 829 // In the best case, we expect that all local results are duplicated on the
770 // elements. 830 // server. Keep track of how many are missing.
831 if (local_result_count) {
832 int missing_count = std::count_if(
833 query_results_.begin(), query_results_.end(), IsLocalOnlyResult);
834 UMA_HISTOGRAM_PERCENTAGE("WebHistory.LocalResultMissingOnServer",
835 missing_count * 100.0 / local_result_count);
836 }
837 }
838
839 // Convert the result vector into a ListValue.
771 ListValue results_value; 840 ListValue results_value;
772 int query_results_size = static_cast<int>(query_results_.size()); 841 for (std::vector<BrowsingHistoryHandler::HistoryEntry>::iterator it =
773 for (int i = 0; i < query_results_size && i < max_count; ++i) { 842 query_results_.begin(); it != query_results_.end(); ++it) {
774 scoped_ptr<base::Value> value( 843 scoped_ptr<base::Value> value(
775 query_results_[i].ToValue(bookmark_model, managed_user_service)); 844 it->ToValue(bookmark_model, managed_user_service));
776 results_value.Append(value.release()); 845 results_value.Append(value.release());
777 } 846 }
778 847
779 web_ui()->CallJavascriptFunction( 848 web_ui()->CallJavascriptFunction(
780 "historyResult", results_info_value_, results_value); 849 "historyResult", results_info_value_, results_value);
781 results_info_value_.Clear(); 850 results_info_value_.Clear();
782 query_results_.clear(); 851 query_results_.clear();
852 web_history_query_results_.clear();
783 } 853 }
784 854
785 void BrowsingHistoryHandler::QueryComplete( 855 void BrowsingHistoryHandler::QueryComplete(
786 const string16& search_text, 856 const string16& search_text,
787 const history::QueryOptions& options, 857 const history::QueryOptions& options,
788 HistoryService::Handle request_handle, 858 HistoryService::Handle request_handle,
789 history::QueryResults* results) { 859 history::QueryResults* results) {
790 // If we're appending to existing results, they will need merging. 860 DCHECK_EQ(0U, query_results_.size());
791 bool needs_merge = query_results_.size() > 0; 861 query_results_.reserve(results->size());
792 862
793 for (size_t i = 0; i < results->size(); ++i) { 863 for (size_t i = 0; i < results->size(); ++i) {
794 history::URLResult const &page = (*results)[i]; 864 history::URLResult const &page = (*results)[i];
795 865
796 std::set<int64> timestamps; 866 std::set<int64> timestamps;
797 timestamps.insert(page.visit_time().ToInternalValue()); 867 timestamps.insert(page.visit_time().ToInternalValue());
798 868
799 query_results_.push_back( 869 query_results_.push_back(
800 HistoryEntry(page.url(), 870 HistoryEntry(
801 page.title(), 871 HistoryEntry::LOCAL_ENTRY,
802 page.visit_time(), 872 page.url(),
803 timestamps, 873 page.title(),
804 !search_text.empty(), 874 page.visit_time(),
805 page.snippet().text())); 875 timestamps,
876 !search_text.empty(),
877 page.snippet().text()));
806 } 878 }
807 879
808 results_info_value_.SetString("term", search_text); 880 results_info_value_.SetString("term", search_text);
809 results_info_value_.SetBoolean("finished", results->reached_beginning()); 881 results_info_value_.SetBoolean("finished", results->reached_beginning());
810 882
811 // Add the specific dates that were searched to display them. 883 // Add the specific dates that were searched to display them.
812 // TODO(sergiu): Put today if the start is in the future. 884 // TODO(sergiu): Put today if the start is in the future.
813 results_info_value_.SetString("queryStartTime", 885 results_info_value_.SetString("queryStartTime",
814 getRelativeDateLocalized(options.begin_time)); 886 getRelativeDateLocalized(options.begin_time));
815 if (!options.end_time.is_null()) { 887 if (!options.end_time.is_null()) {
816 results_info_value_.SetString("queryEndTime", 888 results_info_value_.SetString("queryEndTime",
817 getRelativeDateLocalized(options.end_time - 889 getRelativeDateLocalized(options.end_time -
818 base::TimeDelta::FromDays(1))); 890 base::TimeDelta::FromDays(1)));
819 } else { 891 } else {
820 results_info_value_.SetString("queryEndTime", 892 results_info_value_.SetString("queryEndTime",
821 getRelativeDateLocalized(base::Time::Now())); 893 getRelativeDateLocalized(base::Time::Now()));
822 } 894 }
823 if (!web_history_timer_.IsRunning()) 895 if (!web_history_timer_.IsRunning())
824 ReturnResultsToFrontEnd(needs_merge, options.max_count); 896 ReturnResultsToFrontEnd();
825 } 897 }
826 898
827 void BrowsingHistoryHandler::WebHistoryQueryComplete( 899 void BrowsingHistoryHandler::WebHistoryQueryComplete(
828 const string16& search_text, 900 const string16& search_text,
829 const history::QueryOptions& options, 901 const history::QueryOptions& options,
902 base::TimeTicks start_time,
830 history::WebHistoryService::Request* request, 903 history::WebHistoryService::Request* request,
831 const DictionaryValue* results_value) { 904 const DictionaryValue* results_value) {
905 base::TimeDelta delta = base::TimeTicks::Now() - start_time;
906 UMA_HISTOGRAM_TIMES("WebHistory.ResponseTime", delta);
907
908 // If the response came in too late, do nothing.
909 // TODO(dubroy): Maybe show a banner, and prompt the user to reload?
910 if (!web_history_timer_.IsRunning())
911 return;
832 web_history_timer_.Stop(); 912 web_history_timer_.Stop();
833 913
914 UMA_HISTOGRAM_ENUMERATION(
915 "WebHistory.QueryCompletion",
916 results_value ? WEB_HISTORY_QUERY_SUCCEEDED : WEB_HISTORY_QUERY_FAILED,
917 NUM_WEB_HISTORY_QUERY_BUCKETS);
918
919 DCHECK_EQ(0U, web_history_query_results_.size());
834 const ListValue* events = NULL; 920 const ListValue* events = NULL;
835 if (results_value && results_value->GetList("event", &events)) { 921 if (results_value && results_value->GetList("event", &events)) {
922 web_history_query_results_.reserve(events->GetSize());
836 for (unsigned int i = 0; i < events->GetSize(); ++i) { 923 for (unsigned int i = 0; i < events->GetSize(); ++i) {
837 const DictionaryValue* event = NULL; 924 const DictionaryValue* event = NULL;
838 const DictionaryValue* result = NULL; 925 const DictionaryValue* result = NULL;
839 const ListValue* results = NULL; 926 const ListValue* results = NULL;
840 const ListValue* ids = NULL; 927 const ListValue* ids = NULL;
841 string16 url; 928 string16 url;
842 string16 title; 929 string16 title;
843 base::Time visit_time; 930 base::Time visit_time;
844 931
845 if (!(events->GetDictionary(i, &event) && 932 if (!(events->GetDictionary(i, &event) &&
(...skipping 27 matching lines...) Expand all
873 base::Time time = base::Time::UnixEpoch() + 960 base::Time time = base::Time::UnixEpoch() +
874 base::TimeDelta::FromMicroseconds(timestamp_usec); 961 base::TimeDelta::FromMicroseconds(timestamp_usec);
875 timestamps.insert(time.ToInternalValue()); 962 timestamps.insert(time.ToInternalValue());
876 963
877 // Use the first timestamp as the visit time for this result. 964 // Use the first timestamp as the visit time for this result.
878 // TODO(dubroy): Use the sane time instead once it is available. 965 // TODO(dubroy): Use the sane time instead once it is available.
879 if (visit_time.is_null()) 966 if (visit_time.is_null())
880 visit_time = time; 967 visit_time = time;
881 } 968 }
882 GURL gurl(url); 969 GURL gurl(url);
883 query_results_.push_back( 970 web_history_query_results_.push_back(
884 HistoryEntry( 971 HistoryEntry(
972 HistoryEntry::REMOTE_ENTRY,
885 gurl, 973 gurl,
886 title, 974 title,
887 visit_time, 975 visit_time,
888 timestamps, 976 timestamps,
889 !search_text.empty(), 977 !search_text.empty(),
890 string16())); 978 string16()));
891 } 979 }
892 } else if (results_value) { 980 } else if (results_value) {
893 NOTREACHED() << "Failed to parse JSON response."; 981 NOTREACHED() << "Failed to parse JSON response.";
894 } 982 }
895 if (!results_info_value_.empty()) 983 if (!results_info_value_.empty())
896 ReturnResultsToFrontEnd(true, options.max_count); 984 ReturnResultsToFrontEnd();
897 } 985 }
898 986
899 void BrowsingHistoryHandler::RemoveComplete() { 987 void BrowsingHistoryHandler::RemoveComplete() {
900 urls_to_be_deleted_.clear(); 988 urls_to_be_deleted_.clear();
901 989
902 // Notify the page that the deletion request succeeded. 990 // Notify the page that the deletion request succeeded.
903 web_ui()->CallJavascriptFunction("deleteComplete"); 991 web_ui()->CallJavascriptFunction("deleteComplete");
904 } 992 }
905 993
906 void BrowsingHistoryHandler::RemoveWebHistoryComplete( 994 void BrowsingHistoryHandler::RemoveWebHistoryComplete(
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" + 1091 return GURL(std::string(chrome::kChromeUIHistoryURL) + "#q=" +
1004 net::EscapeQueryParamValue(UTF16ToUTF8(text), true)); 1092 net::EscapeQueryParamValue(UTF16ToUTF8(text), true));
1005 } 1093 }
1006 1094
1007 // static 1095 // static
1008 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes( 1096 base::RefCountedMemory* HistoryUI::GetFaviconResourceBytes(
1009 ui::ScaleFactor scale_factor) { 1097 ui::ScaleFactor scale_factor) {
1010 return ResourceBundle::GetSharedInstance(). 1098 return ResourceBundle::GetSharedInstance().
1011 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor); 1099 LoadDataResourceBytesForScale(IDR_HISTORY_FAVICON, scale_factor);
1012 } 1100 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/history_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698