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 EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ | 5 #ifndef EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ |
6 #define EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ | 6 #define EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/version.h" | 16 #include "base/version.h" |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 // A helper class for keeping track of data for the ContentVerifier that should | 20 // A helper class for keeping track of data for the ContentVerifier that should |
21 // only be accessed on the IO thread. | 21 // only be accessed on the IO thread. |
22 class ContentVerifierIOData | 22 class ContentVerifierIOData |
23 : public base::RefCountedThreadSafe<ContentVerifierIOData> { | 23 : public base::RefCountedThreadSafe<ContentVerifierIOData> { |
24 public: | 24 public: |
25 struct ExtensionData { | 25 struct ExtensionData { |
26 std::set<base::FilePath> browser_image_paths; | 26 scoped_ptr<std::set<base::FilePath>> browser_image_paths; |
27 base::Version version; | 27 base::Version version; |
28 | 28 |
29 ExtensionData(const std::set<base::FilePath>& browser_image_paths, | 29 ExtensionData(scoped_ptr<std::set<base::FilePath>> browser_image_paths, |
30 const base::Version& version); | 30 const base::Version& version); |
31 ~ExtensionData(); | 31 ~ExtensionData(); |
32 }; | 32 }; |
33 | 33 |
34 ContentVerifierIOData(); | 34 ContentVerifierIOData(); |
35 | 35 |
36 void AddData(const std::string& extension_id, scoped_ptr<ExtensionData> data); | 36 void AddData(const std::string& extension_id, scoped_ptr<ExtensionData> data); |
37 void RemoveData(const std::string& extension_id); | 37 void RemoveData(const std::string& extension_id); |
38 void Clear(); | 38 void Clear(); |
39 | 39 |
40 // This should be called on the IO thread, and the return value should not | 40 // This should be called on the IO thread, and the return value should not |
41 // be retained or used on other threads. | 41 // be retained or used on other threads. |
42 const ExtensionData* GetData(const std::string& extension_id); | 42 const ExtensionData* GetData(const std::string& extension_id); |
43 | 43 |
44 protected: | 44 protected: |
45 friend class base::RefCountedThreadSafe<ContentVerifierIOData>; | 45 friend class base::RefCountedThreadSafe<ContentVerifierIOData>; |
46 virtual ~ContentVerifierIOData(); | 46 virtual ~ContentVerifierIOData(); |
47 | 47 |
48 std::map<std::string, linked_ptr<ExtensionData> > data_map_; | 48 std::map<std::string, linked_ptr<ExtensionData> > data_map_; |
49 }; | 49 }; |
50 | 50 |
51 } // namespace extensions | 51 } // namespace extensions |
52 | 52 |
53 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ | 53 #endif // EXTENSIONS_BROWSER_CONTENT_VERIFIER_IO_DATA_H_ |
OLD | NEW |