OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/json/json_file_value_serializer.h" | 14 #include "base/json/json_file_value_serializer.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
18 | 18 |
19 namespace component_updater { | 19 namespace component_updater { |
20 | 20 |
21 class ComponentInstaller; | 21 class ComponentInstaller; |
22 class ComponentPatcher; | 22 class ComponentPatcher; |
| 23 class OutOfProcessPatcher; |
23 | 24 |
24 // Deserializes the CRX manifest. The top level must be a dictionary. | 25 // Deserializes the CRX manifest. The top level must be a dictionary. |
25 scoped_ptr<base::DictionaryValue> ReadManifest( | 26 scoped_ptr<base::DictionaryValue> ReadManifest( |
26 const base::FilePath& unpack_path); | 27 const base::FilePath& unpack_path); |
27 | 28 |
28 // In charge of unpacking the component CRX package and verifying that it is | 29 // In charge of unpacking the component CRX package and verifying that it is |
29 // well formed and the cryptographic signature is correct. If there is no | 30 // well formed and the cryptographic signature is correct. If there is no |
30 // error the component specific installer will be invoked to proceed with | 31 // error the component specific installer will be invoked to proceed with |
31 // the component installation or update. | 32 // the component installation or update. |
32 // | 33 // |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 91 |
91 typedef base::Callback<void(Error, int)> Callback; | 92 typedef base::Callback<void(Error, int)> Callback; |
92 | 93 |
93 // Constructs an unpacker for a specific component unpacking operation. | 94 // Constructs an unpacker for a specific component unpacking operation. |
94 // |pk_hash| is the expected/ public key SHA256 hash. |path| is the current | 95 // |pk_hash| is the expected/ public key SHA256 hash. |path| is the current |
95 // location of the CRX. | 96 // location of the CRX. |
96 ComponentUnpacker(const std::vector<uint8>& pk_hash, | 97 ComponentUnpacker(const std::vector<uint8>& pk_hash, |
97 const base::FilePath& path, | 98 const base::FilePath& path, |
98 const std::string& fingerprint, | 99 const std::string& fingerprint, |
99 ComponentInstaller* installer, | 100 ComponentInstaller* installer, |
100 bool in_process, | 101 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher, |
101 scoped_refptr<base::SequencedTaskRunner> task_runner); | 102 scoped_refptr<base::SequencedTaskRunner> task_runner); |
102 | 103 |
103 // Begins the actual unpacking of the files. May invoke a patcher if the | 104 // Begins the actual unpacking of the files. May invoke a patcher if the |
104 // package is a differential update. Calls |callback| with the result. | 105 // package is a differential update. Calls |callback| with the result. |
105 void Unpack(const Callback& callback); | 106 void Unpack(const Callback& callback); |
106 | 107 |
107 private: | 108 private: |
108 friend class base::RefCountedThreadSafe<ComponentUnpacker>; | 109 friend class base::RefCountedThreadSafe<ComponentUnpacker>; |
109 | 110 |
110 virtual ~ComponentUnpacker(); | 111 virtual ~ComponentUnpacker(); |
(...skipping 29 matching lines...) Expand all Loading... |
140 | 141 |
141 std::vector<uint8> pk_hash_; | 142 std::vector<uint8> pk_hash_; |
142 base::FilePath path_; | 143 base::FilePath path_; |
143 base::FilePath unpack_path_; | 144 base::FilePath unpack_path_; |
144 base::FilePath unpack_diff_path_; | 145 base::FilePath unpack_diff_path_; |
145 bool is_delta_; | 146 bool is_delta_; |
146 std::string fingerprint_; | 147 std::string fingerprint_; |
147 scoped_refptr<ComponentPatcher> patcher_; | 148 scoped_refptr<ComponentPatcher> patcher_; |
148 ComponentInstaller* installer_; | 149 ComponentInstaller* installer_; |
149 Callback callback_; | 150 Callback callback_; |
150 const bool in_process_; | 151 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher_; |
151 Error error_; | 152 Error error_; |
152 int extended_error_; | 153 int extended_error_; |
153 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 154 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
154 | 155 |
155 DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker); | 156 DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker); |
156 }; | 157 }; |
157 | 158 |
158 } // namespace component_updater | 159 } // namespace component_updater |
159 | 160 |
160 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 161 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
OLD | NEW |