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

Unified Diff: chrome/browser/supervised_user/prototype/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: is_sorted is Cpp11 (yay...) 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
Index: chrome/browser/supervised_user/prototype/supervised_user_blacklist.h
diff --git a/chrome/browser/supervised_user/prototype/supervised_user_blacklist.h b/chrome/browser/supervised_user/prototype/supervised_user_blacklist.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab24e4e093187def29fa6ef51176033e429d6b2f
--- /dev/null
+++ b/chrome/browser/supervised_user/prototype/supervised_user_blacklist.h
@@ -0,0 +1,59 @@
+// 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_PROTOTYPE_SUPERVISED_USER_BLACKLIST_H_
+#define CHROME_BROWSER_SUPERVISED_USER_PROTOTYPE_SUPERVISED_USER_BLACKLIST_H_
+
+#include <string>
+#include <vector>
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/sha1.h"
+
+namespace base {
+class FilePath;
+}
+
+class GURL;
+
+// Compact list of (SHA1 hashes of) blocked hosts.
+// Checking for URLs is thread-safe, loading is not.
+class SupervisedUserBlacklist {
+ public:
+ struct Hash {
+ Hash() {}
+ explicit Hash(const std::string& host);
+ bool operator<(const Hash& rhs) const;
+
+ unsigned char data[base::kSHA1Length];
+ };
+
+ SupervisedUserBlacklist();
+ ~SupervisedUserBlacklist();
+
+ // Asynchronously read a blacklist from the given file, replacing any previous
+ // entries. |done_callback| will be run after reading finishes (successfully
+ // or not), but not if the SupervisedUserBlacklist is destroyed before that.
+ void ReadFromFile(const base::FilePath& path,
+ const base::Closure& done_callback);
+
+ bool HasURL(const GURL& url) const;
+
+ size_t GetEntryCount() const;
+
+ private:
+ void OnReadFromFileCompleted(const base::Closure& done_callback,
+ scoped_ptr<std::vector<Hash> > host_hashes);
+
+ std::vector<Hash> host_hashes_;
+
+ base::WeakPtrFactory<SupervisedUserBlacklist> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(SupervisedUserBlacklist);
+};
+
+#endif // CHROME_BROWSER_SUPERVISED_USER_PROTOTYPE_SUPERVISED_USER_BLACKLIST_H_
« no previous file with comments | « no previous file | chrome/browser/supervised_user/prototype/supervised_user_blacklist.cc » ('j') | chrome/chrome_browser.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698