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

Side by Side Diff: chrome/browser/supervised_user/experimental/supervised_user_blacklist.h

Issue 537993002: Supervised users: Prototype of static client-side host blacklist. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: experimental 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/supervised_user/experimental/supervised_user_blacklist.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback_forward.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/sha1.h"
16
17 namespace base {
18 class FilePath;
19 }
20
21 class GURL;
22
23 // Compact list of (SHA1 hashes of) blocked hosts.
24 // Checking for URLs is thread-safe, loading is not.
25 class SupervisedUserBlacklist {
26 public:
27 struct Hash {
28 Hash() {}
29 explicit Hash(const std::string& host);
30 bool operator<(const Hash& rhs) const;
31
32 unsigned char data[base::kSHA1Length];
33 };
34
35 SupervisedUserBlacklist();
36 ~SupervisedUserBlacklist();
37
38 // Asynchronously read a blacklist from the given file, replacing any previous
39 // entries. |done_callback| will be run after reading finishes (successfully
40 // or not), but not if the SupervisedUserBlacklist is destroyed before that.
41 void ReadFromFile(const base::FilePath& path,
42 const base::Closure& done_callback);
43
44 bool HasURL(const GURL& url) const;
45
46 size_t GetEntryCount() const;
47
48 private:
49 void OnReadFromFileCompleted(const base::Closure& done_callback,
50 scoped_ptr<std::vector<Hash> > host_hashes);
51
52 std::vector<Hash> host_hashes_;
53
54 base::WeakPtrFactory<SupervisedUserBlacklist> weak_ptr_factory_;
55
56 DISALLOW_COPY_AND_ASSIGN(SupervisedUserBlacklist);
57 };
58
59 #endif // CHROME_BROWSER_SUPERVISED_USER_EXPERIMENTAL_SUPERVISED_USER_BLACKLIST _H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/supervised_user/experimental/supervised_user_blacklist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698