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

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: Threading model changes. Created 7 years, 1 month 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 492c7f1f0f4d638fb19a73c285cbba75828d9472..1a87ffe5d0f773fd0f378f544b5a96c050d58634 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -413,8 +413,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);
void ChangeItemState(CrxUpdateItem* item, CrxUpdateItem::Status to);
@@ -440,6 +445,8 @@ class CrxUpdateService : public ComponentUpdateService {
scoped_ptr<component_updater::PingManager> ping_manager_;
+ scoped_ptr<component_updater::ComponentUnpacker> unpacker_;
+
// A collection of every work item.
typedef std::vector<CrxUpdateItem*> UpdateItems;
UpdateItems work_items_;
@@ -1061,41 +1068,53 @@ void CrxUpdateService::OnURLFetchComplete(const net::URLFetcher* source,
// Install consists of digital signature verification, unpacking and then
// calling the component specific installer. All that is handled by the
-// |unpacker|. If there is an error this function is in charge of deleting
+// |unpacker_|. If there is an error this function is in charge of deleting
// the files created.
void CrxUpdateService::Install(const CRXContext* context,
const base::FilePath& crx_path) {
// This function owns the file at |crx_path| and the |context| object.
- ComponentUnpacker unpacker(context->pk_hash,
- crx_path,
- context->fingerprint,
- component_patcher_.get(),
- context->installer);
+ unpacker_.reset(new component_updater::ComponentUnpacker(
+ context->pk_hash,
+ crx_path,
+ context->fingerprint,
+ component_patcher_.get(),
+ context->installer,
+ blocking_task_runner_));
+ unpacker_->Unpack(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) {
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:
@@ -1103,7 +1122,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