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_UI_WEBUI_PREDICTORS_PREDICTORS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PREDICTORS_PREDICTORS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_PREDICTORS_PREDICTORS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PREDICTORS_PREDICTORS_HANDLER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 10 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
11 #include "content/public/browser/web_ui_message_handler.h" | 11 #include "content/public/browser/web_ui_message_handler.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class ListValue; | 14 class ListValue; |
15 } | 15 } |
16 | 16 |
17 namespace predictors { | 17 namespace predictors { |
18 class AutocompleteActionPredictor; | 18 class AutocompleteActionPredictor; |
19 class ResourcePrefetchPredictor; | 19 class LoadingPredictor; |
20 } | 20 } |
21 | 21 |
22 class Profile; | 22 class Profile; |
23 | 23 |
24 // The handler for Javascript messages for about:predictors. | 24 // The handler for Javascript messages for about:predictors. |
25 class PredictorsHandler : public content::WebUIMessageHandler { | 25 class PredictorsHandler : public content::WebUIMessageHandler { |
26 public: | 26 public: |
27 explicit PredictorsHandler(Profile* profile); | 27 explicit PredictorsHandler(Profile* profile); |
28 ~PredictorsHandler() override; | 28 ~PredictorsHandler() override; |
29 | 29 |
30 // WebUIMessageHandler implementation. | 30 // WebUIMessageHandler implementation. |
31 void RegisterMessages() override; | 31 void RegisterMessages() override; |
32 | 32 |
33 private: | 33 private: |
34 // Synchronously fetches the database from AutocompleteActionPredictor and | 34 // Synchronously fetches the database from AutocompleteActionPredictor and |
35 // calls into JS with the resulting DictionaryValue. | 35 // calls into JS with the resulting DictionaryValue. |
36 void RequestAutocompleteActionPredictorDb(const base::ListValue* args); | 36 void RequestAutocompleteActionPredictorDb(const base::ListValue* args); |
37 | 37 |
38 // Fetches stats for the ResourcePrefetchPredictor and returns it as a | 38 // Fetches stats for the ResourcePrefetchPredictor and returns it as a |
39 // DictionaryValue to the JS. | 39 // DictionaryValue to the JS. |
40 void RequestResourcePrefetchPredictorDb(const base::ListValue* args); | 40 void RequestResourcePrefetchPredictorDb(const base::ListValue* args); |
41 | 41 |
42 // Helper for RequestResourcePrefetchPredictorDb. | 42 // Helper for RequestResourcePrefetchPredictorDb. |
43 void AddPrefetchDataMapToListValue( | 43 void AddPrefetchDataMapToListValue( |
44 const predictors::ResourcePrefetchPredictor::PrefetchDataMap& data_map, | 44 const predictors::ResourcePrefetchPredictor::PrefetchDataMap& data_map, |
45 base::ListValue* db) const; | 45 base::ListValue* db) const; |
46 | 46 |
47 predictors::AutocompleteActionPredictor* autocomplete_action_predictor_; | 47 predictors::AutocompleteActionPredictor* autocomplete_action_predictor_; |
48 predictors::ResourcePrefetchPredictor* resource_prefetch_predictor_; | 48 predictors::LoadingPredictor* loading_predictor_; |
49 | 49 |
50 DISALLOW_COPY_AND_ASSIGN(PredictorsHandler); | 50 DISALLOW_COPY_AND_ASSIGN(PredictorsHandler); |
51 }; | 51 }; |
52 | 52 |
53 #endif // CHROME_BROWSER_UI_WEBUI_PREDICTORS_PREDICTORS_HANDLER_H_ | 53 #endif // CHROME_BROWSER_UI_WEBUI_PREDICTORS_PREDICTORS_HANDLER_H_ |
OLD | NEW |