| 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 beee14aa0f4b942c49671c52933ed8bb64968160..ec2215edd4771c8484053954fa1ae62d8466b690 100644
|
| --- a/chrome/browser/component_updater/component_updater_service.cc
|
| +++ b/chrome/browser/component_updater/component_updater_service.cc
|
| @@ -16,6 +16,7 @@
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "base/sequenced_task_runner.h"
|
| #include "base/stl_util.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_piece.h"
|
| @@ -332,8 +333,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::ComponentUnpacker::Error error,
|
| + int extended_error);
|
| +
|
| void DoneInstalling(const std::string& component_id,
|
| - ComponentUnpacker::Error error,
|
| + component_updater::ComponentUnpacker::Error error,
|
| int extended_error);
|
|
|
| void ChangeItemState(CrxUpdateItem* item, CrxUpdateItem::Status to);
|
| @@ -353,12 +359,14 @@ class CrxUpdateService : public ComponentUpdateService {
|
|
|
| scoped_ptr<ComponentUpdateService::Configurator> config_;
|
|
|
| - scoped_ptr<ComponentPatcher> component_patcher_;
|
| + scoped_ptr<component_updater::ComponentPatcher> component_patcher_;
|
|
|
| scoped_ptr<net::URLFetcher> url_fetcher_;
|
|
|
| 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_;
|
| @@ -1014,41 +1022,55 @@ 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::ComponentUnpacker::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,
|
| - int extra_code) {
|
| +void CrxUpdateService::DoneInstalling(
|
| + const std::string& component_id,
|
| + component_updater::ComponentUnpacker::Error error,
|
| + int extra_code) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| ErrorCategory error_category = kErrorNone;
|
| switch (error) {
|
| - case ComponentUnpacker::kNone:
|
| + case component_updater::ComponentUnpacker::kNone:
|
| break;
|
| - case ComponentUnpacker::kInstallerError:
|
| + case component_updater::ComponentUnpacker::kInstallerError:
|
| error_category = kInstallError;
|
| break;
|
| default:
|
| @@ -1056,7 +1078,7 @@ void CrxUpdateService::DoneInstalling(const std::string& component_id,
|
| break;
|
| }
|
|
|
| - const bool is_success = error == ComponentUnpacker::kNone;
|
| + const bool is_success = error == component_updater::ComponentUnpacker::kNone;
|
|
|
| CrxUpdateItem* item = FindUpdateItemById(component_id);
|
| if (item->status == CrxUpdateItem::kUpdatingDiff && !is_success) {
|
|
|