Chromium Code Reviews| 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 de0b90a5f5572061a3bf6c8fa52241ec5a3cb30d..5f964f560a36dacb364795e5765b75b11691d18e 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/threading/sequenced_worker_pool.h" |
| #include "base/timer/timer.h" |
| @@ -224,6 +225,11 @@ class CrxUpdateService : public ComponentUpdateService { |
| void Install(scoped_ptr<CRXContext> context, const base::FilePath& crx_path); |
| + void DoneUnpacking(const std::string& component_id, |
| + const base::FilePath& crx_path, |
| + ComponentUnpacker::Error error, |
| + int extended_error); |
| + |
| void DoneInstalling(const std::string& component_id, |
| ComponentUnpacker::Error error, |
| int extended_error); |
| @@ -251,6 +257,8 @@ class CrxUpdateService : public ComponentUpdateService { |
| scoped_ptr<PingManager> ping_manager_; |
| + scoped_ptr<ComponentUnpacker> unpacker_; |
| + |
| scoped_ptr<CrxDownloader> crx_downloader_; |
| // A collection of every work item. |
| @@ -827,25 +835,36 @@ void CrxUpdateService::DownloadComplete( |
| // 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(scoped_ptr<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 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)); |
| +} |
| + |
| +// Do some cleanup before we skip back to the UI thread. |
|
Sorin Jianu
2014/01/25 02:30:21
This comment is more an implementation comment tha
waffles
2014/01/28 21:06:31
Done.
|
| +void CrxUpdateService::DoneUnpacking( |
| + const std::string& component_id, |
| + const base::FilePath& crx_path, |
| + ComponentUnpacker::Error error, |
| + int extended_error) { |
| if (!DeleteFileAndEmptyParentDirectory(crx_path)) |
| 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())); |
| } |