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

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

Issue 25909005: Use UtilityProcessHost to patch files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nonblocking
Patch Set: Rebase to LKGR/248226 Created 6 years, 10 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
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/bind.h" 10 #include "base/bind.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 bool is_delta_; 91 bool is_delta_;
92 std::vector<uint8> public_key_; 92 std::vector<uint8> public_key_;
93 }; 93 };
94 94
95 } // namespace 95 } // namespace
96 96
97 ComponentUnpacker::ComponentUnpacker( 97 ComponentUnpacker::ComponentUnpacker(
98 const std::vector<uint8>& pk_hash, 98 const std::vector<uint8>& pk_hash,
99 const base::FilePath& path, 99 const base::FilePath& path,
100 const std::string& fingerprint, 100 const std::string& fingerprint,
101 ComponentPatcher* patcher,
102 ComponentInstaller* installer, 101 ComponentInstaller* installer,
102 bool in_process,
103 scoped_refptr<base::SequencedTaskRunner> task_runner) 103 scoped_refptr<base::SequencedTaskRunner> task_runner)
104 : pk_hash_(pk_hash), 104 : pk_hash_(pk_hash),
105 path_(path), 105 path_(path),
106 is_delta_(false), 106 is_delta_(false),
107 fingerprint_(fingerprint), 107 fingerprint_(fingerprint),
108 patcher_(patcher),
109 installer_(installer), 108 installer_(installer),
109 in_process_(in_process),
110 error_(kNone), 110 error_(kNone),
111 extended_error_(0), 111 extended_error_(0),
112 ptr_factory_(this), 112 ptr_factory_(this),
113 task_runner_(task_runner) { 113 task_runner_(task_runner) {
114 } 114 }
115 115
116 // TODO(cpu): add a specific attribute check to a component json that the 116 // TODO(cpu): add a specific attribute check to a component json that the
117 // extension unpacker will reject, so that a component cannot be installed 117 // extension unpacker will reject, so that a component cannot be installed
118 // as an extension. 118 // as an extension.
119 scoped_ptr<base::DictionaryValue> ReadManifest( 119 scoped_ptr<base::DictionaryValue> ReadManifest(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 195
196 196
197 bool ComponentUnpacker::BeginPatching() { 197 bool ComponentUnpacker::BeginPatching() {
198 if (is_delta_) { // Package is a diff package. 198 if (is_delta_) { // Package is a diff package.
199 // Use a different temp directory for the patch output files. 199 // Use a different temp directory for the patch output files.
200 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), 200 if (!base::CreateNewTempDirectory(base::FilePath::StringType(),
201 &unpack_path_)) { 201 &unpack_path_)) {
202 error_ = kUnzipPathError; 202 error_ = kUnzipPathError;
203 return false; 203 return false;
204 } 204 }
205 patcher_.reset(new ComponentPatcher(unpack_diff_path_,
206 unpack_path_,
207 installer_,
208 in_process_,
209 task_runner_));
205 task_runner_->PostTask( 210 task_runner_->PostTask(
206 FROM_HERE, base::Bind(&DifferentialUpdatePatch, 211 FROM_HERE, base::Bind(&ComponentPatcher::Start,
207 unpack_diff_path_, 212 patcher_->GetWeakPtr(),
208 unpack_path_,
209 patcher_,
210 installer_,
211 base::Bind(&ComponentUnpacker::EndPatching, 213 base::Bind(&ComponentUnpacker::EndPatching,
212 GetWeakPtr()))); 214 GetWeakPtr())));
213 } else { 215 } else {
214 task_runner_->PostTask( 216 task_runner_->PostTask(
215 FROM_HERE, base::Bind(&ComponentUnpacker::EndPatching, 217 FROM_HERE, base::Bind(&ComponentUnpacker::EndPatching,
216 GetWeakPtr(), 218 GetWeakPtr(),
217 kNone, 219 kNone,
218 0)); 220 0));
219 } 221 }
220 return true; 222 return true;
221 } 223 }
222 224
223 void ComponentUnpacker::EndPatching(Error error, int extended_error) { 225 void ComponentUnpacker::EndPatching(Error error, int extended_error) {
226 patcher_.reset();
224 error_ = error; 227 error_ = error;
225 extended_error_ = extended_error; 228 extended_error_ = extended_error;
226 if (error_ != kNone) { 229 if (error_ != kNone) {
227 Finish(); 230 Finish();
228 return; 231 return;
229 } 232 }
230 // Optimization: clean up patch files early, in case disk space is too low to 233 // Optimization: clean up patch files early, in case disk space is too low to
231 // install otherwise. 234 // install otherwise.
232 if (!unpack_diff_path_.empty()) { 235 if (!unpack_diff_path_.empty()) {
233 base::DeleteFile(unpack_diff_path_, true); 236 base::DeleteFile(unpack_diff_path_, true);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 271 }
269 272
270 base::WeakPtr<ComponentUnpacker> ComponentUnpacker::GetWeakPtr() { 273 base::WeakPtr<ComponentUnpacker> ComponentUnpacker::GetWeakPtr() {
271 return ptr_factory_.GetWeakPtr(); 274 return ptr_factory_.GetWeakPtr();
272 } 275 }
273 276
274 ComponentUnpacker::~ComponentUnpacker() { 277 ComponentUnpacker::~ComponentUnpacker() {
275 } 278 }
276 279
277 } // namespace component_updater 280 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698