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

Unified Diff: chrome/browser/supervised_user/experimental/supervised_user_blacklist_downloader.h

Issue 592423005: Supervised user blacklist: Add downloader class to download a blacklist if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comment Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/supervised_user/experimental/supervised_user_blacklist_downloader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/supervised_user/experimental/supervised_user_blacklist_downloader.h
diff --git a/chrome/browser/supervised_user/experimental/supervised_user_blacklist_downloader.h b/chrome/browser/supervised_user/experimental/supervised_user_blacklist_downloader.h
new file mode 100644
index 0000000000000000000000000000000000000000..b223b58e68af35e9ab1682f2dd6228e298b7062f
--- /dev/null
+++ b/chrome/browser/supervised_user/experimental/supervised_user_blacklist_downloader.h
@@ -0,0 +1,55 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_DOWNLOADER_H_
+#define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_DOWNLOADER_H_
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "net/url_request/url_fetcher_delegate.h"
+
+namespace base {
+class FilePath;
+} // namespace base
+
+namespace net {
+class URLFetcher;
+class URLRequestContextGetter;
+} // namespace net
+
+class GURL;
+
+// Helper class to download a blacklist file from a given URL and store it in a
+// local file. If the local file already exists, reports success without
+// downloading anything.
+class SupervisedUserBlacklistDownloader : public net::URLFetcherDelegate {
+ public:
+ typedef base::Callback<void(bool /* success */)> DownloadFinishedCallback;
+
+ // Directly starts the download (if necessary) and runs |callback| when done.
+ // If the instance is destroyed before it is finished, |callback| is not run.
+ SupervisedUserBlacklistDownloader(
+ const GURL& url,
+ const base::FilePath& path,
+ net::URLRequestContextGetter* request_context,
+ const DownloadFinishedCallback& callback);
+ virtual ~SupervisedUserBlacklistDownloader();
+
+ private:
+ // net::URLFetcherDelegate implementation.
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+
+ void OnFileExistsCheckDone(bool exists);
+
+ DownloadFinishedCallback callback_;
+
+ scoped_ptr<net::URLFetcher> fetcher_;
+
+ base::WeakPtrFactory<SupervisedUserBlacklistDownloader> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserBlacklistDownloader);
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_DOWNLOADER_H_
« no previous file with comments | « no previous file | chrome/browser/supervised_user/experimental/supervised_user_blacklist_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698