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

Unified Diff: chrome/browser/component_updater/background_downloader_win.cc

Issue 113533004: Clean up empty directories after install and on errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/component_updater/background_downloader_win.cc
diff --git a/chrome/browser/component_updater/background_downloader_win.cc b/chrome/browser/component_updater/background_downloader_win.cc
index 5ee7aa5859407af5ae803ba7dd63dd41aadb16a1..5a7dec210cee2b2ca0f9fbf750f1da5267e9c003 100644
--- a/chrome/browser/component_updater/background_downloader_win.cc
+++ b/chrome/browser/component_updater/background_downloader_win.cc
@@ -310,6 +310,18 @@ HRESULT GetBitsManager(IBackgroundCopyManager** bits_manager) {
return S_OK;
}
+void CleanupJobFiles(IBackgroundCopyJob* job) {
+ std::vector<ScopedComPtr<IBackgroundCopyFile> > files;
+ if (FAILED(GetFilesInJob(job, &files)))
+ return;
+ for (size_t i = 0; i != files.size(); ++i) {
+ base::string16 local_name;
+ HRESULT hr(GetJobFileProperties(files[i], &local_name, NULL, NULL));
+ if (SUCCEEDED(hr))
+ DeleteFileAndEmptyParentDirectory(base::FilePath(local_name));
+ }
+}
+
} // namespace
BackgroundDownloader::BackgroundDownloader(
@@ -444,8 +456,10 @@ void BackgroundDownloader::EndDownload(HRESULT error) {
}
}
- if (FAILED(error) && job_)
+ if (FAILED(error) && job_) {
job_->Cancel();
+ CleanupJobFiles(job_);
+ }
job_ = NULL;
@@ -658,6 +672,7 @@ HRESULT BackgroundDownloader::CleanupStaleJobs(
for (size_t i = 0; i != jobs.size(); ++i) {
jobs[i]->Cancel();
+ CleanupJobFiles(jobs[i]);
}
return S_OK;

Powered by Google App Engine
This is Rietveld 408576698