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

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

Issue 434183002: Don't fail component registration if the component on disk is corrupt. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: switch the happy case to be first Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 older_dirs.push_back(path); 157 older_dirs.push_back(path);
158 } 158 }
159 } else { 159 } else {
160 latest_dir = path; 160 latest_dir = path;
161 latest_version = version; 161 latest_version = version;
162 found = true; 162 found = true;
163 } 163 }
164 } 164 }
165 165
166 if (found) { 166 if (found) {
167 current_version_ = latest_version;
168 // TODO(ddorwin): Remove these members and pass them directly to
169 // FinishRegistration().
170 base::ReadFileToString(latest_dir.AppendASCII("manifest.fingerprint"),
171 &current_fingerprint_);
172 current_manifest_ = ReadManifest(latest_dir); 167 current_manifest_ = ReadManifest(latest_dir);
173 if (!current_manifest_) { 168 if (current_manifest_) {
169 current_version_ = latest_version;
170 // TODO(ddorwin): Remove these members and pass them directly to
171 // FinishRegistration().
172 base::ReadFileToString(latest_dir.AppendASCII("manifest.fingerprint"),
173 &current_fingerprint_);
174 } else {
175 // If the manifest can't be read, mark the directory for deletion and
176 // continue as if there were no versioned directories at all.
174 DLOG(ERROR) << "Failed to read manifest for " 177 DLOG(ERROR) << "Failed to read manifest for "
175 << installer_traits_->GetName() << " (" 178 << installer_traits_->GetName() << " ("
176 << base_dir.MaybeAsASCII() << ")."; 179 << base_dir.MaybeAsASCII() << ").";
177 return; 180 older_dirs.push_back(latest_dir);
178 } 181 }
179 } 182 }
180 183
181 // Remove older versions of the component. None should be in use during 184 // Remove older versions of the component. None should be in use during
182 // browser startup. 185 // browser startup.
183 for (std::vector<base::FilePath>::iterator iter = older_dirs.begin(); 186 for (std::vector<base::FilePath>::iterator iter = older_dirs.begin();
184 iter != older_dirs.end(); 187 iter != older_dirs.end();
185 ++iter) { 188 ++iter) {
186 base::DeleteFile(*iter, true); 189 base::DeleteFile(*iter, true);
187 } 190 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 222
220 if (current_version_.CompareTo(base::Version(kNullVersion)) > 0) { 223 if (current_version_.CompareTo(base::Version(kNullVersion)) > 0) {
221 scoped_ptr<base::DictionaryValue> manifest_copy( 224 scoped_ptr<base::DictionaryValue> manifest_copy(
222 current_manifest_->DeepCopy()); 225 current_manifest_->DeepCopy());
223 installer_traits_->ComponentReady( 226 installer_traits_->ComponentReady(
224 current_version_, GetInstallDirectory(), manifest_copy.Pass()); 227 current_version_, GetInstallDirectory(), manifest_copy.Pass());
225 } 228 }
226 } 229 }
227 230
228 } // namespace component_updater 231 } // 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