Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/browser/chromeos/customization_wallpaper_downloader.h

Issue 253833006: Add browser test for CustomizationWallpaperDownloader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
60 base::TimeDelta retry_current_delay_for_testing() const {
61 return retry_current_delay_;
62 }
63
55 private: 64 private:
56 // Start new request. 65 // Start new request.
57 void StartRequest(); 66 void StartRequest();
58 67
59 // Schedules retry. 68 // Schedules retry.
60 void Retry(); 69 void Retry();
61 70
62 // Called on UI thread. 71 // Called on UI thread.
63 void OnWallpaperDirectoryCreated(scoped_ptr<bool> success); 72 void OnWallpaperDirectoryCreated(scoped_ptr<bool> success);
64 73
(...skipping 17 matching lines...) Expand all
82 91
83 // Full path to temporary file to fetch downloaded wallpper. 92 // Full path to temporary file to fetch downloaded wallpper.
84 const base::FilePath wallpaper_temporary_file_; 93 const base::FilePath wallpaper_temporary_file_;
85 94
86 // Pending retry. 95 // Pending retry.
87 base::OneShotTimer<CustomizationWallpaperDownloader> request_scheduled_; 96 base::OneShotTimer<CustomizationWallpaperDownloader> request_scheduled_;
88 97
89 // Number of download retries (first attempt is not counted as retry). 98 // Number of download retries (first attempt is not counted as retry).
90 size_t retries_; 99 size_t retries_;
91 100
101 // Sleep between retry requests (increasing, see Retry() method for details).
102 // Non-constant value for tests.
103 base::TimeDelta retry_delay_;
104
105 // Retry delay of the last attempt. For testing only.
106 base::TimeDelta retry_current_delay_;
107
92 // Callback supplied by caller. 108 // Callback supplied by caller.
93 base::Callback<void(bool success, const GURL&)> on_wallpaper_fetch_completed_; 109 base::Callback<void(bool success, const GURL&)> on_wallpaper_fetch_completed_;
94 110
95 base::WeakPtrFactory<CustomizationWallpaperDownloader> weak_factory_; 111 base::WeakPtrFactory<CustomizationWallpaperDownloader> weak_factory_;
96 112
97 DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloader); 113 DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloader);
98 }; 114 };
99 115
100 } // namespace chromeos 116 } // namespace chromeos
101 117
102 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_ 118 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698