| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 on_wallpaper_fetch_completed); | 45 on_wallpaper_fetch_completed); |
| 46 | 46 |
| 47 virtual ~CustomizationWallpaperDownloader(); | 47 virtual ~CustomizationWallpaperDownloader(); |
| 48 | 48 |
| 49 // Start download. | 49 // Start download. |
| 50 void Start(); | 50 void Start(); |
| 51 | 51 |
| 52 // net::URLFetcherDelegate | 52 // net::URLFetcherDelegate |
| 53 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 53 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 54 | 54 |
| 55 // This is called in tests to modify (lower) retry delay. |
| 56 void set_retry_delay_for_testing(base::TimeDelta value) { |
| 57 retry_delay_ = value; |
| 58 } |
| 59 |
| 55 private: | 60 private: |
| 56 // Start new request. | 61 // Start new request. |
| 57 void StartRequest(); | 62 void StartRequest(); |
| 58 | 63 |
| 59 // Schedules retry. | 64 // Schedules retry. |
| 60 void Retry(); | 65 void Retry(); |
| 61 | 66 |
| 62 // Called on UI thread. | 67 // Called on UI thread. |
| 63 void OnWallpaperDirectoryCreated(scoped_ptr<bool> success); | 68 void OnWallpaperDirectoryCreated(scoped_ptr<bool> success); |
| 64 | 69 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 82 | 87 |
| 83 // Full path to temporary file to fetch downloaded wallpper. | 88 // Full path to temporary file to fetch downloaded wallpper. |
| 84 const base::FilePath wallpaper_temporary_file_; | 89 const base::FilePath wallpaper_temporary_file_; |
| 85 | 90 |
| 86 // Pending retry. | 91 // Pending retry. |
| 87 base::OneShotTimer<CustomizationWallpaperDownloader> request_scheduled_; | 92 base::OneShotTimer<CustomizationWallpaperDownloader> request_scheduled_; |
| 88 | 93 |
| 89 // Number of download retries (first attempt is not counted as retry). | 94 // Number of download retries (first attempt is not counted as retry). |
| 90 size_t retries_; | 95 size_t retries_; |
| 91 | 96 |
| 97 // Sleep between retry requests (increasing, see Retry() method for details). |
| 98 // Non-constant value for tests. |
| 99 base::TimeDelta retry_delay_; |
| 100 |
| 92 // Callback supplied by caller. | 101 // Callback supplied by caller. |
| 93 base::Callback<void(bool success, const GURL&)> on_wallpaper_fetch_completed_; | 102 base::Callback<void(bool success, const GURL&)> on_wallpaper_fetch_completed_; |
| 94 | 103 |
| 95 base::WeakPtrFactory<CustomizationWallpaperDownloader> weak_factory_; | 104 base::WeakPtrFactory<CustomizationWallpaperDownloader> weak_factory_; |
| 96 | 105 |
| 97 DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloader); | 106 DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloader); |
| 98 }; | 107 }; |
| 99 | 108 |
| 100 } // namespace chromeos | 109 } // namespace chromeos |
| 101 | 110 |
| 102 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ | 111 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ |
| OLD | NEW |