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

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

Issue 337025: Design changes in browser/privacy_blacklist needed to integrate (Closed)
Patch Set: fixes Created 11 years, 1 month 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 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_PRIVACY_BLACKLIST_BLACKLIST_IO_H_ 5 #ifndef CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_IO_H_
6 #define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_IO_H_ 6 #define CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_IO_H_
7 7
8 #include <list> 8 #include <string>
9 9
10 #include "base/string16.h" 10 class Blacklist;
11 #include "chrome/browser/privacy_blacklist/blacklist.h"
12
13 class FilePath; 11 class FilePath;
14 12
15 // Helper class to keep state while reading multiple text blacklists to 13 // Set of routines to read and write blacklists.
16 // produce a single binary blacklist used by the Blacklist constructor.
17 class BlacklistIO { 14 class BlacklistIO {
18 public: 15 public:
19 BlacklistIO(); 16 // Reads a blacklist stored on disk in a text format.
20 ~BlacklistIO(); 17 // On error returns false and fills |error_string|.
21 18 static bool ReadText(Blacklist* blacklist, const FilePath& path,
22 // Reads a text blacklist, as downloaded from the blacklist provider. 19 std::string* error_string);
23 bool Read(const FilePath& path); 20
24 21 // Reads a blacklist stored on disk in a binary format.
25 // Writes a binary blacklist with aggregated entries for all read blacklists. 22 // Returns true on success.
26 bool Write(const FilePath& path); 23 static bool ReadBinary(Blacklist* blacklist, const FilePath& path);
27 24
28 // Returns the text of the last occuring error. An empty string is returned 25 // Writes |blacklist| to |path| in a binary format. Returns true on success.
29 // if no such error happened. 26 static bool WriteBinary(const Blacklist* blacklist, const FilePath& path);
30 const string16& last_error() const {
31 return last_error_;
32 }
33
34 private:
35 // Introspection functions, for testing purposes.
36 const std::list<Blacklist::Entry*>& blacklist() const {
37 return blacklist_;
38 }
39 const std::list<Blacklist::Provider*>& providers() const {
40 return providers_;
41 }
42
43 std::list<Blacklist::Entry*> blacklist_;
44 std::list<Blacklist::Provider*> providers_;
45 string16 last_error_; // Stores text of last error, empty if N/A.
46
47 FRIEND_TEST(BlacklistIOTest, Generic);
48 FRIEND_TEST(BlacklistIOTest, Combine);
49 DISALLOW_COPY_AND_ASSIGN(BlacklistIO);
50 }; 27 };
51 28
52 #endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_IO_H_ 29 #endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_IO_H_
OLDNEW
« no previous file with comments | « chrome/browser/privacy_blacklist/blacklist.cc ('k') | chrome/browser/privacy_blacklist/blacklist_io.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698