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