| 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_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
| 6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 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/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
| 18 | 19 |
| 19 namespace component_updater { | 20 namespace component_updater { |
| 20 | 21 |
| 21 class ComponentInstaller; | 22 class ComponentInstaller; |
| 22 class ComponentPatcher; | 23 class ComponentPatcher; |
| 23 class OutOfProcessPatcher; | 24 class OutOfProcessPatcher; |
| 24 | 25 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 kDeltaPatchProcessFailure, | 88 kDeltaPatchProcessFailure, |
| 88 kDeltaMissingExistingFile, | 89 kDeltaMissingExistingFile, |
| 89 kFingerprintWriteFailed, | 90 kFingerprintWriteFailed, |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 typedef base::Callback<void(Error, int)> Callback; | 93 typedef base::Callback<void(Error, int)> Callback; |
| 93 | 94 |
| 94 // Constructs an unpacker for a specific component unpacking operation. | 95 // Constructs an unpacker for a specific component unpacking operation. |
| 95 // |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 |
| 96 // location of the CRX. | 97 // location of the CRX. |
| 97 ComponentUnpacker(const std::vector<uint8>& pk_hash, | 98 ComponentUnpacker(const std::vector<uint8_t>& pk_hash, |
| 98 const base::FilePath& path, | 99 const base::FilePath& path, |
| 99 const std::string& fingerprint, | 100 const std::string& fingerprint, |
| 100 ComponentInstaller* installer, | 101 ComponentInstaller* installer, |
| 101 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher, | 102 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher, |
| 102 scoped_refptr<base::SequencedTaskRunner> task_runner); | 103 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 103 | 104 |
| 104 // 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 |
| 105 // package is a differential update. Calls |callback| with the result. | 106 // package is a differential update. Calls |callback| with the result. |
| 106 void Unpack(const Callback& callback); | 107 void Unpack(const Callback& callback); |
| 107 | 108 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 132 | 133 |
| 133 // The fourth step is to install the unpacked component. | 134 // The fourth step is to install the unpacked component. |
| 134 void Install(); | 135 void Install(); |
| 135 | 136 |
| 136 // The final step is to do clean-up for things that can't be tidied as we go. | 137 // The final step is to do clean-up for things that can't be tidied as we go. |
| 137 // If there is an error at any step, the remaining steps are skipped and | 138 // If there is an error at any step, the remaining steps are skipped and |
| 138 // and Finish is called. | 139 // and Finish is called. |
| 139 // Finish is responsible for calling the callback provided in Start(). | 140 // Finish is responsible for calling the callback provided in Start(). |
| 140 void Finish(); | 141 void Finish(); |
| 141 | 142 |
| 142 std::vector<uint8> pk_hash_; | 143 std::vector<uint8_t> pk_hash_; |
| 143 base::FilePath path_; | 144 base::FilePath path_; |
| 144 base::FilePath unpack_path_; | 145 base::FilePath unpack_path_; |
| 145 base::FilePath unpack_diff_path_; | 146 base::FilePath unpack_diff_path_; |
| 146 bool is_delta_; | 147 bool is_delta_; |
| 147 std::string fingerprint_; | 148 std::string fingerprint_; |
| 148 scoped_refptr<ComponentPatcher> patcher_; | 149 scoped_refptr<ComponentPatcher> patcher_; |
| 149 ComponentInstaller* installer_; | 150 ComponentInstaller* installer_; |
| 150 Callback callback_; | 151 Callback callback_; |
| 151 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher_; | 152 scoped_refptr<OutOfProcessPatcher> out_of_process_patcher_; |
| 152 Error error_; | 153 Error error_; |
| 153 int extended_error_; | 154 int extended_error_; |
| 154 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 155 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 155 | 156 |
| 156 DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker); | 157 DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker); |
| 157 }; | 158 }; |
| 158 | 159 |
| 159 } // namespace component_updater | 160 } // namespace component_updater |
| 160 | 161 |
| 161 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 162 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
| OLD | NEW |