| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/utility_process_host.h" | 10 #include "chrome/browser/utility_process_host.h" |
| 11 #include "chrome/common/pref_service.h" | 11 #include "chrome/common/pref_service.h" |
| 12 #include "chrome/common/web_resource/web_resource_unpacker.h" | 12 #include "chrome/common/web_resource/web_resource_unpacker.h" |
| 13 | 13 |
| 14 class Profile; | 14 class Profile; |
| 15 | 15 |
| 16 class WebResourceService | 16 class WebResourceService |
| 17 : public UtilityProcessHost::Client { | 17 : public UtilityProcessHost::Client { |
| 18 public: | 18 public: |
| 19 WebResourceService(Profile* profile, | 19 WebResourceService(Profile* profile); |
| 20 MessageLoop* backend_loop); | |
| 21 ~WebResourceService(); | 20 ~WebResourceService(); |
| 22 | 21 |
| 23 // Sleep until cache needs to be updated, but always for at least 5 seconds | 22 // Sleep until cache needs to be updated, but always for at least 5 seconds |
| 24 // so we don't interfere with startup. Then begin updating resources. | 23 // so we don't interfere with startup. Then begin updating resources. |
| 25 void StartAfterDelay(); | 24 void StartAfterDelay(); |
| 26 | 25 |
| 27 // We have successfully pulled data from a resource server; now launch | 26 // We have successfully pulled data from a resource server; now launch |
| 28 // the process that will parse the JSON, and then update the cache. | 27 // the process that will parse the JSON, and then update the cache. |
| 29 void UpdateResourceCache(const std::string& json_data); | 28 void UpdateResourceCache(const std::string& json_data); |
| 30 | 29 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 | 53 |
| 55 // We need to be able to load parsed resource data into preferences file, | 54 // We need to be able to load parsed resource data into preferences file, |
| 56 // and get proper install directory. | 55 // and get proper install directory. |
| 57 PrefService* prefs_; | 56 PrefService* prefs_; |
| 58 | 57 |
| 59 FilePath web_resource_dir_; | 58 FilePath web_resource_dir_; |
| 60 | 59 |
| 61 // Server from which we are currently pulling web resource data. | 60 // Server from which we are currently pulling web resource data. |
| 62 std::wstring web_resource_server_; | 61 std::wstring web_resource_server_; |
| 63 | 62 |
| 64 // Whenever we update resource cache, schedule another task. | |
| 65 MessageLoop* backend_loop_; | |
| 66 | |
| 67 WebResourceFetcher* web_resource_fetcher_; | 63 WebResourceFetcher* web_resource_fetcher_; |
| 68 | 64 |
| 69 ResourceDispatcherHost* resource_dispatcher_host_; | 65 ResourceDispatcherHost* resource_dispatcher_host_; |
| 70 | 66 |
| 71 // Gets mutable dictionary attached to user's preferences, so that we | 67 // Gets mutable dictionary attached to user's preferences, so that we |
| 72 // can write resource data back to user's pref file. | 68 // can write resource data back to user's pref file. |
| 73 DictionaryValue* web_resource_cache_; | 69 DictionaryValue* web_resource_cache_; |
| 74 | 70 |
| 75 // True if we are currently mid-fetch. If we are asked to start a fetch | 71 // True if we are currently mid-fetch. If we are asked to start a fetch |
| 76 // when we are still fetching resource data, schedule another one in | 72 // when we are still fetching resource data, schedule another one in |
| (...skipping 11 matching lines...) Expand all Loading... |
| 88 | 84 |
| 89 // Name of directory inside the profile where we will store resource-related | 85 // Name of directory inside the profile where we will store resource-related |
| 90 // data (for now, thumbnail images). | 86 // data (for now, thumbnail images). |
| 91 static const char* kResourceDirectoryName; | 87 static const char* kResourceDirectoryName; |
| 92 | 88 |
| 93 DISALLOW_COPY_AND_ASSIGN(WebResourceService); | 89 DISALLOW_COPY_AND_ASSIGN(WebResourceService); |
| 94 }; | 90 }; |
| 95 | 91 |
| 96 #endif // CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ | 92 #endif // CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ |
| 97 | 93 |
| OLD | NEW |