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

Side by Side Diff: chrome/browser/policy/app_pack_updater.h

Issue 11572044: Automatically retry the following URLFetchers when the network changes: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Document the retry behavior Created 8 years 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) 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_POLICY_APP_PACK_UPDATER_H_ 5 #ifndef CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_
6 #define CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_ 6 #define CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
18 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" 18 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h"
19 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 #include "net/base/network_change_notifier.h"
22 21
23 class GURL; 22 class GURL;
24 23
25 namespace extensions { 24 namespace extensions {
26 class CrxInstaller; 25 class CrxInstaller;
27 class ExtensionDownloader; 26 class ExtensionDownloader;
28 class ExternalLoader; 27 class ExternalLoader;
29 } 28 }
30 29
31 namespace net { 30 namespace net {
32 class URLRequestContextGetter; 31 class URLRequestContextGetter;
33 } 32 }
34 33
35 namespace tracked_objects { 34 namespace tracked_objects {
36 class Location; 35 class Location;
37 } 36 }
38 37
39 namespace policy { 38 namespace policy {
40 39
41 class AppPackExternalLoader; 40 class AppPackExternalLoader;
42 class EnterpriseInstallAttributes; 41 class EnterpriseInstallAttributes;
43 42
44 // The AppPackUpdater manages a set of extensions that are configured via a 43 // The AppPackUpdater manages a set of extensions that are configured via a
45 // device policy to be locally cached and installed into the Demo user account 44 // device policy to be locally cached and installed into the Demo user account
46 // at login time. 45 // at login time.
47 class AppPackUpdater : public content::NotificationObserver, 46 class AppPackUpdater : public content::NotificationObserver,
48 public net::NetworkChangeNotifier::IPAddressObserver,
49 public extensions::ExtensionDownloaderDelegate { 47 public extensions::ExtensionDownloaderDelegate {
50 public: 48 public:
51 // Callback to listen for updates to the screensaver extension's path. 49 // Callback to listen for updates to the screensaver extension's path.
52 typedef base::Callback<void(const FilePath&)> ScreenSaverUpdateCallback; 50 typedef base::Callback<void(const FilePath&)> ScreenSaverUpdateCallback;
53 51
54 // Keys for the entries in the AppPack dictionary policy. 52 // Keys for the entries in the AppPack dictionary policy.
55 static const char kExtensionId[]; 53 static const char kExtensionId[];
56 static const char kUpdateUrl[]; 54 static const char kUpdateUrl[];
57 55
58 // The |request_context| is used for the update checks. 56 // The |request_context| is used for the update checks.
(...skipping 11 matching lines...) Expand all
70 // exists. Subsequent calls will override the previous |callback|. A null 68 // exists. Subsequent calls will override the previous |callback|. A null
71 // |callback| can be used to remove a previous callback. 69 // |callback| can be used to remove a previous callback.
72 void SetScreenSaverUpdateCallback(const ScreenSaverUpdateCallback& callback); 70 void SetScreenSaverUpdateCallback(const ScreenSaverUpdateCallback& callback);
73 71
74 // If a user of one of the AppPack's extensions detects that the extension 72 // If a user of one of the AppPack's extensions detects that the extension
75 // is damaged then this method can be used to remove it from the cache and 73 // is damaged then this method can be used to remove it from the cache and
76 // retry to download it after a restart. 74 // retry to download it after a restart.
77 void OnDamagedFileDetected(const FilePath& path); 75 void OnDamagedFileDetected(const FilePath& path);
78 76
79 private: 77 private:
80 struct AppPackEntry {
81 std::string update_url;
82 bool update_checked;
83 };
84
85 struct CacheEntry { 78 struct CacheEntry {
86 std::string path; 79 std::string path;
87 std::string cached_version; 80 std::string cached_version;
88 }; 81 };
89 82
90 // Maps an extension ID to its update URL and update information. 83 // Maps an extension ID to its update URL.
91 typedef std::map<std::string, AppPackEntry> PolicyEntryMap; 84 typedef std::map<std::string, std::string> PolicyEntryMap;
92 85
93 // Maps an extension ID to a CacheEntry. 86 // Maps an extension ID to a CacheEntry.
94 typedef std::map<std::string, CacheEntry> CacheEntryMap; 87 typedef std::map<std::string, CacheEntry> CacheEntryMap;
95 88
96 void Init(); 89 void Init();
97 90
98 // content::NotificationObserver: 91 // content::NotificationObserver:
99 virtual void Observe(int type, 92 virtual void Observe(int type,
100 const content::NotificationSource& source, 93 const content::NotificationSource& source,
101 const content::NotificationDetails& details) OVERRIDE; 94 const content::NotificationDetails& details) OVERRIDE;
102 95
103 // net::NetworkChangeNotifier::IPAddressObserver:
104 virtual void OnIPAddressChanged() OVERRIDE;
105
106 // Loads the current policy and schedules a cache update. 96 // Loads the current policy and schedules a cache update.
107 void LoadPolicy(); 97 void LoadPolicy();
108 98
109 // Starts a cache update check immediately. 99 // Starts a cache update check immediately.
110 void CheckCacheNow(); 100 void CheckCacheNow();
111 101
112 // Performs a cache update check on the blocking pool. |app_pack_updater| is 102 // Performs a cache update check on the blocking pool. |app_pack_updater| is
113 // used to reply in the UI thread. |valid_ids| contains the list of IDs that 103 // used to reply in the UI thread. |valid_ids| contains the list of IDs that
114 // are currently configured by policy; anything else is invalid, and should 104 // are currently configured by policy; anything else is invalid, and should
115 // be removed from the cache. |valid_ids| is owned by the posted task. 105 // be removed from the cache. |valid_ids| is owned by the posted task.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 void OnCrxInstallFailed(extensions::CrxInstaller* installer); 169 void OnCrxInstallFailed(extensions::CrxInstaller* installer);
180 170
181 // Helper to post blocking IO tasks to the blocking pool. 171 // Helper to post blocking IO tasks to the blocking pool.
182 void PostBlockingTask(const tracked_objects::Location& from_here, 172 void PostBlockingTask(const tracked_objects::Location& from_here,
183 const base::Closure& task); 173 const base::Closure& task);
184 174
185 // Sets |screen_saver_path_| and invokes |screen_saver_update_callback_| if 175 // Sets |screen_saver_path_| and invokes |screen_saver_update_callback_| if
186 // appropriate. 176 // appropriate.
187 void SetScreenSaverPath(const FilePath& path); 177 void SetScreenSaverPath(const FilePath& path);
188 178
189 // Marks extension |id| in |app_pack_extensions_| as having already been
190 // checked for updates, if it exists.
191 void SetUpdateChecked(const std::string& id);
192
193 base::WeakPtrFactory<AppPackUpdater> weak_ptr_factory_; 179 base::WeakPtrFactory<AppPackUpdater> weak_ptr_factory_;
194 180
195 // Observes failures to install CRX files. 181 // Observes failures to install CRX files.
196 content::NotificationRegistrar notification_registrar_; 182 content::NotificationRegistrar notification_registrar_;
197 183
198 // Unique sequence token so that tasks posted by the AppPackUpdater are 184 // Unique sequence token so that tasks posted by the AppPackUpdater are
199 // executed sequentially in the blocking pool. 185 // executed sequentially in the blocking pool.
200 base::SequencedWorkerPool::SequenceToken worker_pool_token_; 186 base::SequencedWorkerPool::SequenceToken worker_pool_token_;
201 187
202 // Whether the updater has initialized. This is only done if the device is in 188 // Whether the updater has initialized. This is only done if the device is in
(...skipping 30 matching lines...) Expand all
233 219
234 // For checking the device mode. 220 // For checking the device mode.
235 EnterpriseInstallAttributes* install_attributes_; 221 EnterpriseInstallAttributes* install_attributes_;
236 222
237 DISALLOW_COPY_AND_ASSIGN(AppPackUpdater); 223 DISALLOW_COPY_AND_ASSIGN(AppPackUpdater);
238 }; 224 };
239 225
240 } // namespace policy 226 } // namespace policy
241 227
242 #endif // CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_ 228 #endif // CHROME_BROWSER_POLICY_APP_PACK_UPDATER_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/gaia/gaia_oauth_fetcher.cc ('k') | chrome/browser/policy/app_pack_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698