| OLD | NEW |
| 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_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/version.h" | 20 #include "base/version.h" |
| 21 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" | 21 #include "chrome/browser/extensions/updater/extension_downloader_delegate.h" |
| 22 #include "chrome/browser/extensions/updater/manifest_fetch_data.h" | 22 #include "chrome/browser/extensions/updater/manifest_fetch_data.h" |
| 23 #include "chrome/browser/extensions/updater/request_queue.h" | 23 #include "chrome/browser/extensions/updater/request_queue.h" |
| 24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/update_manifest.h" | 25 #include "chrome/common/extensions/update_manifest.h" |
| 26 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
| 27 #include "net/url_request/url_fetcher_delegate.h" | 27 #include "net/url_request/url_fetcher_delegate.h" |
| 28 | 28 |
| 29 class Version; | |
| 30 | |
| 31 namespace net { | 29 namespace net { |
| 32 class URLFetcher; | 30 class URLFetcher; |
| 33 class URLRequestContextGetter; | 31 class URLRequestContextGetter; |
| 34 class URLRequestStatus; | 32 class URLRequestStatus; |
| 35 } | 33 } |
| 36 | 34 |
| 37 namespace extensions { | 35 namespace extensions { |
| 38 | 36 |
| 39 struct UpdateDetails { | 37 struct UpdateDetails { |
| 40 UpdateDetails(const std::string& id, const Version& version); | 38 UpdateDetails(const std::string& id, const base::Version& version); |
| 41 ~UpdateDetails(); | 39 ~UpdateDetails(); |
| 42 | 40 |
| 43 std::string id; | 41 std::string id; |
| 44 Version version; | 42 base::Version version; |
| 45 }; | 43 }; |
| 46 | 44 |
| 47 class ExtensionUpdaterTest; | 45 class ExtensionUpdaterTest; |
| 48 | 46 |
| 49 // A class that checks for updates of a given list of extensions, and downloads | 47 // A class that checks for updates of a given list of extensions, and downloads |
| 50 // the crx file when updates are found. It uses a |ExtensionDownloaderDelegate| | 48 // the crx file when updates are found. It uses a |ExtensionDownloaderDelegate| |
| 51 // that takes ownership of the downloaded crx files, and handles events during | 49 // that takes ownership of the downloaded crx files, and handles events during |
| 52 // the update check. | 50 // the update check. |
| 53 class ExtensionDownloader : public net::URLFetcherDelegate { | 51 class ExtensionDownloader : public net::URLFetcherDelegate { |
| 54 public: | 52 public: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 125 |
| 128 std::string id; | 126 std::string id; |
| 129 GURL url; | 127 GURL url; |
| 130 std::string package_hash; | 128 std::string package_hash; |
| 131 std::string version; | 129 std::string version; |
| 132 std::set<int> request_ids; | 130 std::set<int> request_ids; |
| 133 }; | 131 }; |
| 134 | 132 |
| 135 // Helper for AddExtension() and AddPendingExtension(). | 133 // Helper for AddExtension() and AddPendingExtension(). |
| 136 bool AddExtensionData(const std::string& id, | 134 bool AddExtensionData(const std::string& id, |
| 137 const Version& version, | 135 const base::Version& version, |
| 138 Manifest::Type extension_type, | 136 Manifest::Type extension_type, |
| 139 const GURL& extension_update_url, | 137 const GURL& extension_update_url, |
| 140 const std::string& update_url_data, | 138 const std::string& update_url_data, |
| 141 int request_id); | 139 int request_id); |
| 142 | 140 |
| 143 // Adds all recorded stats taken so far to histogram counts. | 141 // Adds all recorded stats taken so far to histogram counts. |
| 144 void ReportStats() const; | 142 void ReportStats() const; |
| 145 | 143 |
| 146 // Begins an update check. | 144 // Begins an update check. |
| 147 void StartUpdateCheck(scoped_ptr<ManifestFetchData> fetch_data); | 145 void StartUpdateCheck(scoped_ptr<ManifestFetchData> fetch_data); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 223 |
| 226 // Maps an extension-id to its PingResult data. | 224 // Maps an extension-id to its PingResult data. |
| 227 std::map<std::string, ExtensionDownloaderDelegate::PingResult> ping_results_; | 225 std::map<std::string, ExtensionDownloaderDelegate::PingResult> ping_results_; |
| 228 | 226 |
| 229 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader); | 227 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader); |
| 230 }; | 228 }; |
| 231 | 229 |
| 232 } // namespace extensions | 230 } // namespace extensions |
| 233 | 231 |
| 234 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ | 232 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_H_ |
| OLD | NEW |