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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 14 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
16 #include "chrome/browser/autocomplete/autocomplete_result.h" | 16 #include "chrome/browser/autocomplete/autocomplete_result.h" |
17 #include "components/autocomplete/autocomplete_input.h" | 17 #include "components/autocomplete/autocomplete_input.h" |
18 | 18 |
19 class AutocompleteControllerDelegate; | 19 class AutocompleteControllerDelegate; |
20 class HistoryURLProvider; | 20 class HistoryURLProvider; |
21 class KeywordProvider; | 21 class KeywordProvider; |
22 class Profile; | 22 class Profile; |
23 class SearchProvider; | 23 class SearchProvider; |
24 class TemplateURLService; | |
24 class ZeroSuggestProvider; | 25 class ZeroSuggestProvider; |
25 | 26 |
26 // The AutocompleteController is the center of the autocomplete system. A | 27 // The AutocompleteController is the center of the autocomplete system. A |
27 // class creates an instance of the controller, which in turn creates a set of | 28 // class creates an instance of the controller, which in turn creates a set of |
28 // AutocompleteProviders to serve it. The owning class can ask the controller | 29 // AutocompleteProviders to serve it. The owning class can ask the controller |
29 // to Start() a query; the controller in turn passes this call down to the | 30 // to Start() a query; the controller in turn passes this call down to the |
30 // providers, each of which keeps track of its own matches and whether it has | 31 // providers, each of which keeps track of its own matches and whether it has |
31 // finished processing the query. When a provider gets more matches or finishes | 32 // finished processing the query. When a provider gets more matches or finishes |
32 // processing, it notifies the controller, which merges the combined matches | 33 // processing, it notifies the controller, which merges the combined matches |
33 // together and makes the result available to interested observers. | 34 // together and makes the result available to interested observers. |
34 // | 35 // |
35 // The owner may also cancel the current query by calling Stop(), which the | 36 // The owner may also cancel the current query by calling Stop(), which the |
36 // controller will in turn communicate to all the providers. No callbacks will | 37 // controller will in turn communicate to all the providers. No callbacks will |
37 // happen after a request has been stopped. | 38 // happen after a request has been stopped. |
38 // | 39 // |
39 // IMPORTANT: There is NO THREAD SAFETY built into this portion of the | 40 // IMPORTANT: There is NO THREAD SAFETY built into this portion of the |
40 // autocomplete system. All calls to and from the AutocompleteController should | 41 // autocomplete system. All calls to and from the AutocompleteController should |
41 // happen on the same thread. AutocompleteProviders are responsible for doing | 42 // happen on the same thread. AutocompleteProviders are responsible for doing |
42 // their own thread management when they need to return matches asynchronously. | 43 // their own thread management when they need to return matches asynchronously. |
43 // | 44 // |
44 // The coordinator for autocomplete queries, responsible for combining the | 45 // The coordinator for autocomplete queries, responsible for combining the |
45 // matches from a series of providers into one AutocompleteResult. | 46 // matches from a series of providers into one AutocompleteResult. |
46 class AutocompleteController : public AutocompleteProviderListener { | 47 class AutocompleteController : public AutocompleteProviderListener { |
47 public: | 48 public: |
48 // |provider_types| is a bitmap containing AutocompleteProvider::Type values | 49 // |provider_types| is a bitmap containing AutocompleteProvider::Type values |
49 // that will (potentially, depending on platform, flags, etc.) be | 50 // that will (potentially, depending on platform, flags, etc.) be |
50 // instantiated. | 51 // instantiated. |template_url_service| is used to create URLs from the |
52 // autocomplete results. | |
51 AutocompleteController(Profile* profile, | 53 AutocompleteController(Profile* profile, |
52 AutocompleteControllerDelegate* delegate, | 54 AutocompleteControllerDelegate* delegate, |
53 int provider_types); | 55 int provider_types, |
56 TemplateURLService* template_url_service); | |
Peter Kasting
2014/06/30 22:42:09
Nit: Place this right after the Profile* argument
Jun Mukai
2014/06/30 23:52:35
Done.
| |
54 ~AutocompleteController(); | 57 ~AutocompleteController(); |
55 | 58 |
56 // Starts an autocomplete query, which continues until all providers are | 59 // Starts an autocomplete query, which continues until all providers are |
57 // done or the query is Stop()ed. It is safe to Start() a new query without | 60 // done or the query is Stop()ed. It is safe to Start() a new query without |
58 // Stop()ing the previous one. | 61 // Stop()ing the previous one. |
59 // | 62 // |
60 // See AutocompleteInput::AutocompleteInput(...) for more details regarding | 63 // See AutocompleteInput::AutocompleteInput(...) for more details regarding |
61 // |input| params. | 64 // |input| params. |
62 // | 65 // |
63 // The controller calls AutocompleteControllerDelegate::OnResultChanged() from | 66 // The controller calls AutocompleteControllerDelegate::OnResultChanged() from |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 // and doesn't expect it to change. | 233 // and doesn't expect it to change. |
231 const base::TimeDelta stop_timer_duration_; | 234 const base::TimeDelta stop_timer_duration_; |
232 | 235 |
233 // True if a query is not currently running. | 236 // True if a query is not currently running. |
234 bool done_; | 237 bool done_; |
235 | 238 |
236 // Are we in Start()? This is used to avoid updating |result_| and sending | 239 // Are we in Start()? This is used to avoid updating |result_| and sending |
237 // notifications until Start() has been invoked on all providers. | 240 // notifications until Start() has been invoked on all providers. |
238 bool in_start_; | 241 bool in_start_; |
239 | 242 |
240 Profile* profile_; | 243 TemplateURLService* template_url_service_; |
241 | 244 |
242 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); | 245 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); |
243 }; | 246 }; |
244 | 247 |
245 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ | 248 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ |
OLD | NEW |