summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwaffles@chromium.org <waffles@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-02 04:13:14 +0000
committerwaffles@chromium.org <waffles@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-02 04:13:14 +0000
commit87da10b361831245690ba88458645c1a076fd657 (patch)
tree2a24c6e388911843b2ec3dc4b28e314e0154dc4d
parent06b311c12438756904446e8ba09132460fbad557 (diff)
downloadchromium_src-87da10b361831245690ba88458645c1a076fd657.zip
chromium_src-87da10b361831245690ba88458645c1a076fd657.tar.gz
chromium_src-87da10b361831245690ba88458645c1a076fd657.tar.bz2
Threading clean-up for component updater differential update.
This cleans up a threading model oversight - methods in the differential update operation should only ever be called on the SequencedTaskRunner, never on the IO thread itself. BUG=304879 Review URL: https://codereview.chromium.org/221343002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261062 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/component_updater/component_patcher_operation.cc34
-rw-r--r--chrome/browser/component_updater/component_patcher_operation.h6
2 files changed, 33 insertions, 7 deletions
diff --git a/chrome/browser/component_updater/component_patcher_operation.cc b/chrome/browser/component_updater/component_patcher_operation.cc
index d9fb069..96c27c4 100644
--- a/chrome/browser/component_updater/component_patcher_operation.cc
+++ b/chrome/browser/component_updater/component_patcher_operation.cc
@@ -228,6 +228,10 @@ bool DeltaUpdateOp::InProcess() {
return in_process_;
}
+scoped_refptr<base::SequencedTaskRunner> DeltaUpdateOp::GetTaskRunner() {
+ return task_runner_;
+}
+
DeltaUpdateOpCopy::DeltaUpdateOpCopy() {}
DeltaUpdateOpCopy::~DeltaUpdateOpCopy() {}
@@ -279,7 +283,9 @@ void DeltaUpdateOpCreate::DoRun(const ComponentUnpacker::Callback& callback) {
}
DeltaUpdateOpPatchHost::DeltaUpdateOpPatchHost(
- scoped_refptr<DeltaUpdateOpPatch> patcher) : patcher_(patcher) {
+ scoped_refptr<DeltaUpdateOpPatch> patcher,
+ scoped_refptr<base::SequencedTaskRunner> task_runner)
+ : patcher_(patcher), task_runner_(task_runner) {
}
DeltaUpdateOpPatchHost::~DeltaUpdateOpPatchHost() {
@@ -307,18 +313,33 @@ bool DeltaUpdateOpPatchHost::OnMessageReceived(const IPC::Message& message) {
}
void DeltaUpdateOpPatchHost::OnPatchSucceeded() {
- patcher_->DonePatching(ComponentUnpacker::kNone, 0);
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&DeltaUpdateOpPatch::DonePatching,
+ patcher_,
+ ComponentUnpacker::kNone,
+ 0));
+ task_runner_ = NULL;
patcher_ = NULL;
}
void DeltaUpdateOpPatchHost::OnPatchFailed(int error_code) {
- patcher_->DonePatching(ComponentUnpacker::kDeltaOperationFailure, error_code);
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&DeltaUpdateOpPatch::DonePatching,
+ patcher_,
+ ComponentUnpacker::kDeltaOperationFailure,
+ error_code));
+ task_runner_ = NULL;
patcher_ = NULL;
}
void DeltaUpdateOpPatchHost::OnProcessCrashed(int exit_code) {
- patcher_->DonePatching(ComponentUnpacker::kDeltaPatchProcessFailure,
- exit_code);
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&DeltaUpdateOpPatch::DonePatching,
+ patcher_,
+ ComponentUnpacker::kDeltaPatchProcessFailure,
+ exit_code));
+ task_runner_ = NULL;
patcher_ = NULL;
}
@@ -352,7 +373,8 @@ ComponentUnpacker::Error DeltaUpdateOpPatch::DoParseArguments(
void DeltaUpdateOpPatch::DoRun(const ComponentUnpacker::Callback& callback) {
callback_ = callback;
if (!InProcess()) {
- host_ = new DeltaUpdateOpPatchHost(scoped_refptr<DeltaUpdateOpPatch>(this));
+ host_ = new DeltaUpdateOpPatchHost(scoped_refptr<DeltaUpdateOpPatch>(this),
+ GetTaskRunner());
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
diff --git a/chrome/browser/component_updater/component_patcher_operation.h b/chrome/browser/component_updater/component_patcher_operation.h
index 91c3a16..6475c33 100644
--- a/chrome/browser/component_updater/component_patcher_operation.h
+++ b/chrome/browser/component_updater/component_patcher_operation.h
@@ -43,6 +43,8 @@ class DeltaUpdateOp : public base::RefCountedThreadSafe<DeltaUpdateOp> {
bool InProcess();
+ scoped_refptr<base::SequencedTaskRunner> GetTaskRunner();
+
std::string output_sha256_;
base::FilePath output_abs_path_;
@@ -151,7 +153,8 @@ class DeltaUpdateOpPatch;
class DeltaUpdateOpPatchHost : public content::UtilityProcessHostClient {
public:
- explicit DeltaUpdateOpPatchHost(scoped_refptr<DeltaUpdateOpPatch> patcher);
+ DeltaUpdateOpPatchHost(scoped_refptr<DeltaUpdateOpPatch> patcher,
+ scoped_refptr<base::SequencedTaskRunner> task_runner);
void StartProcess(scoped_ptr<IPC::Message> message);
@@ -168,6 +171,7 @@ class DeltaUpdateOpPatchHost : public content::UtilityProcessHostClient {
virtual void OnProcessCrashed(int exit_code) OVERRIDE;
scoped_refptr<DeltaUpdateOpPatch> patcher_;
+ scoped_refptr<base::SequencedTaskRunner> task_runner_;
};
// Both 'bsdiff' and 'courgette' operations take an existing file on disk,