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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "base/timer.h" | 13 #include "base/timer.h" |
14 #include "chrome/browser/autocomplete/autocomplete.h" | 14 #include "chrome/browser/autocomplete/autocomplete.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_types.h" | 17 #include "chrome/browser/autocomplete/autocomplete_types.h" |
17 | 18 |
18 class AutocompleteControllerDelegate; | 19 class AutocompleteControllerDelegate; |
19 class KeywordProvider; | 20 class KeywordProvider; |
20 class Profile; | 21 class Profile; |
21 class SearchProvider; | 22 class SearchProvider; |
22 | 23 |
| 24 // The AutocompleteController is the center of the autocomplete system. A |
| 25 // class creates an instance of the controller, which in turn creates a set of |
| 26 // AutocompleteProviders to serve it. The owning class can ask the controller |
| 27 // to Start() a query; the controller in turn passes this call down to the |
| 28 // providers, each of which keeps track of its own matches and whether it has |
| 29 // finished processing the query. When a provider gets more matches or finishes |
| 30 // processing, it notifies the controller, which merges the combined matches |
| 31 // together and makes the result available to interested observers. |
| 32 // |
| 33 // The owner may also cancel the current query by calling Stop(), which the |
| 34 // controller will in turn communicate to all the providers. No callbacks will |
| 35 // happen after a request has been stopped. |
| 36 // |
| 37 // IMPORTANT: There is NO THREAD SAFETY built into this portion of the |
| 38 // autocomplete system. All calls to and from the AutocompleteController should |
| 39 // happen on the same thread. AutocompleteProviders are responsible for doing |
| 40 // their own thread management when they need to return matches asynchronously. |
| 41 // |
23 // The coordinator for autocomplete queries, responsible for combining the | 42 // The coordinator for autocomplete queries, responsible for combining the |
24 // matches from a series of providers into one AutocompleteResult. | 43 // matches from a series of providers into one AutocompleteResult. |
25 class AutocompleteController : public AutocompleteProviderListener { | 44 class AutocompleteController : public AutocompleteProviderListener { |
26 public: | 45 public: |
27 // Used to indicate an index that is not selected in a call to Update(). | 46 // Used to indicate an index that is not selected in a call to Update(). |
28 static const int kNoItemSelected; | 47 static const int kNoItemSelected; |
29 | 48 |
30 // Normally, you will call the first constructor. Unit tests can use the | 49 // Normally, you will call the first constructor. Unit tests can use the |
31 // second to set the providers to some known testing providers. The default | 50 // second to set the providers to some known testing providers. The default |
32 // providers will be overridden and the controller will take ownership of the | 51 // providers will be overridden and the controller will take ownership of the |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Are we in Start()? This is used to avoid updating |result_| and sending | 205 // Are we in Start()? This is used to avoid updating |result_| and sending |
187 // notifications until Start() has been invoked on all providers. | 206 // notifications until Start() has been invoked on all providers. |
188 bool in_start_; | 207 bool in_start_; |
189 | 208 |
190 Profile* profile_; | 209 Profile* profile_; |
191 | 210 |
192 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); | 211 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); |
193 }; | 212 }; |
194 | 213 |
195 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ | 214 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_CONTROLLER_H_ |
OLD | NEW |