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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 private: | 55 private: |
56 // This class is used in tests. | |
57 friend class TestWallpaperImageURLFetcherCallback; | |
58 | |
59 // This is called in tests to modify (lower) retry delay. | |
60 void set_retry_delay_for_testing(double value) { | |
Daniel Erat
2014/04/30 21:23:06
leave this as public; there's a presubmit check th
Alexander Alekseev
2014/05/04 23:30:56
Done.
| |
61 retry_delay_seconds_ = value; | |
62 } | |
63 | |
56 // Start new request. | 64 // Start new request. |
57 void StartRequest(); | 65 void StartRequest(); |
58 | 66 |
59 // Schedules retry. | 67 // Schedules retry. |
60 void Retry(); | 68 void Retry(); |
61 | 69 |
62 // Called on UI thread. | 70 // Called on UI thread. |
63 void OnWallpaperDirectoryCreated(scoped_ptr<bool> success); | 71 void OnWallpaperDirectoryCreated(scoped_ptr<bool> success); |
64 | 72 |
65 // Called on UI thread. | 73 // Called on UI thread. |
(...skipping 16 matching lines...) Expand all Loading... | |
82 | 90 |
83 // Full path to temporary file to fetch downloaded wallpper. | 91 // Full path to temporary file to fetch downloaded wallpper. |
84 const base::FilePath wallpaper_temporary_file_; | 92 const base::FilePath wallpaper_temporary_file_; |
85 | 93 |
86 // Pending retry. | 94 // Pending retry. |
87 base::OneShotTimer<CustomizationWallpaperDownloader> request_scheduled_; | 95 base::OneShotTimer<CustomizationWallpaperDownloader> request_scheduled_; |
88 | 96 |
89 // Number of download retries (first attempt is not counted as retry). | 97 // Number of download retries (first attempt is not counted as retry). |
90 size_t retries_; | 98 size_t retries_; |
91 | 99 |
100 // Sleep between retry requests (increasing, see Retry() method for details). | |
101 // Non-constant value for tests. | |
102 double retry_delay_seconds_; | |
Daniel Erat
2014/04/30 21:23:06
base::TimeDelta
Alexander Alekseev
2014/05/04 23:30:56
Done.
| |
103 | |
92 // Callback supplied by caller. | 104 // Callback supplied by caller. |
93 base::Callback<void(bool success, const GURL&)> on_wallpaper_fetch_completed_; | 105 base::Callback<void(bool success, const GURL&)> on_wallpaper_fetch_completed_; |
94 | 106 |
95 base::WeakPtrFactory<CustomizationWallpaperDownloader> weak_factory_; | 107 base::WeakPtrFactory<CustomizationWallpaperDownloader> weak_factory_; |
96 | 108 |
97 DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloader); | 109 DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloader); |
98 }; | 110 }; |
99 | 111 |
100 } // namespace chromeos | 112 } // namespace chromeos |
101 | 113 |
102 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ | 114 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ |
OLD | NEW |