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

Side by Side Diff: components/component_updater/default_component_installer.cc

Issue 2022273002: Add logging in DefaultComponentInstaller to help investigate a bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/component_updater/default_component_installer.h" 5 #include "components/component_updater/default_component_installer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 146
147 bool DefaultComponentInstaller::Uninstall() { 147 bool DefaultComponentInstaller::Uninstall() {
148 DCHECK(thread_checker_.CalledOnValidThread()); 148 DCHECK(thread_checker_.CalledOnValidThread());
149 task_runner_->PostTask( 149 task_runner_->PostTask(
150 FROM_HERE, 150 FROM_HERE,
151 base::Bind(&DefaultComponentInstaller::UninstallOnTaskRunner, this)); 151 base::Bind(&DefaultComponentInstaller::UninstallOnTaskRunner, this));
152 return true; 152 return true;
153 } 153 }
154 154
155 // TODO(xhwang): The following LOG(WARNING) messages are added to help
156 // investigate http://crbug.com/614745. Remove redundant checks or convent them
157 // to VLOG(1) after investigation is completed.
155 bool DefaultComponentInstaller::FindPreinstallation() { 158 bool DefaultComponentInstaller::FindPreinstallation() {
156 base::FilePath path; 159 base::FilePath path;
157 if (!PathService::Get(DIR_COMPONENT_PREINSTALLED, &path)) 160 if (!PathService::Get(DIR_COMPONENT_PREINSTALLED, &path)) {
161 LOG(WARNING) << "DIR_COMPONENT_PREINSTALLED does not exist.";
158 return false; 162 return false;
163 }
164
159 path = path.Append(installer_traits_->GetRelativeInstallDir()); 165 path = path.Append(installer_traits_->GetRelativeInstallDir());
160 if (!base::PathExists(path)) 166 if (!base::PathExists(path)) {
167 LOG(WARNING) << "Relative install dir does not exist: "
168 << path.MaybeAsASCII();
161 return false; 169 return false;
170 }
171
162 std::unique_ptr<base::DictionaryValue> manifest = 172 std::unique_ptr<base::DictionaryValue> manifest =
163 update_client::ReadManifest(path); 173 update_client::ReadManifest(path);
164 if (!manifest || !installer_traits_->VerifyInstallation(*manifest, path)) 174 if (!manifest) {
175 LOG(WARNING) << "Manifest does not exist: " << path.MaybeAsASCII();
165 return false; 176 return false;
177 }
178
179 if (!installer_traits_->VerifyInstallation(*manifest, path)) {
180 LOG(WARNING) << "Installation verification failed: " << path.MaybeAsASCII();
181 return false;
182 }
183
166 std::string version_lexical; 184 std::string version_lexical;
167 if (!manifest->GetStringASCII("version", &version_lexical)) 185 if (!manifest->GetStringASCII("version", &version_lexical)) {
186 LOG(WARNING) << "Failed to get component version from the manifest.";
168 return false; 187 return false;
188 }
189
169 const base::Version version(version_lexical); 190 const base::Version version(version_lexical);
170 if (!version.IsValid()) 191 if (!version.IsValid()) {
192 LOG(WARNING) << "Version in the manifest is invalid:" << version_lexical;
171 return false; 193 return false;
194 }
195
196 LOG(WARNING) << "Preinstalled component found for "
197 << installer_traits_->GetName() << " at " << path.MaybeAsASCII()
198 << " with version " << version << ".";
199
172 current_install_dir_ = path; 200 current_install_dir_ = path;
173 current_manifest_ = std::move(manifest); 201 current_manifest_ = std::move(manifest);
174 current_version_ = version; 202 current_version_ = version;
175 return true; 203 return true;
176 } 204 }
177 205
178 void DefaultComponentInstaller::StartRegistration(ComponentUpdateService* cus) { 206 void DefaultComponentInstaller::StartRegistration(ComponentUpdateService* cus) {
207 LOG(WARNING) << __FUNCTION__ << " for " << installer_traits_->GetName();
179 DCHECK(task_runner_.get()); 208 DCHECK(task_runner_.get());
180 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 209 DCHECK(task_runner_->RunsTasksOnCurrentThread());
181 210
182 base::Version latest_version(kNullVersion); 211 base::Version latest_version(kNullVersion);
183 212
184 // First check for an installation set up alongside Chrome itself. 213 // First check for an installation set up alongside Chrome itself.
185 if (FindPreinstallation()) 214 if (FindPreinstallation())
186 latest_version = current_version_; 215 latest_version = current_version_;
187 216
188 // Then check for a higher-versioned user-wide installation. 217 // Then check for a higher-versioned user-wide installation.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // Delete the base directory if it's empty now. 313 // Delete the base directory if it's empty now.
285 if (base::IsDirectoryEmpty(base_dir)) { 314 if (base::IsDirectoryEmpty(base_dir)) {
286 if (base::DeleteFile(base_dir, false)) 315 if (base::DeleteFile(base_dir, false))
287 DLOG(ERROR) << "Couldn't delete " << base_dir.value(); 316 DLOG(ERROR) << "Couldn't delete " << base_dir.value();
288 } 317 }
289 } 318 }
290 319
291 void DefaultComponentInstaller::FinishRegistration( 320 void DefaultComponentInstaller::FinishRegistration(
292 ComponentUpdateService* cus, 321 ComponentUpdateService* cus,
293 const base::Closure& callback) { 322 const base::Closure& callback) {
323 LOG(WARNING) << __FUNCTION__ << " for " << installer_traits_->GetName();
294 DCHECK(thread_checker_.CalledOnValidThread()); 324 DCHECK(thread_checker_.CalledOnValidThread());
325
295 if (installer_traits_->CanAutoUpdate()) { 326 if (installer_traits_->CanAutoUpdate()) {
296 CrxComponent crx; 327 CrxComponent crx;
297 crx.name = installer_traits_->GetName(); 328 crx.name = installer_traits_->GetName();
298 crx.requires_network_encryption = 329 crx.requires_network_encryption =
299 installer_traits_->RequiresNetworkEncryption(); 330 installer_traits_->RequiresNetworkEncryption();
300 crx.installer = this; 331 crx.installer = this;
301 crx.version = current_version_; 332 crx.version = current_version_;
302 crx.fingerprint = current_fingerprint_; 333 crx.fingerprint = current_fingerprint_;
303 installer_traits_->GetHash(&crx.pk_hash); 334 installer_traits_->GetHash(&crx.pk_hash);
304 if (!cus->RegisterComponent(crx)) { 335 if (!cus->RegisterComponent(crx)) {
305 NOTREACHED() << "Component registration failed for " 336 LOG(WARNING) << "Component registration failed for "
306 << installer_traits_->GetName(); 337 << installer_traits_->GetName();
307 return; 338 return;
308 } 339 }
309 340
310 if (!callback.is_null()) 341 if (!callback.is_null())
311 callback.Run(); 342 callback.Run();
312 } 343 }
313 344
314 if (!current_manifest_) 345 if (!current_manifest_) {
346 LOG(WARNING) << "No component found for " << installer_traits_->GetName();
315 return; 347 return;
348 }
316 349
317 std::unique_ptr<base::DictionaryValue> manifest_copy( 350 std::unique_ptr<base::DictionaryValue> manifest_copy(
318 current_manifest_->DeepCopy()); 351 current_manifest_->DeepCopy());
319 ComponentReady(std::move(manifest_copy)); 352 ComponentReady(std::move(manifest_copy));
320 } 353 }
321 354
322 void DefaultComponentInstaller::ComponentReady( 355 void DefaultComponentInstaller::ComponentReady(
323 std::unique_ptr<base::DictionaryValue> manifest) { 356 std::unique_ptr<base::DictionaryValue> manifest) {
324 VLOG(1) << "Component ready, version " << current_version_.GetString() 357 VLOG(1) << "Component ready, version " << current_version_.GetString()
325 << " in " << current_install_dir_.value(); 358 << " in " << current_install_dir_.value();
326 installer_traits_->ComponentReady(current_version_, current_install_dir_, 359 installer_traits_->ComponentReady(current_version_, current_install_dir_,
327 std::move(manifest)); 360 std::move(manifest));
328 } 361 }
329 362
330 } // namespace component_updater 363 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698