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_EXTENSIONS_EXTENSION_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <map> | 10 #include <map> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/time.h" | 21 #include "base/time.h" |
22 #include "base/timer.h" | 22 #include "base/timer.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/common/extensions/update_manifest.h" | 24 #include "chrome/common/extensions/update_manifest.h" |
25 #include "chrome/common/net/url_fetcher.h" | 25 #include "chrome/common/net/url_fetcher.h" |
26 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
27 | 27 |
28 class Extension; | 28 class Extension; |
29 class ExtensionPrefs; | 29 class ExtensionPrefs; |
30 class ExtensionUpdaterTest; | 30 class ExtensionUpdaterTest; |
31 class ExtensionUpdaterFileHandler; | |
32 class PrefService; | 31 class PrefService; |
33 class Profile; | 32 class Profile; |
34 class SafeManifestParser; | 33 class SafeManifestParser; |
35 | 34 |
36 // To save on server resources we can request updates for multiple extensions | 35 // To save on server resources we can request updates for multiple extensions |
37 // in one manifest check. This class helps us keep track of the id's for a | 36 // in one manifest check. This class helps us keep track of the id's for a |
38 // given fetch, building up the actual URL, and what if anything to include | 37 // given fetch, building up the actual URL, and what if anything to include |
39 // in the ping parameter. | 38 // in the ping parameter. |
40 class ManifestFetchData { | 39 class ManifestFetchData { |
41 public: | 40 public: |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 228 |
230 static const char* kBlacklistAppID; | 229 static const char* kBlacklistAppID; |
231 | 230 |
232 // Does common work from constructors. | 231 // Does common work from constructors. |
233 void Init(); | 232 void Init(); |
234 | 233 |
235 // Computes when to schedule the first update check. | 234 // Computes when to schedule the first update check. |
236 base::TimeDelta DetermineFirstCheckDelay(); | 235 base::TimeDelta DetermineFirstCheckDelay(); |
237 | 236 |
238 // URLFetcher::Delegate interface. | 237 // URLFetcher::Delegate interface. |
239 virtual void OnURLFetchComplete(const URLFetcher* source, | 238 virtual void OnURLFetchComplete(const URLFetcher* source); |
240 const GURL& url, | |
241 const net::URLRequestStatus& status, | |
242 int response_code, | |
243 const net::ResponseCookies& cookies, | |
244 const std::string& data); | |
245 | 239 |
246 // These do the actual work when a URL fetch completes. | 240 // These do the actual work when a URL fetch completes. |
247 virtual void OnManifestFetchComplete(const GURL& url, | 241 virtual void OnManifestFetchComplete(const GURL& url, |
248 const net::URLRequestStatus& status, | 242 const net::URLRequestStatus& status, |
249 int response_code, | 243 int response_code, |
250 const std::string& data); | 244 const std::string& data); |
251 virtual void OnCRXFetchComplete(const GURL& url, | 245 |
| 246 virtual void OnCRXFetchComplete(const URLFetcher* source, |
| 247 const GURL& url, |
252 const net::URLRequestStatus& status, | 248 const net::URLRequestStatus& status, |
253 int response_code, | 249 int response_code); |
254 const std::string& data); | |
255 | 250 |
256 // Called when a crx file has been written into a temp file, and is ready | 251 // Called when a crx file has been written into a temp file, and is ready |
257 // to be installed. | 252 // to be installed. |
258 void OnCRXFileWritten(const std::string& id, | 253 void OnCRXFileWritten(const std::string& id, |
259 const FilePath& path, | 254 const FilePath& path, |
260 const GURL& download_url); | 255 const GURL& download_url); |
261 | 256 |
262 // Called when we encountered an error writing a crx file to a temp file. | 257 // Called when we encountered an error writing a crx file to a temp file. |
263 void OnCRXFileWriteError(const std::string& id); | 258 void OnCRXFileWriteError(const std::string& id); |
264 | 259 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 base::OneShotTimer<ExtensionUpdater> timer_; | 336 base::OneShotTimer<ExtensionUpdater> timer_; |
342 int frequency_seconds_; | 337 int frequency_seconds_; |
343 | 338 |
344 ScopedRunnableMethodFactory<ExtensionUpdater> method_factory_; | 339 ScopedRunnableMethodFactory<ExtensionUpdater> method_factory_; |
345 | 340 |
346 bool will_check_soon_; | 341 bool will_check_soon_; |
347 | 342 |
348 ExtensionPrefs* extension_prefs_; | 343 ExtensionPrefs* extension_prefs_; |
349 PrefService* prefs_; | 344 PrefService* prefs_; |
350 Profile* profile_; | 345 Profile* profile_; |
351 | |
352 scoped_refptr<ExtensionUpdaterFileHandler> file_handler_; | |
353 bool blacklist_checks_enabled_; | 346 bool blacklist_checks_enabled_; |
354 | 347 |
355 // The ids of extensions that have in-progress update checks. | 348 // The ids of extensions that have in-progress update checks. |
356 std::set<std::string> in_progress_ids_; | 349 std::set<std::string> in_progress_ids_; |
357 | 350 |
358 FRIEND_TEST(ExtensionUpdaterTest, TestStartUpdateCheckMemory); | 351 FRIEND_TEST(ExtensionUpdaterTest, TestStartUpdateCheckMemory); |
359 FRIEND_TEST(ExtensionUpdaterTest, TestAfterStopBehavior); | 352 FRIEND_TEST(ExtensionUpdaterTest, TestAfterStopBehavior); |
360 | 353 |
361 DISALLOW_COPY_AND_ASSIGN(ExtensionUpdater); | 354 DISALLOW_COPY_AND_ASSIGN(ExtensionUpdater); |
362 }; | 355 }; |
363 | 356 |
364 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ | 357 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_UPDATER_H_ |
OLD | NEW |