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

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

Issue 1403153004: Supervised user SafeSites: don't cache results for more than one hour (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 5 years, 2 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_async_url_checker.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_async_url_checker.h
diff --git a/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.h b/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.h
index bf8907cd50abed2589a69517933604f9616c5cac..ed7af25f95af677f24b62b360159530228f79ed4 100644
--- a/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.h
+++ b/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.h
@@ -5,12 +5,11 @@
#ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CHECKER_H_
#define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CHECKER_H_
-#include <string>
-
#include "base/callback_forward.h"
#include "base/containers/mru_cache.h"
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
+#include "base/time/time.h"
#include "chrome/browser/supervised_user/supervised_user_url_filter.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
@@ -20,16 +19,16 @@ class URLFetcher;
class URLRequestContextGetter;
}
-// This class checks against an online service (currently a Custom Search
-// Engine using SafeSearch) whether a given URL is safe to visit for a
-// supervised user, and returns the result asynchronously via a callback.
+// This class checks against an online service (the SafeSearch API) whether a
+// given URL is safe to visit for a supervised user, and returns the result
+// asynchronously via a callback.
class SupervisedUserAsyncURLChecker : net::URLFetcherDelegate {
public:
// Returns whether |url| should be blocked. Called from CheckURL.
- typedef base::Callback<void(const GURL&,
- SupervisedUserURLFilter::FilteringBehavior,
- bool /* uncertain */)>
- CheckCallback;
+ using CheckCallback =
+ base::Callback<void(const GURL&,
+ SupervisedUserURLFilter::FilteringBehavior,
+ bool /* uncertain */)>;
SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context);
SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context,
@@ -39,6 +38,10 @@ class SupervisedUserAsyncURLChecker : net::URLFetcherDelegate {
// Returns whether |callback| was run synchronously.
bool CheckURL(const GURL& url, const CheckCallback& callback);
+ void SetCacheTimeoutForTesting(const base::TimeDelta& timeout) {
+ cache_timeout_ = timeout;
+ }
+
private:
struct Check;
struct CheckResult {
@@ -46,6 +49,7 @@ class SupervisedUserAsyncURLChecker : net::URLFetcherDelegate {
bool uncertain);
SupervisedUserURLFilter::FilteringBehavior behavior;
bool uncertain;
+ base::TimeTicks timestamp;
};
// net::URLFetcherDelegate implementation.
@@ -56,6 +60,7 @@ class SupervisedUserAsyncURLChecker : net::URLFetcherDelegate {
ScopedVector<Check> checks_in_progress_;
base::MRUCache<GURL, CheckResult> cache_;
+ base::TimeDelta cache_timeout_;
DISALLOW_COPY_AND_ASSIGN(SupervisedUserAsyncURLChecker);
};
« no previous file with comments | « no previous file | chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698