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

Side by Side Diff: chrome/browser/privacy_blacklist/blacklist_manager.h

Issue 164535: Create BlacklistManager, which will aggregate individual blacklists into one compiled one (Closed)
Patch Set: sync with trunk, fix little things Created 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/privacy_blacklist/blacklist_manager.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 (c) 2009 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_PRIVACY_BLACKLIST_BLACKLIST_MANAGER_H_
6 #define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_MANAGER_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/file_path.h"
13 #include "base/non_thread_safe.h"
14 #include "base/ref_counted.h"
15 #include "base/scoped_ptr.h"
16 #include "chrome/common/notification_registrar.h"
17
18 class Blacklist;
19 class MessageLoop;
20 class Profile;
21 class Task;
22
23 namespace base {
24 class Thread;
25 }
26
27 class BlacklistPathProvider {
28 public:
29 virtual ~BlacklistPathProvider();
30
31 virtual std::vector<FilePath> GetBlacklistPaths() = 0;
32 };
33
34 // Updates one compiled binary blacklist based on a list of plaintext
35 // blacklists.
36 class BlacklistManager : public base::RefCountedThreadSafe<BlacklistManager>,
37 public NotificationObserver,
38 public NonThreadSafe {
39 public:
40 // You must create and destroy BlacklistManager on the same thread.
41 BlacklistManager(Profile* profile, base::Thread* backend_thread);
42
43 void RegisterBlacklistPathProvider(BlacklistPathProvider* provider);
44 void UnregisterBlacklistPathProvider(BlacklistPathProvider* provider);
45
46 const Blacklist* GetCompiledBlacklist() const {
47 return compiled_blacklist_.get();
48 }
49
50 // NotificationObserver
51 virtual void Observe(NotificationType type,
stoyan 2009/10/15 16:22:41 move this method to private:?
52 const NotificationSource& source,
53 const NotificationDetails& details);
54
55 #ifdef UNIT_TEST
56 const FilePath& compiled_blacklist_path() { return compiled_blacklist_path_; }
57 #endif // UNIT_TEST
58
59 private:
60 class CompileBlacklistTask;
61 class ReadBlacklistTask;
62
63 typedef std::set<BlacklistPathProvider*> ProvidersSet;
64
65 void CompileBlacklist();
66 void ReadBlacklist();
67
68 void OnBlacklistCompilationFinished(bool success);
69 void OnBlacklistReadFinished(Blacklist* blacklist);
70
71 void RunTaskOnBackendThread(Task* task);
72
73 // Path where we store the compiled blacklist.
74 FilePath compiled_blacklist_path_;
75
76 // Keep the compiled blacklist object in memory.
77 scoped_ptr<Blacklist> compiled_blacklist_;
78
79 // If true, then we started compiling a blacklist and haven't yet finished
80 // successfully. This helps prevent an infinite loop in case of multiple
81 // I/O errors.
82 bool compiling_blacklist_;
83
84 // Registered blacklist paths providers.
85 ProvidersSet providers_;
86
87 // Backend thread we will execute I/O operations on (NULL means no separate
88 // thread).
89 base::Thread* backend_thread_;
90
91 NotificationRegistrar registrar_;
92
93 DISALLOW_COPY_AND_ASSIGN(BlacklistManager);
94 };
95
96 #endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/privacy_blacklist/blacklist_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698