summaryrefslogtreecommitdiffstats
path: root/components/component_updater
diff options
context:
space:
mode:
authorbauerb <bauerb@chromium.org>2015-02-27 09:27:43 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-27 17:28:15 +0000
commita62abf7bad8d3d50d9c433ac97f1eeca7b9dfcfc (patch)
tree370fba225fa40a40fc7a726e2eba8e983b0abf34 /components/component_updater
parentd49594b5595a26fd0cb5e30a3e0255e74f31a5f5 (diff)
downloadchromium_src-a62abf7bad8d3d50d9c433ac97f1eeca7b9dfcfc.zip
chromium_src-a62abf7bad8d3d50d9c433ac97f1eeca7b9dfcfc.tar.gz
chromium_src-a62abf7bad8d3d50d9c433ac97f1eeca7b9dfcfc.tar.bz2
Reland r318372: Don't check for supervised user whitelist updates until after registering the corresponding component.
Previously, the call to OnDemandUpdate would fail because the component wasn't registered yet, but SupervisedUserWhitelistInstaller didn't check the return value. Now it does, and the unit test checks that OnDemandUpdate isn't called too early. BUG=436459 Review URL: https://codereview.chromium.org/938053002 Review URL: https://codereview.chromium.org/962993002 Cr-Commit-Position: refs/heads/master@{#318474}
Diffstat (limited to 'components/component_updater')
-rw-r--r--components/component_updater/default_component_installer.cc21
-rw-r--r--components/component_updater/default_component_installer.h8
2 files changed, 18 insertions, 11 deletions
diff --git a/components/component_updater/default_component_installer.cc b/components/component_updater/default_component_installer.cc
index 027b1cb..d430863 100644
--- a/components/component_updater/default_component_installer.cc
+++ b/components/component_updater/default_component_installer.cc
@@ -44,7 +44,9 @@ DefaultComponentInstaller::DefaultComponentInstaller(
DefaultComponentInstaller::~DefaultComponentInstaller() {
}
-void DefaultComponentInstaller::Register(ComponentUpdateService* cus) {
+void DefaultComponentInstaller::Register(
+ ComponentUpdateService* cus,
+ const base::Closure& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
task_runner_ = cus->GetSequencedTaskRunner();
@@ -53,10 +55,12 @@ void DefaultComponentInstaller::Register(ComponentUpdateService* cus) {
<< "has no installer traits.";
return;
}
- task_runner_->PostTask(
+ task_runner_->PostTaskAndReply(
FROM_HERE,
base::Bind(&DefaultComponentInstaller::StartRegistration,
- this, cus));
+ this, cus),
+ base::Bind(&DefaultComponentInstaller::FinishRegistration,
+ this, cus, callback));
}
void DefaultComponentInstaller::OnUpdateError(int error) {
@@ -199,11 +203,6 @@ void DefaultComponentInstaller::StartRegistration(ComponentUpdateService* cus) {
// browser startup.
for (const auto& older_path : older_paths)
base::DeleteFile(older_path, true);
-
- main_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&DefaultComponentInstaller::FinishRegistration,
- this, cus));
}
void DefaultComponentInstaller::UninstallOnTaskRunner() {
@@ -239,7 +238,8 @@ base::FilePath DefaultComponentInstaller::GetInstallDirectory() {
}
void DefaultComponentInstaller::FinishRegistration(
- ComponentUpdateService* cus) {
+ ComponentUpdateService* cus,
+ const base::Closure& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
if (installer_traits_->CanAutoUpdate()) {
CrxComponent crx;
@@ -255,6 +255,9 @@ void DefaultComponentInstaller::FinishRegistration(
<< installer_traits_->GetName();
return;
}
+
+ if (!callback.is_null())
+ callback.Run();
}
if (!current_manifest_)
diff --git a/components/component_updater/default_component_installer.h b/components/component_updater/default_component_installer.h
index 5815cd1..1725798 100644
--- a/components/component_updater/default_component_installer.h
+++ b/components/component_updater/default_component_installer.h
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -90,7 +91,9 @@ class DefaultComponentInstaller : public update_client::ComponentInstaller {
scoped_ptr<ComponentInstallerTraits> installer_traits);
// Registers the component for update checks and installs.
- void Register(ComponentUpdateService* cus);
+ // The passed |callback| will be called once the initial check for installed
+ // versions is done and the component has been registered.
+ void Register(ComponentUpdateService* cus, const base::Closure& callback);
// Overridden from ComponentInstaller:
void OnUpdateError(int error) override;
@@ -108,7 +111,8 @@ class DefaultComponentInstaller : public update_client::ComponentInstaller {
const base::FilePath& unpack_path,
const base::FilePath& install_path);
void StartRegistration(ComponentUpdateService* cus);
- void FinishRegistration(ComponentUpdateService* cus);
+ void FinishRegistration(ComponentUpdateService* cus,
+ const base::Closure& callback);
void ComponentReady(scoped_ptr<base::DictionaryValue> manifest);
void UninstallOnTaskRunner();