OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ |
6 #define CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ | 6 #define CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "content/browser/utility_process_host.h" | 11 #include "content/browser/utility_process_host.h" |
12 #include "content/common/notification_type.h" | 12 #include "content/common/content_notification_types.h" |
13 | 13 |
14 class DictionaryValue; | 14 class DictionaryValue; |
15 class PrefService; | 15 class PrefService; |
16 class ResourceDispatcherHost; | 16 class ResourceDispatcherHost; |
17 | 17 |
18 // A WebResourceService fetches data from a web resource server and store | 18 // A WebResourceService fetches data from a web resource server and store |
19 // locally as user preference. | 19 // locally as user preference. |
20 class WebResourceService : public UtilityProcessHost::Client { | 20 class WebResourceService : public UtilityProcessHost::Client { |
21 public: | 21 public: |
22 // Pass notification_type = NOTIFICATION_TYPE_COUNT if notification is not | 22 // Pass notification_type = NOTIFICATION_TYPE_COUNT if notification is not |
23 // required. | 23 // required. |
24 WebResourceService(PrefService* prefs, | 24 WebResourceService(PrefService* prefs, |
25 const char* web_resource_server, | 25 const char* web_resource_server, |
26 bool apply_locale_to_url_, | 26 bool apply_locale_to_url_, |
27 NotificationType::Type notification_type, | 27 int notification_type, |
28 const char* last_update_time_pref_name, | 28 const char* last_update_time_pref_name, |
29 int start_fetch_delay, | 29 int start_fetch_delay, |
30 int cache_update_delay); | 30 int cache_update_delay); |
31 | 31 |
32 // Sleep until cache needs to be updated, but always for at least 5 seconds | 32 // Sleep until cache needs to be updated, but always for at least 5 seconds |
33 // so we don't interfere with startup. Then begin updating resources. | 33 // so we don't interfere with startup. Then begin updating resources. |
34 void StartAfterDelay(); | 34 void StartAfterDelay(); |
35 | 35 |
36 // We have successfully pulled data from a resource server; now launch | 36 // We have successfully pulled data from a resource server; now launch |
37 // the process that will parse the JSON, and then update the cache. | 37 // the process that will parse the JSON, and then update the cache. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // kCacheUpdateDelay time, and silently exit. | 80 // kCacheUpdateDelay time, and silently exit. |
81 bool in_fetch_; | 81 bool in_fetch_; |
82 | 82 |
83 // URL that hosts the web resource. | 83 // URL that hosts the web resource. |
84 const char* web_resource_server_; | 84 const char* web_resource_server_; |
85 | 85 |
86 // Indicates whether we should append locale to the web resource server URL. | 86 // Indicates whether we should append locale to the web resource server URL. |
87 bool apply_locale_to_url_; | 87 bool apply_locale_to_url_; |
88 | 88 |
89 // Notification type when an update is done. | 89 // Notification type when an update is done. |
90 NotificationType::Type notification_type_; | 90 int notification_type_; |
91 | 91 |
92 // Pref name to store the last update's time. | 92 // Pref name to store the last update's time. |
93 const char* last_update_time_pref_name_; | 93 const char* last_update_time_pref_name_; |
94 | 94 |
95 // Delay on first fetch so we don't interfere with startup. | 95 // Delay on first fetch so we don't interfere with startup. |
96 int start_fetch_delay_; | 96 int start_fetch_delay_; |
97 | 97 |
98 // Delay between calls to update the web resource cache. This delay may be | 98 // Delay between calls to update the web resource cache. This delay may be |
99 // different for different builds of Chrome. | 99 // different for different builds of Chrome. |
100 int cache_update_delay_; | 100 int cache_update_delay_; |
101 | 101 |
102 // True if a task has been set to update the cache when a new web resource | 102 // True if a task has been set to update the cache when a new web resource |
103 // becomes available. | 103 // becomes available. |
104 bool web_resource_update_scheduled_; | 104 bool web_resource_update_scheduled_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(WebResourceService); | 106 DISALLOW_COPY_AND_ASSIGN(WebResourceService); |
107 }; | 107 }; |
108 | 108 |
109 #endif // CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ | 109 #endif // CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ |
OLD | NEW |