OLD | NEW |
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 <list> |
9 | 9 |
| 10 #include "base/string16.h" |
10 #include "chrome/browser/privacy_blacklist/blacklist.h" | 11 #include "chrome/browser/privacy_blacklist/blacklist.h" |
11 | 12 |
12 class FilePath; | 13 class FilePath; |
13 | 14 |
14 // Helper class to keep state while reading multiple text blacklists to | 15 // Helper class to keep state while reading multiple text blacklists to |
15 // produce a single binary blacklist used by the Blacklist constructor. | 16 // produce a single binary blacklist used by the Blacklist constructor. |
16 class BlacklistIO { | 17 class BlacklistIO { |
17 public: | 18 public: |
18 BlacklistIO(); | 19 BlacklistIO(); |
19 ~BlacklistIO(); | 20 ~BlacklistIO(); |
20 | 21 |
21 // Reads a text blacklist, as downloaded from the blacklist provider. | 22 // Reads a text blacklist, as downloaded from the blacklist provider. |
22 bool Read(const FilePath& path); | 23 bool Read(const FilePath& path); |
23 | 24 |
24 // Writes a binary blacklist with aggregated entries for all read blacklists. | 25 // Writes a binary blacklist with aggregated entries for all read blacklists. |
25 bool Write(const FilePath& path); | 26 bool Write(const FilePath& path); |
26 | 27 |
| 28 // Returns the text of the last occuring error. An empty string is returned |
| 29 // if no such error happened. |
| 30 const string16& last_error() const { |
| 31 return last_error_; |
| 32 } |
| 33 |
27 private: | 34 private: |
28 // Introspection functions, for testing purposes. | 35 // Introspection functions, for testing purposes. |
29 const std::list<Blacklist::Entry*>& blacklist() const { | 36 const std::list<Blacklist::Entry*>& blacklist() const { |
30 return blacklist_; | 37 return blacklist_; |
31 } | 38 } |
32 const std::list<Blacklist::Provider*>& providers() const { | 39 const std::list<Blacklist::Provider*>& providers() const { |
33 return providers_; | 40 return providers_; |
34 } | 41 } |
35 | 42 |
36 std::list<Blacklist::Entry*> blacklist_; | 43 std::list<Blacklist::Entry*> blacklist_; |
37 std::list<Blacklist::Provider*> providers_; | 44 std::list<Blacklist::Provider*> providers_; |
| 45 string16 last_error_; // Stores text of last error, empty if N/A. |
38 | 46 |
39 FRIEND_TEST(BlacklistIOTest, Generic); | 47 FRIEND_TEST(BlacklistIOTest, Generic); |
40 FRIEND_TEST(BlacklistIOTest, Combine); | 48 FRIEND_TEST(BlacklistIOTest, Combine); |
41 DISALLOW_COPY_AND_ASSIGN(BlacklistIO); | 49 DISALLOW_COPY_AND_ASSIGN(BlacklistIO); |
42 }; | 50 }; |
43 | 51 |
44 #endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_IO_H_ | 52 #endif // CHROME_BROWSER_PRIVACY_BLACKLIST_BLACKLIST_IO_H_ |
OLD | NEW |