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

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

Issue 25883006: Support asynchronous patching operations in the component updater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tests
Patch Set: New LKGR, Windows fixes. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/component_updater/component_updater_service.cc
diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
index a4829d213a2f7abf5667e559a23c5b8d532f6e6d..61e797e3fb65ddcc233de39acf8580e5c57dce5e 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -349,8 +349,13 @@ class CrxUpdateService : public ComponentUpdateService {
void Install(const CRXContext* context, const base::FilePath& crx_path);
+ void DoneUnpacking(const std::string& component_id,
+ const base::FilePath& crx_path,
+ component_updater::Error error,
+ int extended_error);
+
void DoneInstalling(const std::string& component_id,
- ComponentUnpacker::Error error,
+ component_updater::Error error,
int extended_error);
size_t ChangeItemStatus(CrxUpdateItem::Status from,
@@ -922,36 +927,47 @@ void CrxUpdateService::Install(const CRXContext* context,
const base::FilePath& crx_path) {
// This function owns the |crx_path| and the |context| object.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- ComponentUnpacker unpacker(context->pk_hash,
- crx_path,
- context->fingerprint,
- component_patcher_.get(),
- context->installer);
+ component_updater::Unpack(context->pk_hash,
+ crx_path,
+ context->fingerprint,
+ component_patcher_.get(),
+ context->installer,
+ base::Bind(&CrxUpdateService::DoneUnpacking,
+ base::Unretained(this),
+ context->id,
+ crx_path));
+ delete context;
+}
+
+// Do some cleanup before we skip back to the UI thread.
+void CrxUpdateService::DoneUnpacking(const std::string& component_id,
+ const base::FilePath& crx_path,
+ component_updater::Error error,
+ int extended_error) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
if (!base::DeleteFile(crx_path, false))
NOTREACHED() << crx_path.value();
- // Why unretained? See comment at top of file.
BrowserThread::PostDelayedTask(
BrowserThread::UI,
FROM_HERE,
base::Bind(&CrxUpdateService::DoneInstalling, base::Unretained(this),
- context->id, unpacker.error(), unpacker.extended_error()),
+ component_id, error, extended_error),
base::TimeDelta::FromMilliseconds(config_->StepDelay()));
- delete context;
}
// Installation has been completed. Adjust the component status and
// schedule the next check. Schedule a short delay before trying the full
// update when the differential update failed.
void CrxUpdateService::DoneInstalling(const std::string& component_id,
- ComponentUnpacker::Error error,
+ component_updater::Error error,
int extra_code) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
ErrorCategory error_category = kErrorNone;
switch (error) {
- case ComponentUnpacker::kNone:
+ case component_updater::kNone:
break;
- case ComponentUnpacker::kInstallerError:
+ case component_updater::kInstallerError:
error_category = kInstallError;
break;
default:
@@ -959,7 +975,7 @@ void CrxUpdateService::DoneInstalling(const std::string& component_id,
break;
}
- const bool is_success = error == ComponentUnpacker::kNone;
+ const bool is_success = error == component_updater::kNone;
CrxUpdateItem* item = FindUpdateItemById(component_id);
if (item->status == CrxUpdateItem::kUpdatingDiff && !is_success) {

Powered by Google App Engine
This is Rietveld 408576698