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 EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_H_ | 5 #ifndef EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_H_ |
6 #define EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_H_ | 6 #define EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 public: | 57 public: |
58 // A closure which constructs a new ExtensionDownloader to be owned by the | 58 // A closure which constructs a new ExtensionDownloader to be owned by the |
59 // caller. | 59 // caller. |
60 typedef base::Callback<scoped_ptr<ExtensionDownloader>( | 60 typedef base::Callback<scoped_ptr<ExtensionDownloader>( |
61 ExtensionDownloaderDelegate* delegate)> Factory; | 61 ExtensionDownloaderDelegate* delegate)> Factory; |
62 | 62 |
63 // |delegate| is stored as a raw pointer and must outlive the | 63 // |delegate| is stored as a raw pointer and must outlive the |
64 // ExtensionDownloader. | 64 // ExtensionDownloader. |
65 ExtensionDownloader(ExtensionDownloaderDelegate* delegate, | 65 ExtensionDownloader(ExtensionDownloaderDelegate* delegate, |
66 net::URLRequestContextGetter* request_context); | 66 net::URLRequestContextGetter* request_context); |
67 virtual ~ExtensionDownloader(); | 67 ~ExtensionDownloader() override; |
68 | 68 |
69 // Adds |extension| to the list of extensions to check for updates. | 69 // Adds |extension| to the list of extensions to check for updates. |
70 // Returns false if the |extension| can't be updated due to invalid details. | 70 // Returns false if the |extension| can't be updated due to invalid details. |
71 // In that case, no callbacks will be performed on the |delegate_|. | 71 // In that case, no callbacks will be performed on the |delegate_|. |
72 // The |request_id| is passed on as is to the various |delegate_| callbacks. | 72 // The |request_id| is passed on as is to the various |delegate_| callbacks. |
73 // This is used for example by ExtensionUpdater to keep track of when | 73 // This is used for example by ExtensionUpdater to keep track of when |
74 // potentially concurrent update checks complete. | 74 // potentially concurrent update checks complete. |
75 bool AddExtension(const Extension& extension, int request_id); | 75 bool AddExtension(const Extension& extension, int request_id); |
76 | 76 |
77 // Adds extension |id| to the list of extensions to check for updates. | 77 // Adds extension |id| to the list of extensions to check for updates. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Adds all recorded stats taken so far to histogram counts. | 189 // Adds all recorded stats taken so far to histogram counts. |
190 void ReportStats() const; | 190 void ReportStats() const; |
191 | 191 |
192 // Begins an update check. | 192 // Begins an update check. |
193 void StartUpdateCheck(scoped_ptr<ManifestFetchData> fetch_data); | 193 void StartUpdateCheck(scoped_ptr<ManifestFetchData> fetch_data); |
194 | 194 |
195 // Called by RequestQueue when a new manifest fetch request is started. | 195 // Called by RequestQueue when a new manifest fetch request is started. |
196 void CreateManifestFetcher(); | 196 void CreateManifestFetcher(); |
197 | 197 |
198 // net::URLFetcherDelegate implementation. | 198 // net::URLFetcherDelegate implementation. |
199 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 199 void OnURLFetchComplete(const net::URLFetcher* source) override; |
200 | 200 |
201 // Handles the result of a manifest fetch. | 201 // Handles the result of a manifest fetch. |
202 void OnManifestFetchComplete(const GURL& url, | 202 void OnManifestFetchComplete(const GURL& url, |
203 const net::URLRequestStatus& status, | 203 const net::URLRequestStatus& status, |
204 int response_code, | 204 int response_code, |
205 const base::TimeDelta& backoff_delay, | 205 const base::TimeDelta& backoff_delay, |
206 const std::string& data); | 206 const std::string& data); |
207 | 207 |
208 // Once a manifest is parsed, this starts fetches of any relevant crx files. | 208 // Once a manifest is parsed, this starts fetches of any relevant crx files. |
209 // If |results| is null, it means something went wrong when parsing it. | 209 // If |results| is null, it means something went wrong when parsing it. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 bool file_ownership_passed); | 249 bool file_ownership_passed); |
250 | 250 |
251 // Potentially updates an ExtensionFetch's authentication state and returns | 251 // Potentially updates an ExtensionFetch's authentication state and returns |
252 // |true| if the fetch should be retried. Returns |false| if the failure was | 252 // |true| if the fetch should be retried. Returns |false| if the failure was |
253 // not related to authentication, leaving the ExtensionFetch data unmodified. | 253 // not related to authentication, leaving the ExtensionFetch data unmodified. |
254 bool IterateFetchCredentialsAfterFailure(ExtensionFetch* fetch, | 254 bool IterateFetchCredentialsAfterFailure(ExtensionFetch* fetch, |
255 const net::URLRequestStatus& status, | 255 const net::URLRequestStatus& status, |
256 int response_code); | 256 int response_code); |
257 | 257 |
258 // OAuth2TokenService::Consumer implementation. | 258 // OAuth2TokenService::Consumer implementation. |
259 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 259 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
260 const std::string& access_token, | 260 const std::string& access_token, |
261 const base::Time& expiration_time) override; | 261 const base::Time& expiration_time) override; |
262 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 262 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
263 const GoogleServiceAuthError& error) override; | 263 const GoogleServiceAuthError& error) override; |
264 | 264 |
265 ManifestFetchData* CreateManifestFetchData(const GURL& update_url, | 265 ManifestFetchData* CreateManifestFetchData(const GURL& update_url, |
266 int request_id); | 266 int request_id); |
267 | 267 |
268 // The delegate that receives the crx files downloaded by the | 268 // The delegate that receives the crx files downloaded by the |
269 // ExtensionDownloader, and that fills in optional ping and update url data. | 269 // ExtensionDownloader, and that fills in optional ping and update url data. |
270 ExtensionDownloaderDelegate* delegate_; | 270 ExtensionDownloaderDelegate* delegate_; |
271 | 271 |
272 // The request context to use for the URLFetchers. | 272 // The request context to use for the URLFetchers. |
273 scoped_refptr<net::URLRequestContextGetter> request_context_; | 273 scoped_refptr<net::URLRequestContextGetter> request_context_; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 325 |
326 // Used to create WeakPtrs to |this|. | 326 // Used to create WeakPtrs to |this|. |
327 base::WeakPtrFactory<ExtensionDownloader> weak_ptr_factory_; | 327 base::WeakPtrFactory<ExtensionDownloader> weak_ptr_factory_; |
328 | 328 |
329 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader); | 329 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloader); |
330 }; | 330 }; |
331 | 331 |
332 } // namespace extensions | 332 } // namespace extensions |
333 | 333 |
334 #endif // EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_H_ | 334 #endif // EXTENSIONS_BROWSER_UPDATER_EXTENSION_DOWNLOADER_H_ |
OLD | NEW |