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 COMPONENTS_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 5 #ifndef COMPONENTS_UPDATE_CLIENT_COMPONENT_UNPACKER_H_ |
6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 6 #define COMPONENTS_UPDATE_CLIENT_COMPONENT_UNPACKER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
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/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
19 | 19 |
20 namespace component_updater { | 20 namespace update_client { |
21 | 21 |
22 class ComponentInstaller; | 22 class ComponentInstaller; |
23 class ComponentPatcher; | 23 class ComponentPatcher; |
24 class OutOfProcessPatcher; | 24 class OutOfProcessPatcher; |
25 | 25 |
26 // Deserializes the CRX manifest. The top level must be a dictionary. | 26 // Deserializes the CRX manifest. The top level must be a dictionary. |
27 scoped_ptr<base::DictionaryValue> ReadManifest( | 27 scoped_ptr<base::DictionaryValue> ReadManifest( |
28 const base::FilePath& unpack_path); | 28 const base::FilePath& unpack_path); |
29 | 29 |
30 // In charge of unpacking the component CRX package and verifying that it is | 30 // In charge of unpacking the component CRX package and verifying that it is |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 typedef base::Callback<void(Error, int)> Callback; | 93 typedef base::Callback<void(Error, int)> Callback; |
94 | 94 |
95 // Constructs an unpacker for a specific component unpacking operation. | 95 // Constructs an unpacker for a specific component unpacking operation. |
96 // |pk_hash| is the expected/ public key SHA256 hash. |path| is the current | 96 // |pk_hash| is the expected/ public key SHA256 hash. |path| is the current |
97 // location of the CRX. | 97 // location of the CRX. |
98 ComponentUnpacker(const std::vector<uint8_t>& pk_hash, | 98 ComponentUnpacker(const std::vector<uint8_t>& pk_hash, |
99 const base::FilePath& path, | 99 const base::FilePath& path, |
100 const std::string& fingerprint, | 100 const std::string& fingerprint, |
101 ComponentInstaller* installer, | 101 ComponentInstaller* installer, |
102 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher, | 102 scoped_refptr<OutOfProcessPatcher> oop_patcher, |
103 scoped_refptr<base::SequencedTaskRunner> task_runner); | 103 scoped_refptr<base::SequencedTaskRunner> task_runner); |
104 | 104 |
105 // Begins the actual unpacking of the files. May invoke a patcher if the | 105 // Begins the actual unpacking of the files. May invoke a patcher if the |
106 // package is a differential update. Calls |callback| with the result. | 106 // package is a differential update. Calls |callback| with the result. |
107 void Unpack(const Callback& callback); | 107 void Unpack(const Callback& callback); |
108 | 108 |
109 private: | 109 private: |
110 friend class base::RefCountedThreadSafe<ComponentUnpacker>; | 110 friend class base::RefCountedThreadSafe<ComponentUnpacker>; |
111 | 111 |
112 virtual ~ComponentUnpacker(); | 112 virtual ~ComponentUnpacker(); |
(...skipping 29 matching lines...) Expand all Loading... |
142 | 142 |
143 std::vector<uint8_t> pk_hash_; | 143 std::vector<uint8_t> pk_hash_; |
144 base::FilePath path_; | 144 base::FilePath path_; |
145 base::FilePath unpack_path_; | 145 base::FilePath unpack_path_; |
146 base::FilePath unpack_diff_path_; | 146 base::FilePath unpack_diff_path_; |
147 bool is_delta_; | 147 bool is_delta_; |
148 std::string fingerprint_; | 148 std::string fingerprint_; |
149 scoped_refptr<ComponentPatcher> patcher_; | 149 scoped_refptr<ComponentPatcher> patcher_; |
150 ComponentInstaller* installer_; | 150 ComponentInstaller* installer_; |
151 Callback callback_; | 151 Callback callback_; |
152 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher_; | 152 scoped_refptr<OutOfProcessPatcher> oop_patcher_; |
153 Error error_; | 153 Error error_; |
154 int extended_error_; | 154 int extended_error_; |
155 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 155 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
156 | 156 |
157 DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker); | 157 DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker); |
158 }; | 158 }; |
159 | 159 |
160 } // namespace component_updater | 160 } // namespace update_client |
161 | 161 |
162 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 162 #endif // COMPONENTS_UPDATE_CLIENT_COMPONENT_UNPACKER_H_ |
OLD | NEW |