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

Side by Side Diff: chrome/installer/util/installer_state.cc

Issue 6538025: Temp dir cleanup:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/installer/util/installer_state.h" 5 #include "chrome/installer/util/installer_state.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 381
382 return current_version.release(); 382 return current_version.release();
383 } 383 }
384 384
385 FilePath InstallerState::GetInstallerDirectory(const Version& version) const { 385 FilePath InstallerState::GetInstallerDirectory(const Version& version) const {
386 return target_path().Append(ASCIIToWide(version.GetString())) 386 return target_path().Append(ASCIIToWide(version.GetString()))
387 .Append(kInstallerDir); 387 .Append(kInstallerDir);
388 } 388 }
389 389
390 void InstallerState::RemoveOldVersionDirectories( 390 void InstallerState::RemoveOldVersionDirectories(
391 const Version& latest_version) const { 391 const Version& latest_version,
392 const FilePath& temp_path) const {
392 file_util::FileEnumerator version_enum(target_path(), false, 393 file_util::FileEnumerator version_enum(target_path(), false,
393 file_util::FileEnumerator::DIRECTORIES); 394 file_util::FileEnumerator::DIRECTORIES);
394 scoped_ptr<Version> version; 395 scoped_ptr<Version> version;
395 std::vector<FilePath> key_files; 396 std::vector<FilePath> key_files;
396 397
397 // We try to delete all directories whose versions are lower than 398 // We try to delete all directories whose versions are lower than
398 // latest_version. 399 // latest_version.
399 FilePath next_version = version_enum.Next(); 400 FilePath next_version = version_enum.Next();
400 while (!next_version.empty()) { 401 while (!next_version.empty()) {
401 file_util::FileEnumerator::FindInfo find_data = {0}; 402 file_util::FileEnumerator::FindInfo find_data = {0};
402 version_enum.GetFindInfo(&find_data); 403 version_enum.GetFindInfo(&find_data);
403 VLOG(1) << "directory found: " << find_data.cFileName; 404 VLOG(1) << "directory found: " << find_data.cFileName;
404 version.reset(Version::GetVersionFromString( 405 version.reset(Version::GetVersionFromString(
405 WideToASCII(find_data.cFileName))); 406 WideToASCII(find_data.cFileName)));
406 if (version.get() && latest_version.CompareTo(*version) > 0) { 407 if (version.get() && latest_version.CompareTo(*version) > 0) {
407 key_files.clear(); 408 key_files.clear();
408 std::for_each(products_.begin(), products_.end(), 409 std::for_each(products_.begin(), products_.end(),
409 std::bind2nd(std::mem_fun(&Product::AddKeyFiles), 410 std::bind2nd(std::mem_fun(&Product::AddKeyFiles),
410 &key_files)); 411 &key_files));
411 const std::vector<FilePath>::iterator end = key_files.end(); 412 const std::vector<FilePath>::iterator end = key_files.end();
412 for (std::vector<FilePath>::iterator scan = key_files.begin(); 413 for (std::vector<FilePath>::iterator scan = key_files.begin();
413 scan != end; ++scan) { 414 scan != end; ++scan) {
414 *scan = next_version.Append(*scan); 415 *scan = next_version.Append(*scan);
415 } 416 }
416 417
417 VLOG(1) << "Deleting directory: " << next_version.value(); 418 VLOG(1) << "Deleting directory: " << next_version.value();
418 419
419 scoped_ptr<WorkItem> item( 420 scoped_ptr<WorkItem> item(
420 WorkItem::CreateDeleteTreeWorkItem(next_version, key_files)); 421 WorkItem::CreateDeleteTreeWorkItem(next_version, temp_path,
422 key_files));
421 if (!item->Do()) 423 if (!item->Do())
422 item->Rollback(); 424 item->Rollback();
423 } 425 }
424 426
425 next_version = version_enum.Next(); 427 next_version = version_enum.Next();
426 } 428 }
427 } 429 }
428 430
429 void InstallerState::AddComDllList(std::vector<FilePath>* com_dll_list) const { 431 void InstallerState::AddComDllList(std::vector<FilePath>* com_dll_list) const {
430 std::for_each(products_.begin(), products_.end(), 432 std::for_each(products_.begin(), products_.end(),
431 std::bind2nd(std::mem_fun(&Product::AddComDllList), 433 std::bind2nd(std::mem_fun(&Product::AddComDllList),
432 com_dll_list)); 434 com_dll_list));
433 } 435 }
434 436
435 bool InstallerState::SetChannelFlags(bool set, 437 bool InstallerState::SetChannelFlags(bool set,
436 ChannelInfo* channel_info) const { 438 ChannelInfo* channel_info) const {
437 bool modified = false; 439 bool modified = false;
438 for (Products::const_iterator scan = products_.begin(), end = products_.end(); 440 for (Products::const_iterator scan = products_.begin(), end = products_.end();
439 scan != end; ++scan) { 441 scan != end; ++scan) {
440 modified |= (*scan)->SetChannelFlags(set, channel_info); 442 modified |= (*scan)->SetChannelFlags(set, channel_info);
441 } 443 }
442 return modified; 444 return modified;
443 } 445 }
444 446
445 } // namespace installer 447 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698