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

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

Issue 236013002: Apply default wallpaper from customization manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After-review. Created 6 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_
7
8 #include <string>
9
10 #include "base/bind.h"
11 #include "base/files/file_path.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h"
15 #include "base/timer/timer.h"
16 #include "chrome/browser/chromeos/customization_document.h"
17 #include "net/url_request/url_fetcher.h"
18 #include "url/gurl.h"
19
20 namespace chromeos {
21
22 // Download customized wallpaper.
23 // ServicesCustomizationDocument::OnCustomizedWallpaperDownloaded() in called on
Daniel Erat 2014/04/14 15:26:15 nit: s/in/is/
Alexander Alekseev 2014/04/15 01:57:16 Done.
24 // success.
25 class CustomizationWallpaperDownloader : public net::URLFetcherDelegate {
26 public:
27 CustomizationWallpaperDownloader(
28 net::URLRequestContextGetter* url_context_getter,
29 const GURL& wallpaper_url,
30 const base::FilePath& wallpaper_dir,
31 const base::FilePath& wallpaper_downloaded_file,
32 base::Callback<void(const GURL&)> on_url_fetched);
33
34 virtual ~CustomizationWallpaperDownloader();
35
36 // Start download.
37 void Start();
38
39 // net::URLFetcherDelegate
40 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
41
42 private:
43 // Start new request.
44 void StartRequest();
45
46 // Schedules retry.
47 void Retry();
48
49 // Create wallpaper cache directory and analyze result.
50 // Called on BlockingPool.
51 static void CreateWallpaperDirectory(const base::FilePath& wallpaper_dir,
52 bool* success);
53 // Called on UI thread.
54 void OnWallpaperDirectoryCreated(scoped_ptr<bool> success);
55
56 // Rename temporary file to wallpaper file and analyze result.
57 // Called on BlockingPool.
58 static void RenameTemporaryFile(const base::FilePath& from,
59 const base::FilePath& to,
60 bool* success);
61
62 // Called on UI thread.
63 void OnTemporaryFileRenamed(scoped_ptr<bool> success);
64
65 scoped_refptr<net::URLRequestContextGetter> url_context_getter_;
Daniel Erat 2014/04/14 15:26:15 add comments to all members describing what they'r
Alexander Alekseev 2014/04/15 01:57:16 Done.
66
67 scoped_ptr<net::URLFetcher> url_fetcher_;
68
69 const GURL wallpaper_url_;
70
71 const base::FilePath wallpaper_dir_;
72
73 const base::FilePath wallpaper_downloaded_file_;
74
75 const base::FilePath wallpaper_temporary_file_;
76
77 // Pending retry.
78 base::OneShotTimer<CustomizationWallpaperDownloader> request_scheduled_;
79
80 // Number of retry attempts.
81 unsigned retries_;
Daniel Erat 2014/04/14 15:26:15 just make this be an int
Alexander Alekseev 2014/04/15 01:57:16 Done.
82
83 // Callback supplied by caller.
84 base::Callback<void(const GURL&)> on_url_fetched_;
85
86 base::WeakPtrFactory<CustomizationWallpaperDownloader> weak_factory_;
87
88 DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloader);
89 };
90
91 } // namespace chromeos
92
93 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698