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 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 const base::FilePath& path, | 97 const base::FilePath& path, |
98 const std::string& fingerprint, | 98 const std::string& fingerprint, |
99 ComponentInstaller* installer, | 99 ComponentInstaller* installer, |
100 bool in_process, | 100 bool in_process, |
101 scoped_refptr<base::SequencedTaskRunner> task_runner); | 101 scoped_refptr<base::SequencedTaskRunner> task_runner); |
102 | 102 |
103 // Begins the actual unpacking of the files. May invoke a patcher if the | 103 // Begins the actual unpacking of the files. May invoke a patcher if the |
104 // package is a differential update. Calls |callback| with the result. | 104 // package is a differential update. Calls |callback| with the result. |
105 void Unpack(const Callback& callback); | 105 void Unpack(const Callback& callback); |
106 | 106 |
| 107 // Creates a ComponentUnpacker by loading CRX and related information from |
| 108 // |backup_path| that was previously saved by SaveInstallSource(). |
| 109 static scoped_refptr<ComponentUnpacker> CreateFromBackup( |
| 110 const base::FilePath& backup_path, |
| 111 ComponentInstaller* installer, |
| 112 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 113 |
| 114 |
107 private: | 115 private: |
108 friend class base::RefCountedThreadSafe<ComponentUnpacker>; | 116 friend class base::RefCountedThreadSafe<ComponentUnpacker>; |
| 117 friend class ComponentUnpackerTest; |
109 | 118 |
110 virtual ~ComponentUnpacker(); | 119 virtual ~ComponentUnpacker(); |
111 | 120 |
112 bool UnpackInternal(); | 121 bool UnpackInternal(); |
113 | 122 |
114 // The first step of unpacking is to verify the file. Returns false if an | 123 // The first step of unpacking is to verify the file. Returns false if an |
115 // error is encountered, the file is malformed, or the file is incorrectly | 124 // error is encountered, the file is malformed, or the file is incorrectly |
116 // signed. | 125 // signed. |
117 bool Verify(); | 126 bool Verify(); |
118 | 127 |
(...skipping 12 matching lines...) Expand all Loading... |
131 | 140 |
132 // The fourth step is to install the unpacked component. | 141 // The fourth step is to install the unpacked component. |
133 void Install(); | 142 void Install(); |
134 | 143 |
135 // The final step is to do clean-up for things that can't be tidied as we go. | 144 // The final step is to do clean-up for things that can't be tidied as we go. |
136 // If there is an error at any step, the remaining steps are skipped and | 145 // If there is an error at any step, the remaining steps are skipped and |
137 // and Finish is called. | 146 // and Finish is called. |
138 // Finish is responsible for calling the callback provided in Start(). | 147 // Finish is responsible for calling the callback provided in Start(). |
139 void Finish(); | 148 void Finish(); |
140 | 149 |
| 150 // Saves the original CRX file, along with fingerprint and other related |
| 151 // infromation, to |backup_path|. This is for retry patching later when it |
| 152 // fails. |
| 153 bool SaveInstallSource(const base::FilePath& backup_path) const; |
| 154 |
141 std::vector<uint8> pk_hash_; | 155 std::vector<uint8> pk_hash_; |
142 base::FilePath path_; | 156 base::FilePath path_; |
143 base::FilePath unpack_path_; | 157 base::FilePath unpack_path_; |
144 base::FilePath unpack_diff_path_; | 158 base::FilePath unpack_diff_path_; |
145 bool is_delta_; | 159 bool is_delta_; |
146 std::string fingerprint_; | 160 std::string fingerprint_; |
147 scoped_refptr<ComponentPatcher> patcher_; | 161 scoped_refptr<ComponentPatcher> patcher_; |
148 ComponentInstaller* installer_; | 162 ComponentInstaller* installer_; |
149 Callback callback_; | 163 Callback callback_; |
150 const bool in_process_; | 164 const bool in_process_; |
151 Error error_; | 165 Error error_; |
152 int extended_error_; | 166 int extended_error_; |
153 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 167 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
154 | 168 |
155 DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker); | 169 DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker); |
156 }; | 170 }; |
157 | 171 |
158 } // namespace component_updater | 172 } // namespace component_updater |
159 | 173 |
160 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 174 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
OLD | NEW |