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

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

Issue 1830023002: Add some more logging to help diagnise component update issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@brand
Patch Set: Created 4 years, 9 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 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 void DefaultComponentInstaller::OnUpdateError(int error) { 69 void DefaultComponentInstaller::OnUpdateError(int error) {
70 NOTREACHED() << "Component update error: " << error; 70 NOTREACHED() << "Component update error: " << error;
71 } 71 }
72 72
73 bool DefaultComponentInstaller::InstallHelper( 73 bool DefaultComponentInstaller::InstallHelper(
74 const base::DictionaryValue& manifest, 74 const base::DictionaryValue& manifest,
75 const base::FilePath& unpack_path, 75 const base::FilePath& unpack_path,
76 const base::FilePath& install_path) { 76 const base::FilePath& install_path) {
77 if (!base::Move(unpack_path, install_path)) 77 VLOG(1) << "InstallHelper: unpack_path=" << unpack_path.AsUTF8Unsafe()
78 << " install_path=" << install_path.AsUTF8Unsafe();
79
80 if (!base::Move(unpack_path, install_path)) {
81 PLOG(ERROR) << "Move failed.";
78 return false; 82 return false;
79 if (!installer_traits_->OnCustomInstall(manifest, install_path)) 83 }
84 if (!installer_traits_->OnCustomInstall(manifest, install_path)) {
85 PLOG(ERROR) << "CustomInstall failed.";
80 return false; 86 return false;
81 if (!installer_traits_->VerifyInstallation(manifest, install_path)) 87 }
88 if (!installer_traits_->VerifyInstallation(manifest, install_path)) {
89 PLOG(ERROR) << "VerifyInstallation failed.";
82 return false; 90 return false;
91 }
92
83 return true; 93 return true;
84 } 94 }
85 95
86 bool DefaultComponentInstaller::Install(const base::DictionaryValue& manifest, 96 bool DefaultComponentInstaller::Install(const base::DictionaryValue& manifest,
87 const base::FilePath& unpack_path) { 97 const base::FilePath& unpack_path) {
88 std::string manifest_version; 98 std::string manifest_version;
89 manifest.GetStringASCII("version", &manifest_version); 99 manifest.GetStringASCII("version", &manifest_version);
90 base::Version version(manifest_version); 100 base::Version version(manifest_version);
101
102 VLOG(1) << "Install: version=" << version.GetString()
103 << " current version=" << current_version_.GetString();
104
91 if (!version.IsValid()) 105 if (!version.IsValid())
92 return false; 106 return false;
93 if (current_version_.CompareTo(version) > 0) 107 if (current_version_.CompareTo(version) > 0)
94 return false; 108 return false;
95 base::FilePath install_path = 109 base::FilePath install_path =
96 installer_traits_->GetBaseDirectory().AppendASCII(version.GetString()); 110 installer_traits_->GetBaseDirectory().AppendASCII(version.GetString());
97 if (base::PathExists(install_path)) { 111 if (base::PathExists(install_path)) {
98 if (!base::DeleteFile(install_path, true)) 112 if (!base::DeleteFile(install_path, true))
99 return false; 113 return false;
100 } 114 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 FROM_HERE, 147 FROM_HERE,
134 base::Bind(&DefaultComponentInstaller::UninstallOnTaskRunner, this)); 148 base::Bind(&DefaultComponentInstaller::UninstallOnTaskRunner, this));
135 return true; 149 return true;
136 } 150 }
137 151
138 void DefaultComponentInstaller::StartRegistration(ComponentUpdateService* cus) { 152 void DefaultComponentInstaller::StartRegistration(ComponentUpdateService* cus) {
139 DCHECK(task_runner_.get()); 153 DCHECK(task_runner_.get());
140 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 154 DCHECK(task_runner_->RunsTasksOnCurrentThread());
141 base::FilePath base_dir = installer_traits_->GetBaseDirectory(); 155 base::FilePath base_dir = installer_traits_->GetBaseDirectory();
142 if (!base::PathExists(base_dir) && !base::CreateDirectory(base_dir)) { 156 if (!base::PathExists(base_dir) && !base::CreateDirectory(base_dir)) {
143 NOTREACHED() << "Could not create the base directory for " 157 PLOG(ERROR) << "Could not create the base directory for "
144 << installer_traits_->GetName() << " (" 158 << installer_traits_->GetName() << " ("
145 << base_dir.MaybeAsASCII() << ")."; 159 << base_dir.MaybeAsASCII() << ").";
146 return; 160 return;
147 } 161 }
148 162
149 base::FilePath latest_path; 163 base::FilePath latest_path;
150 base::Version latest_version(kNullVersion); 164 base::Version latest_version(kNullVersion);
151 scoped_ptr<base::DictionaryValue> latest_manifest; 165 scoped_ptr<base::DictionaryValue> latest_manifest;
152 166
153 std::vector<base::FilePath> older_paths; 167 std::vector<base::FilePath> older_paths;
154 base::FileEnumerator file_enumerator( 168 base::FileEnumerator file_enumerator(
155 base_dir, false, base::FileEnumerator::DIRECTORIES); 169 base_dir, false, base::FileEnumerator::DIRECTORIES);
(...skipping 10 matching lines...) Expand all
166 // |version| not newer than the latest found version (kNullVersion if no 180 // |version| not newer than the latest found version (kNullVersion if no
167 // version has been found yet) is marked for removal. 181 // version has been found yet) is marked for removal.
168 if (version.CompareTo(latest_version) <= 0) { 182 if (version.CompareTo(latest_version) <= 0) {
169 older_paths.push_back(path); 183 older_paths.push_back(path);
170 continue; 184 continue;
171 } 185 }
172 186
173 scoped_ptr<base::DictionaryValue> manifest = 187 scoped_ptr<base::DictionaryValue> manifest =
174 update_client::ReadManifest(path); 188 update_client::ReadManifest(path);
175 if (!manifest || !installer_traits_->VerifyInstallation(*manifest, path)) { 189 if (!manifest || !installer_traits_->VerifyInstallation(*manifest, path)) {
176 DLOG(ERROR) << "Failed to read manifest or verify installation for " 190 PLOG(ERROR) << "Failed to read manifest or verify installation for "
177 << installer_traits_->GetName() << " (" 191 << installer_traits_->GetName() << " (" << path.MaybeAsASCII()
178 << path.MaybeAsASCII() << ")."; 192 << ").";
179 older_paths.push_back(path); 193 older_paths.push_back(path);
180 continue; 194 continue;
181 } 195 }
182 196
183 // New valid |version| folder found! 197 // New valid |version| folder found!
184 198
185 if (latest_manifest) { 199 if (latest_manifest) {
186 DCHECK(!latest_path.empty()); 200 DCHECK(!latest_path.empty());
187 older_paths.push_back(latest_path); 201 older_paths.push_back(latest_path);
188 } 202 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if (!current_manifest_) 277 if (!current_manifest_)
264 return; 278 return;
265 279
266 scoped_ptr<base::DictionaryValue> manifest_copy( 280 scoped_ptr<base::DictionaryValue> manifest_copy(
267 current_manifest_->DeepCopy()); 281 current_manifest_->DeepCopy());
268 ComponentReady(std::move(manifest_copy)); 282 ComponentReady(std::move(manifest_copy));
269 } 283 }
270 284
271 void DefaultComponentInstaller::ComponentReady( 285 void DefaultComponentInstaller::ComponentReady(
272 scoped_ptr<base::DictionaryValue> manifest) { 286 scoped_ptr<base::DictionaryValue> manifest) {
287 VLOG(1) << "ComponentReady";
273 installer_traits_->ComponentReady(current_version_, GetInstallDirectory(), 288 installer_traits_->ComponentReady(current_version_, GetInstallDirectory(),
274 std::move(manifest)); 289 std::move(manifest));
275 } 290 }
276 291
277 } // namespace component_updater 292 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698