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

Side by Side Diff: chrome/browser/net/file_downloader.h

Issue 1265983007: Popular sites on the NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 4 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
« no previous file with comments | « chrome/browser/android/popular_sites.cc ('k') | chrome/browser/net/file_downloader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_DO WNLOADER_H_ 5 #ifndef CHROME_BROWSER_NET_FILE_DOWNLOADER_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_DO WNLOADER_H_ 6 #define CHROME_BROWSER_NET_FILE_DOWNLOADER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "net/url_request/url_fetcher_delegate.h" 11 #include "net/url_request/url_fetcher_delegate.h"
12 12
13 namespace base { 13 namespace base {
14 class FilePath; 14 class FilePath;
15 } // namespace base 15 } // namespace base
16 16
17 namespace net { 17 namespace net {
18 class URLFetcher; 18 class URLFetcher;
19 class URLRequestContextGetter; 19 class URLRequestContextGetter;
20 } // namespace net 20 } // namespace net
21 21
22 class GURL; 22 class GURL;
23 23
24 // Helper class to download a blacklist file from a given URL and store it in a 24 // Helper class to download a file from a given URL and store it in a local
25 // local file. If the local file already exists, reports success without 25 // file. If the local file already exists, reports success without downloading
26 // downloading anything. 26 // anything.
27 class SupervisedUserBlacklistDownloader : public net::URLFetcherDelegate { 27 // TODO(treib): Add a "bool overwrite" param?
28 class FileDownloader : public net::URLFetcherDelegate {
28 public: 29 public:
29 typedef base::Callback<void(bool /* success */)> DownloadFinishedCallback; 30 typedef base::Callback<void(bool /* success */)> DownloadFinishedCallback;
30 31
31 // Directly starts the download (if necessary) and runs |callback| when done. 32 // Directly starts the download (if necessary) and runs |callback| when done.
32 // If the instance is destroyed before it is finished, |callback| is not run. 33 // If the instance is destroyed before it is finished, |callback| is not run.
33 SupervisedUserBlacklistDownloader( 34 FileDownloader(const GURL& url,
34 const GURL& url, 35 const base::FilePath& path,
35 const base::FilePath& path, 36 net::URLRequestContextGetter* request_context,
36 net::URLRequestContextGetter* request_context, 37 const DownloadFinishedCallback& callback);
37 const DownloadFinishedCallback& callback); 38 ~FileDownloader() override;
38 ~SupervisedUserBlacklistDownloader() override;
39 39
40 private: 40 private:
41 // net::URLFetcherDelegate implementation. 41 // net::URLFetcherDelegate implementation.
42 void OnURLFetchComplete(const net::URLFetcher* source) override; 42 void OnURLFetchComplete(const net::URLFetcher* source) override;
43 43
44 void OnFileExistsCheckDone(bool exists); 44 void OnFileExistsCheckDone(bool exists);
45 45
46 DownloadFinishedCallback callback_; 46 DownloadFinishedCallback callback_;
47 47
48 scoped_ptr<net::URLFetcher> fetcher_; 48 scoped_ptr<net::URLFetcher> fetcher_;
49 49
50 base::WeakPtrFactory<SupervisedUserBlacklistDownloader> weak_ptr_factory_; 50 base::WeakPtrFactory<FileDownloader> weak_ptr_factory_;
51 51
52 DISALLOW_COPY_AND_ASSIGN(SupervisedUserBlacklistDownloader); 52 DISALLOW_COPY_AND_ASSIGN(FileDownloader);
53 }; 53 };
54 54
55 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST _DOWNLOADER_H_ 55 #endif // CHROME_BROWSER_NET_FILE_DOWNLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/popular_sites.cc ('k') | chrome/browser/net/file_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698