Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: chrome/browser/web_resource/web_resource_service.h

Issue 7259019: Move base/values.h into the base namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/content_notification_types.h" 12 #include "content/common/content_notification_types.h"
13 13
14 class DictionaryValue;
15 class PrefService; 14 class PrefService;
16 class ResourceDispatcherHost; 15 class ResourceDispatcherHost;
17 16
17 namespace base {
18 class DictionaryValue;
19 }
20
18 // A WebResourceService fetches data from a web resource server and store 21 // A WebResourceService fetches data from a web resource server and store
19 // locally as user preference. 22 // locally as user preference.
20 class WebResourceService : public UtilityProcessHost::Client { 23 class WebResourceService : public UtilityProcessHost::Client {
21 public: 24 public:
22 // Pass notification_type = NOTIFICATION_TYPE_COUNT if notification is not 25 // Pass notification_type = NOTIFICATION_TYPE_COUNT if notification is not
23 // required. 26 // required.
24 WebResourceService(PrefService* prefs, 27 WebResourceService(PrefService* prefs,
25 const char* web_resource_server, 28 const char* web_resource_server,
26 bool apply_locale_to_url_, 29 bool apply_locale_to_url_,
27 int notification_type, 30 int notification_type,
28 const char* last_update_time_pref_name, 31 const char* last_update_time_pref_name,
29 int start_fetch_delay, 32 int start_fetch_delay,
30 int cache_update_delay); 33 int cache_update_delay);
31 34
32 // Sleep until cache needs to be updated, but always for at least 5 seconds 35 // 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. 36 // so we don't interfere with startup. Then begin updating resources.
34 void StartAfterDelay(); 37 void StartAfterDelay();
35 38
36 // We have successfully pulled data from a resource server; now launch 39 // We have successfully pulled data from a resource server; now launch
37 // the process that will parse the JSON, and then update the cache. 40 // the process that will parse the JSON, and then update the cache.
38 void UpdateResourceCache(const std::string& json_data); 41 void UpdateResourceCache(const std::string& json_data);
39 42
40 protected: 43 protected:
41 virtual ~WebResourceService(); 44 virtual ~WebResourceService();
42 45
43 virtual void Unpack(const DictionaryValue& parsed_json) = 0; 46 virtual void Unpack(const base::DictionaryValue& parsed_json) = 0;
44 47
45 // If delay_ms is positive, schedule notification with the delay. 48 // If delay_ms is positive, schedule notification with the delay.
46 // If delay_ms is 0, notify immediately by calling WebResourceStateChange(). 49 // If delay_ms is 0, notify immediately by calling WebResourceStateChange().
47 // If delay_ms is negative, do nothing. 50 // If delay_ms is negative, do nothing.
48 void PostNotification(int64 delay_ms); 51 void PostNotification(int64 delay_ms);
49 52
50 // We need to be able to load parsed resource data into preferences file, 53 // We need to be able to load parsed resource data into preferences file,
51 // and get proper install directory. 54 // and get proper install directory.
52 PrefService* prefs_; 55 PrefService* prefs_;
53 56
54 private: 57 private:
55 class WebResourceFetcher; 58 class WebResourceFetcher;
56 friend class WebResourceFetcher; 59 friend class WebResourceFetcher;
57 60
58 class UnpackerClient; 61 class UnpackerClient;
59 62
60 // Set in_fetch_ to false, clean up temp directories (in the future). 63 // Set in_fetch_ to false, clean up temp directories (in the future).
61 void EndFetch(); 64 void EndFetch();
62 65
63 // Puts parsed json data in the right places, and writes to prefs file. 66 // Puts parsed json data in the right places, and writes to prefs file.
64 void OnWebResourceUnpacked(const DictionaryValue& parsed_json); 67 void OnWebResourceUnpacked(const base::DictionaryValue& parsed_json);
65 68
66 // Notify listeners that the state of a web resource has changed. 69 // Notify listeners that the state of a web resource has changed.
67 void WebResourceStateChange(); 70 void WebResourceStateChange();
68 71
69 scoped_ptr<WebResourceFetcher> web_resource_fetcher_; 72 scoped_ptr<WebResourceFetcher> web_resource_fetcher_;
70 73
71 ResourceDispatcherHost* resource_dispatcher_host_; 74 ResourceDispatcherHost* resource_dispatcher_host_;
72 75
73 // Allows the creation of tasks to send a WEB_RESOURCE_STATE_CHANGED 76 // Allows the creation of tasks to send a WEB_RESOURCE_STATE_CHANGED
74 // notification. This allows the WebResourceService to notify the New Tab 77 // notification. This allows the WebResourceService to notify the New Tab
(...skipping 25 matching lines...) Expand all
100 int cache_update_delay_; 103 int cache_update_delay_;
101 104
102 // True if a task has been set to update the cache when a new web resource 105 // True if a task has been set to update the cache when a new web resource
103 // becomes available. 106 // becomes available.
104 bool web_resource_update_scheduled_; 107 bool web_resource_update_scheduled_;
105 108
106 DISALLOW_COPY_AND_ASSIGN(WebResourceService); 109 DISALLOW_COPY_AND_ASSIGN(WebResourceService);
107 }; 110 };
108 111
109 #endif // CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_ 112 #endif // CHROME_BROWSER_WEB_RESOURCE_WEB_RESOURCE_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/web_resource/promo_resource_service.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698