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

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

Issue 208273005: If customization includes default wallpaper, download and apply it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update 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
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
33 virtual ~CustomizationWallpaperDownloader();
34
35 // Start download.
36 void Start();
37
38 // net::URLFetcherDelegate
39 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
40
41 private:
42 // Start new request.
43 void StartRequest();
44
45 // Schedules retry.
46 void Retry();
47
48 // Create wallpaper cache directory and analyze result.
49 // Called on BlockingPool.
50 static void CreateWallpaperDirectory(const base::FilePath& wallpaper_dir,
51 bool* success);
52 // Called on UI thread.
53 void OnWallpaperDirectoryCreated(scoped_ptr<bool> success);
54
55 // Rename temporary file to wallpaper file and analyze result.
56 // Called on BlockingPool.
57 static void RenameTemporaryFile(const base::FilePath& from,
58 const base::FilePath& to,
59 bool* success);
60
61 // Called on UI thread.
62 void OnTemporaryFileRenamed(scoped_ptr<bool> success);
63
64 scoped_refptr<net::URLRequestContextGetter> url_context_getter_;
65
66 scoped_ptr<net::URLFetcher> url_fetcher_;
67
68 const GURL wallpaper_url_;
69
70 const base::FilePath wallpaper_dir_;
71
72 const base::FilePath wallpaper_downloaded_file_;
73
74 const base::FilePath wallpaper_temporary_file_;
75
76 // Pending retry.
77 base::OneShotTimer<CustomizationWallpaperDownloader> request_scheduled_;
78
79 // Number of retry attempts.
80 unsigned retries_;
81
82 base::WeakPtrFactory<CustomizationWallpaperDownloader> weak_factory_;
83
84 DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloader);
85 };
86
87 } // namespace chromeos
88
89 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_WALLPAPER_DOWNLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/customization_document.cc ('k') | chrome/browser/chromeos/customization_wallpaper_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698