OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_EXTENSIONS_ACTIVITY_LOG_HASHED_AD_NETWORK_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_HASHED_AD_NETWORK_DATABASE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_HASHED_AD_NETWORK_DATABASE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_HASHED_AD_NETWORK_DATABASE_H_ |
7 | 7 |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "chrome/browser/extensions/activity_log/ad_network_database.h" | 10 #include "chrome/browser/extensions/activity_log/ad_network_database.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class RefCountedStaticMemory; | 13 class RefCountedStaticMemory; |
14 } | 14 } |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 // The standard ("real") implementation of the AdNetworkDatabase, which stores | 18 // The standard ("real") implementation of the AdNetworkDatabase, which stores |
19 // a list of hashes of ad networks. | 19 // a list of hashes of ad networks. |
20 class HashedAdNetworkDatabase : public AdNetworkDatabase { | 20 class HashedAdNetworkDatabase : public AdNetworkDatabase { |
21 public: | 21 public: |
22 explicit HashedAdNetworkDatabase( | 22 explicit HashedAdNetworkDatabase( |
23 scoped_refptr<base::RefCountedStaticMemory> memory); | 23 scoped_refptr<base::RefCountedStaticMemory> memory); |
24 virtual ~HashedAdNetworkDatabase(); | 24 virtual ~HashedAdNetworkDatabase(); |
25 | 25 |
26 bool is_valid() const { return is_valid_; } | |
27 | |
28 private: | 26 private: |
29 // AdNetworkDatabase implementation. | 27 // AdNetworkDatabase implementation. |
30 virtual bool IsAdNetwork(const GURL& url) const OVERRIDE; | 28 virtual bool IsAdNetwork(const GURL& url) const OVERRIDE; |
31 | 29 |
32 // Whether or not the database is valid, i.e., has correctly parsed the hash | |
33 // file. If it is not, it will always return false for IsAdNetwork(), since | |
34 // it cannot match against known hashes. | |
35 bool is_valid_; | |
36 | |
37 // The set of partial hashes for known ad networks. | 30 // The set of partial hashes for known ad networks. |
38 base::hash_set<int64> entries_; | 31 base::hash_set<int64> entries_; |
39 }; | 32 }; |
40 | 33 |
41 } // namespace extensions | 34 } // namespace extensions |
42 | 35 |
43 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_HASHED_AD_NETWORK_DATABASE_H_ | 36 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_HASHED_AD_NETWORK_DATABASE_H_ |
OLD | NEW |