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 #include "chrome/browser/component_updater/component_unpacker.h" | 5 #include "chrome/browser/component_updater/component_unpacker.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 return NULL; | 103 return NULL; |
104 return static_cast<base::DictionaryValue*>(root.release()); | 104 return static_cast<base::DictionaryValue*>(root.release()); |
105 } | 105 } |
106 | 106 |
107 // Deletes a path if it exists, and then creates a directory there. | 107 // Deletes a path if it exists, and then creates a directory there. |
108 // Returns true if and only if these operations were successful. | 108 // Returns true if and only if these operations were successful. |
109 // This method doesn't take any special steps to prevent files from | 109 // This method doesn't take any special steps to prevent files from |
110 // being inserted into the target directory by another process or thread. | 110 // being inserted into the target directory by another process or thread. |
111 bool MakeEmptyDirectory(const base::FilePath& path) { | 111 bool MakeEmptyDirectory(const base::FilePath& path) { |
112 if (base::PathExists(path)) { | 112 if (base::PathExists(path)) { |
113 if (!base::Delete(path, true)) | 113 if (!base::DeleteFile(path, true)) |
114 return false; | 114 return false; |
115 } | 115 } |
116 if (!file_util::CreateDirectory(path)) | 116 if (!file_util::CreateDirectory(path)) |
117 return false; | 117 return false; |
118 return true; | 118 return true; |
119 } | 119 } |
120 | 120 |
121 } // namespace. | 121 } // namespace. |
122 | 122 |
123 ComponentUnpacker::ComponentUnpacker(const std::vector<uint8>& pk_hash, | 123 ComponentUnpacker::ComponentUnpacker(const std::vector<uint8>& pk_hash, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 if (!zip::Unzip(path, unpack_diff_path)) { | 180 if (!zip::Unzip(path, unpack_diff_path)) { |
181 error_ = kUnzipFailed; | 181 error_ = kUnzipFailed; |
182 return; | 182 return; |
183 } | 183 } |
184 ComponentUnpacker::Error result = DifferentialUpdatePatch(unpack_diff_path, | 184 ComponentUnpacker::Error result = DifferentialUpdatePatch(unpack_diff_path, |
185 unpack_path_, | 185 unpack_path_, |
186 patcher, | 186 patcher, |
187 installer, | 187 installer, |
188 &extended_error_); | 188 &extended_error_); |
189 base::Delete(unpack_diff_path, true); | 189 base::DeleteFile(unpack_diff_path, true); |
190 unpack_diff_path.clear(); | 190 unpack_diff_path.clear(); |
191 error_ = result; | 191 error_ = result; |
192 if (error_ != kNone) { | 192 if (error_ != kNone) { |
193 return; | 193 return; |
194 } | 194 } |
195 } else { | 195 } else { |
196 // Package is a normal update/install; unzip it into unpack_path_ directly. | 196 // Package is a normal update/install; unzip it into unpack_path_ directly. |
197 if (!zip::Unzip(path, unpack_path_)) { | 197 if (!zip::Unzip(path, unpack_path_)) { |
198 error_ = kUnzipFailed; | 198 error_ = kUnzipFailed; |
199 return; | 199 return; |
(...skipping 16 matching lines...) Expand all Loading... |
216 if (!installer->Install(*manifest, unpack_path_)) { | 216 if (!installer->Install(*manifest, unpack_path_)) { |
217 error_ = kInstallerError; | 217 error_ = kInstallerError; |
218 return; | 218 return; |
219 } | 219 } |
220 // Installation successful. The directory is not our concern now. | 220 // Installation successful. The directory is not our concern now. |
221 unpack_path_.clear(); | 221 unpack_path_.clear(); |
222 } | 222 } |
223 | 223 |
224 ComponentUnpacker::~ComponentUnpacker() { | 224 ComponentUnpacker::~ComponentUnpacker() { |
225 if (!unpack_path_.empty()) | 225 if (!unpack_path_.empty()) |
226 base::Delete(unpack_path_, true); | 226 base::DeleteFile(unpack_path_, true); |
227 } | 227 } |
OLD | NEW |