Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/component_updater/component_unpacker.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 (file_util::PathExists(path)) { 112 if (file_util::PathExists(path)) {
113 if (!file_util::Delete(path, true)) 113 if (!base::Delete(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
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 file_util::Delete(unpack_diff_path, true); 189 base::Delete(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
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 file_util::Delete(unpack_path_, true); 226 base::Delete(unpack_path_, true);
227 } 227 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/timezone_settings.cc ('k') | chrome/browser/component_updater/component_updater_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698