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

Side by Side Diff: chrome/browser/autocomplete/history_url_provider.cc

Issue 3177020: History provider: style cleanup (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Compile, and all that jazz Created 10 years, 4 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/histogram.h" 10 #include "base/histogram.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/history/history.h" 14 #include "chrome/browser/history/history.h"
15 #include "chrome/browser/history/history_backend.h" 15 #include "chrome/browser/history/history_backend.h"
16 #include "chrome/browser/history/history_database.h" 16 #include "chrome/browser/history/history_database.h"
17 #include "chrome/browser/net/url_fixer_upper.h" 17 #include "chrome/browser/net/url_fixer_upper.h"
18 #include "chrome/browser/pref_service.h" 18 #include "chrome/browser/pref_service.h"
19 #include "chrome/browser/profile.h" 19 #include "chrome/browser/profile.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
22 #include "googleurl/src/gurl.h" 22 #include "googleurl/src/gurl.h"
23 #include "googleurl/src/url_parse.h" 23 #include "googleurl/src/url_parse.h"
24 #include "googleurl/src/url_util.h" 24 #include "googleurl/src/url_util.h"
25 #include "net/base/net_util.h" 25 #include "net/base/net_util.h"
26 26
27 using base::Time; 27 using base::Time;
28 using base::TimeDelta; 28 using base::TimeDelta;
29 using base::TimeTicks; 29 using base::TimeTicks;
30 // TODO(mrossetti): Move these to a more appropriate place.
31 using history::Prefix; 30 using history::Prefix;
32 using history::Prefixes; 31 using history::Prefixes;
33 using history::HistoryMatch; 32 using history::HistoryMatch;
34 using history::HistoryMatches; 33 using history::HistoryMatches;
35 34
36 namespace history { 35 namespace history {
37 36
38 // Returns true if |url| is just a host (e.g. "http://www.google.com/") and 37 // Returns true if |url| is just a host (e.g. "http://www.google.com/") and
39 // not some other subpage (e.g. "http://www.google.com/foo.html"). 38 // not some other subpage (e.g. "http://www.google.com/foo.html").
40 bool IsHostOnly(const GURL& url) { 39 bool IsHostOnly(const GURL& url) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 bool trim_http, 106 bool trim_http,
108 const std::wstring& languages) 107 const std::wstring& languages)
109 : message_loop(MessageLoop::current()), 108 : message_loop(MessageLoop::current()),
110 input(input), 109 input(input),
111 trim_http(trim_http), 110 trim_http(trim_http),
112 cancel(false), 111 cancel(false),
113 failed(false), 112 failed(false),
114 languages(languages) { 113 languages(languages) {
115 } 114 }
116 115
116 HistoryURLProvider::HistoryURLProvider(ACProviderListener* listener,
117 Profile* profile)
118 : AutocompleteProvider(listener, profile, "HistoryURL"),
119 prefixes_(GetPrefixes()),
120 params_(NULL) {
121 }
122
117 void HistoryURLProvider::Start(const AutocompleteInput& input, 123 void HistoryURLProvider::Start(const AutocompleteInput& input,
118 bool minimal_changes) { 124 bool minimal_changes) {
119 // NOTE: We could try hard to do less work in the |minimal_changes| case 125 // NOTE: We could try hard to do less work in the |minimal_changes| case
120 // here; some clever caching would let us reuse the raw matches from the 126 // here; some clever caching would let us reuse the raw matches from the
121 // history DB without re-querying. However, we'd still have to go back to 127 // history DB without re-querying. However, we'd still have to go back to
122 // the history thread to mark these up properly, and if pass 2 is currently 128 // the history thread to mark these up properly, and if pass 2 is currently
123 // running, we'd need to wait for it to return to the main thread before 129 // running, we'd need to wait for it to return to the main thread before
124 // doing this (we can't just write new data for it to read due to thread 130 // doing this (we can't just write new data for it to read due to thread
125 // safety issues). At that point it's just as fast, and easier, to simply 131 // safety issues). At that point it's just as fast, and easier, to simply
126 // re-run the query from scratch and ignore |minimal_changes|. 132 // re-run the query from scratch and ignore |minimal_changes|.
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 else 783 else
778 ++j; 784 ++j;
779 } 785 }
780 } 786 }
781 } 787 }
782 788
783 void HistoryURLProvider::CullPoorMatches(HistoryMatches* matches) const { 789 void HistoryURLProvider::CullPoorMatches(HistoryMatches* matches) const {
784 Time recent_threshold = history::AutocompleteAgeThreshold(); 790 Time recent_threshold = history::AutocompleteAgeThreshold();
785 for (HistoryMatches::iterator i(matches->begin()); i != matches->end();) { 791 for (HistoryMatches::iterator i(matches->begin()); i != matches->end();) {
786 const history::URLRow& url_info(i->url_info); 792 const history::URLRow& url_info(i->url_info);
787 if ((url_info.typed_count() <= 793 if ((url_info.typed_count() <= history::kLowQualityMatchTypedLimit) &&
788 history::kLowQualityMatchTypedLimit) && 794 (url_info.visit_count() <= history::kLowQualityMatchVisitLimit) &&
789 (url_info.visit_count() <=
790 history::kLowQualityMatchVisitLimit) &&
791 (url_info.last_visit() < recent_threshold)) { 795 (url_info.last_visit() < recent_threshold)) {
792 i = matches->erase(i); 796 i = matches->erase(i);
793 } else { 797 } else {
794 ++i; 798 ++i;
795 } 799 }
796 } 800 }
797 } 801 }
798 802
799 void HistoryURLProvider::CullRedirects(history::HistoryBackend* backend, 803 void HistoryURLProvider::CullRedirects(history::HistoryBackend* backend,
800 HistoryMatches* matches, 804 HistoryMatches* matches,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 &match.contents_class); 902 &match.contents_class);
899 } 903 }
900 match.description = UTF16ToWide(info.title()); 904 match.description = UTF16ToWide(info.title());
901 AutocompleteMatch::ClassifyMatchInString(params->input.text(), 905 AutocompleteMatch::ClassifyMatchInString(params->input.text(),
902 UTF16ToWide(info.title()), 906 UTF16ToWide(info.title()),
903 ACMatchClassification::NONE, 907 ACMatchClassification::NONE,
904 &match.description_class); 908 &match.description_class);
905 909
906 return match; 910 return match;
907 } 911 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider.h ('k') | chrome/browser/history/history_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698