OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autocomplete/history_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/autocomplete/autocomplete_match.h" | 15 #include "chrome/browser/autocomplete/autocomplete_match.h" |
16 #include "chrome/browser/history/history.h" | 16 #include "chrome/browser/history/history.h" |
17 #include "chrome/browser/history/history_backend.h" | 17 #include "chrome/browser/history/history_backend.h" |
18 #include "chrome/browser/history/history_database.h" | 18 #include "chrome/browser/history/history_database.h" |
19 #include "chrome/browser/history/history_field_trial.h" | |
20 #include "chrome/browser/history/history_types.h" | 19 #include "chrome/browser/history/history_types.h" |
21 #include "chrome/browser/net/url_fixer_upper.h" | 20 #include "chrome/browser/net/url_fixer_upper.h" |
22 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
23 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
25 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
26 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
27 #include "googleurl/src/url_parse.h" | 26 #include "googleurl/src/url_parse.h" |
28 #include "googleurl/src/url_util.h" | 27 #include "googleurl/src/url_util.h" |
29 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 HistoryURLProviderParams* params) { | 344 HistoryURLProviderParams* params) { |
346 // We may get called with a NULL database if it couldn't be properly | 345 // We may get called with a NULL database if it couldn't be properly |
347 // initialized. | 346 // initialized. |
348 if (!db) { | 347 if (!db) { |
349 params->failed = true; | 348 params->failed = true; |
350 } else if (!params->cancel_flag.IsSet()) { | 349 } else if (!params->cancel_flag.IsSet()) { |
351 base::TimeTicks beginning_time = base::TimeTicks::Now(); | 350 base::TimeTicks beginning_time = base::TimeTicks::Now(); |
352 | 351 |
353 DoAutocomplete(backend, db, params); | 352 DoAutocomplete(backend, db, params); |
354 | 353 |
355 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryAsyncQueryTime" + | 354 UMA_HISTOGRAM_TIMES("Autocomplete.HistoryAsyncQueryTime", |
356 history::HistoryFieldTrial::GetGroupSuffix(), | |
357 base::TimeTicks::Now() - beginning_time); | 355 base::TimeTicks::Now() - beginning_time); |
358 } | 356 } |
359 | 357 |
360 // Return the results (if any) to the main thread. | 358 // Return the results (if any) to the main thread. |
361 params->message_loop->PostTask(FROM_HERE, base::Bind( | 359 params->message_loop->PostTask(FROM_HERE, base::Bind( |
362 &HistoryURLProvider::QueryComplete, this, params)); | 360 &HistoryURLProvider::QueryComplete, this, params)); |
363 } | 361 } |
364 | 362 |
365 // Used by both autocomplete passes, and therefore called on multiple different | 363 // Used by both autocomplete passes, and therefore called on multiple different |
366 // threads (though not simultaneously). | 364 // threads (though not simultaneously). |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 &match.contents_class); | 931 &match.contents_class); |
934 } | 932 } |
935 match.description = info.title(); | 933 match.description = info.title(); |
936 AutocompleteMatch::ClassifyMatchInString(params->input.text(), | 934 AutocompleteMatch::ClassifyMatchInString(params->input.text(), |
937 info.title(), | 935 info.title(), |
938 ACMatchClassification::NONE, | 936 ACMatchClassification::NONE, |
939 &match.description_class); | 937 &match.description_class); |
940 | 938 |
941 return match; | 939 return match; |
942 } | 940 } |
OLD | NEW |