Commit ab84faea authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

SequenceBound: migrate from Post() to AsyncCall() in media classes.

Bug: 1140588
Change-Id: I2c55eeae2125a4c4dea4683a2a017723c3f14e22
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2488320Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820173}
parent e063f324
......@@ -454,8 +454,10 @@ void CdmFileImpl::Read(ReadCallback callback) {
// |this|, and if |this| is destructed it will destroy the file reader on the
// IO thread.
file_reader_ = base::SequenceBound<FileReader>(GetIOThreadTaskRunner({}));
file_reader_.Post(FROM_HERE, &FileReader::Read, file_system_context_,
CreateFileSystemURL(file_name_), std::move(read_done_cb));
// TODO(dcheng): Migrate this to use Then()?
file_reader_.AsyncCall(&FileReader::Read)
.WithArgs(file_system_context_, CreateFileSystemURL(file_name_),
std::move(read_done_cb));
}
void CdmFileImpl::ReadDone(bool success, std::vector<uint8_t> data) {
......@@ -601,9 +603,10 @@ void CdmFileImpl::OnTempFileIsEmpty(scoped_refptr<net::IOBuffer> buffer,
// base::Unretained() is OK as |file_writer_| is owned by |this|, and if
// |this| is destructed it will destroy |file_writer_| on the IO thread.
file_writer_ = base::SequenceBound<FileWriter>(GetIOThreadTaskRunner({}));
file_writer_.Post(FROM_HERE, &FileWriter::Write, file_system_context_,
CreateFileSystemURL(temp_file_name_), std::move(buffer),
bytes_to_write, std::move(write_done_cb));
// TODO(dcheng): Migrate this to use Then()?
file_writer_.AsyncCall(&FileWriter::Write)
.WithArgs(file_system_context_, CreateFileSystemURL(temp_file_name_),
std::move(buffer), bytes_to_write, std::move(write_done_cb));
}
void CdmFileImpl::WriteDone(bool success) {
......
......@@ -37,12 +37,11 @@ class WeakLearningTaskController : public LearningTaskController {
for (auto& id : outstanding_observations_) {
const base::Optional<TargetValue>& default_value = id.second;
if (default_value) {
controller_->Post(FROM_HERE,
&LearningTaskController::CompleteObservation,
id.first, *default_value);
controller_->AsyncCall(&LearningTaskController::CompleteObservation)
.WithArgs(id.first, *default_value);
} else {
controller_->Post(FROM_HERE, &LearningTaskController::CancelObservation,
id.first);
controller_->AsyncCall(&LearningTaskController::CancelObservation)
.WithArgs(id.first);
}
}
}
......@@ -59,8 +58,8 @@ class WeakLearningTaskController : public LearningTaskController {
// We don't send along the default value because LearningTaskControllerImpl
// doesn't support it. Since all client calls eventually come through us
// anyway, it seems okay to handle it here.
controller_->Post(FROM_HERE, &LearningTaskController::BeginObservation, id,
features, base::nullopt, source_id);
controller_->AsyncCall(&LearningTaskController::BeginObservation)
.WithArgs(id, features, base::nullopt, source_id);
}
void CompleteObservation(base::UnguessableToken id,
......@@ -68,16 +67,16 @@ class WeakLearningTaskController : public LearningTaskController {
if (!weak_session_)
return;
outstanding_observations_.erase(id);
controller_->Post(FROM_HERE, &LearningTaskController::CompleteObservation,
id, completion);
controller_->AsyncCall(&LearningTaskController::CompleteObservation)
.WithArgs(id, completion);
}
void CancelObservation(base::UnguessableToken id) override {
if (!weak_session_)
return;
outstanding_observations_.erase(id);
controller_->Post(FROM_HERE, &LearningTaskController::CancelObservation,
id);
controller_->AsyncCall(&LearningTaskController::CancelObservation)
.WithArgs(id);
}
void UpdateDefaultTarget(
......@@ -93,8 +92,8 @@ class WeakLearningTaskController : public LearningTaskController {
void PredictDistribution(const FeatureVector& features,
PredictionCB callback) override {
controller_->Post(FROM_HERE, &LearningTaskController::PredictDistribution,
features, std::move(callback));
controller_->AsyncCall(&LearningTaskController::PredictDistribution)
.WithArgs(features, std::move(callback));
}
base::WeakPtr<LearningSessionImpl> weak_session_;
......
......@@ -34,9 +34,8 @@ class LearningSessionImplTest : public testing::Test {
// As a complete hack, call the only public method on fp so that
// we can verify that it was given to us by the session.
if (!feature_provider_.is_null()) {
feature_provider_.Post(FROM_HERE, &FeatureProvider::AddFeatures,
FeatureVector(),
FeatureProvider::FeatureVectorCB());
feature_provider_.AsyncCall(&FeatureProvider::AddFeatures)
.WithArgs(FeatureVector(), FeatureProvider::FeatureVectorCB());
}
}
......
......@@ -35,10 +35,12 @@ void LearningTaskControllerHelper::BeginObservation(
// Start feature prediction, so that we capture the current values.
if (!feature_provider_.is_null()) {
feature_provider_.Post(
FROM_HERE, &FeatureProvider::AddFeatures, std::move(features),
base::BindOnce(&LearningTaskControllerHelper::OnFeaturesReadyTrampoline,
task_runner_, AsWeakPtr(), id));
// TODO(dcheng): Convert this to use Then() helper.
feature_provider_.AsyncCall(&FeatureProvider::AddFeatures)
.WithArgs(std::move(features),
base::BindOnce(
&LearningTaskControllerHelper::OnFeaturesReadyTrampoline,
task_runner_, AsWeakPtr(), id));
} else {
pending_example.example.features = std::move(features);
pending_example.features_done = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment