OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_ASYNC_URL_CH
ECKER_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CH
ECKER_H_ |
6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CH
ECKER_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL_CH
ECKER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 14 matching lines...) Loading... |
25 // supervised user, and returns the result asynchronously via a callback. | 25 // supervised user, and returns the result asynchronously via a callback. |
26 class SupervisedUserAsyncURLChecker : net::URLFetcherDelegate { | 26 class SupervisedUserAsyncURLChecker : net::URLFetcherDelegate { |
27 public: | 27 public: |
28 // Returns whether |url| should be blocked. Called from CheckURL. | 28 // Returns whether |url| should be blocked. Called from CheckURL. |
29 typedef base::Callback<void(const GURL&, | 29 typedef base::Callback<void(const GURL&, |
30 SupervisedUserURLFilter::FilteringBehavior, | 30 SupervisedUserURLFilter::FilteringBehavior, |
31 bool /* uncertain */)> | 31 bool /* uncertain */)> |
32 CheckCallback; | 32 CheckCallback; |
33 | 33 |
34 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context, | 34 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context, |
35 const std::string& cx); | 35 const std::string& cx, |
| 36 const std::string& api_key); |
36 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context, | 37 SupervisedUserAsyncURLChecker(net::URLRequestContextGetter* context, |
37 const std::string& cx, | 38 const std::string& cx, |
| 39 const std::string& api_key, |
38 size_t cache_size); | 40 size_t cache_size); |
39 virtual ~SupervisedUserAsyncURLChecker(); | 41 virtual ~SupervisedUserAsyncURLChecker(); |
40 | 42 |
41 // Returns whether |callback| was run synchronously. | 43 // Returns whether |callback| was run synchronously. |
42 bool CheckURL(const GURL& url, const CheckCallback& callback); | 44 bool CheckURL(const GURL& url, const CheckCallback& callback); |
43 | 45 |
44 private: | 46 private: |
45 struct Check; | 47 struct Check; |
46 struct CheckResult { | 48 struct CheckResult { |
47 CheckResult(SupervisedUserURLFilter::FilteringBehavior behavior, | 49 CheckResult(SupervisedUserURLFilter::FilteringBehavior behavior, |
48 bool uncertain); | 50 bool uncertain); |
49 SupervisedUserURLFilter::FilteringBehavior behavior; | 51 SupervisedUserURLFilter::FilteringBehavior behavior; |
50 bool uncertain; | 52 bool uncertain; |
51 }; | 53 }; |
52 | 54 |
| 55 void SetApiKey(const std::string& api_key); |
| 56 |
53 // net::URLFetcherDelegate implementation. | 57 // net::URLFetcherDelegate implementation. |
54 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 58 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; |
55 | 59 |
56 net::URLRequestContextGetter* context_; | 60 net::URLRequestContextGetter* context_; |
57 std::string cx_; | 61 std::string cx_; |
| 62 std::string api_key_; |
58 | 63 |
59 ScopedVector<Check> checks_in_progress_; | 64 ScopedVector<Check> checks_in_progress_; |
60 | 65 |
61 base::MRUCache<GURL, CheckResult> cache_; | 66 base::MRUCache<GURL, CheckResult> cache_; |
62 | 67 |
63 DISALLOW_COPY_AND_ASSIGN(SupervisedUserAsyncURLChecker); | 68 DISALLOW_COPY_AND_ASSIGN(SupervisedUserAsyncURLChecker); |
64 }; | 69 }; |
65 | 70 |
66 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL
_CHECKER_H_ | 71 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_ASYNC_URL
_CHECKER_H_ |
OLD | NEW |