Commit e812caf0 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Make UserMediaClient::Request heap allocated

... instead of stack allocated.

This is a precusor CL for making use of ApplyConstraintsRequest directly
in user_media_client.cc|h and apply_constraints_processor.cc|h, instead
of its Blink-exposed wrapper class, WebApplyConstraintsRequest.

This is needed because ApplyConstraintsRequest is GC-ed by OilPan, so
being UserMediaClient::Request the class that will own it, it needs to be
(Oilpan) heap allocated.

In a follow up step [1], it was changed to on-Oilpan-heap allocation.

[1] https://crrev.com/c/1768778

BUG=704136
R=guidou@chromium.org, haraken@chromium.org

Change-Id: I7b3965d892f99a93d12d65ffee3140f08caafbd1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768789
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Auto-Submit: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#690313}
parent a3ccbc29
......@@ -187,7 +187,8 @@ void UserMediaClient::RequestUserMedia(
std::unique_ptr<UserMediaRequestInfo> request_info =
std::make_unique<UserMediaRequestInfo>(request_id, web_request,
user_gesture);
pending_request_infos_.push_back(Request(std::move(request_info)));
pending_request_infos_.push_back(
std::make_unique<Request>(std::move(request_info)));
if (!is_processing_request_)
MaybeProcessNextRequestInfo();
}
......@@ -196,13 +197,13 @@ void UserMediaClient::ApplyConstraints(
const blink::WebApplyConstraintsRequest& web_request) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
pending_request_infos_.push_back(Request(web_request));
pending_request_infos_.push_back(std::make_unique<Request>(web_request));
if (!is_processing_request_)
MaybeProcessNextRequestInfo();
}
void UserMediaClient::StopTrack(const blink::WebMediaStreamTrack& web_track) {
pending_request_infos_.push_back(Request(web_track));
pending_request_infos_.push_back(std::make_unique<Request>(web_track));
if (!is_processing_request_)
MaybeProcessNextRequestInfo();
}
......@@ -216,25 +217,25 @@ void UserMediaClient::MaybeProcessNextRequestInfo() {
if (is_processing_request_ || pending_request_infos_.empty())
return;
Request current_request = std::move(pending_request_infos_.front());
auto current_request = std::move(pending_request_infos_.front());
pending_request_infos_.pop_front();
is_processing_request_ = true;
if (current_request.IsUserMedia()) {
if (current_request->IsUserMedia()) {
user_media_processor_->ProcessRequest(
current_request.MoveUserMediaRequest(),
current_request->MoveUserMediaRequest(),
WTF::Bind(&UserMediaClient::CurrentRequestCompleted,
WrapWeakPersistent(this)));
} else if (current_request.IsApplyConstraints()) {
} else if (current_request->IsApplyConstraints()) {
apply_constraints_processor_->ProcessRequest(
current_request.apply_constraints_request(),
current_request->apply_constraints_request(),
WTF::Bind(&UserMediaClient::CurrentRequestCompleted,
WrapWeakPersistent(this)));
} else {
DCHECK(current_request.IsStopTrack());
DCHECK(current_request->IsStopTrack());
blink::WebPlatformMediaStreamTrack* track =
blink::WebPlatformMediaStreamTrack::GetTrack(
current_request.web_track_to_stop());
current_request->web_track_to_stop());
if (track) {
track->StopAndNotify(WTF::Bind(&UserMediaClient::CurrentRequestCompleted,
WrapWeakPersistent(this)));
......@@ -273,8 +274,8 @@ void UserMediaClient::CancelUserMediaRequest(
} else {
for (auto it = pending_request_infos_.begin();
it != pending_request_infos_.end(); ++it) {
if (it->IsUserMedia() &&
it->user_media_request()->web_request == web_request) {
if ((*it)->IsUserMedia() &&
(*it)->user_media_request()->web_request == web_request) {
pending_request_infos_.erase(it);
did_remove_request = true;
break;
......
......@@ -91,6 +91,8 @@ class MODULES_EXPORT UserMediaClient
std::unique_ptr<UserMediaRequestInfo> user_media_request_;
blink::WebApplyConstraintsRequest apply_constraints_request_;
blink::WebMediaStreamTrack web_track_to_stop_;
DISALLOW_COPY_AND_ASSIGN(Request);
};
void MaybeProcessNextRequestInfo();
......@@ -119,7 +121,7 @@ class MODULES_EXPORT UserMediaClient
// and |pending_request_infos_| is a list of queued requests.
bool is_processing_request_ = false;
Deque<Request> pending_request_infos_;
Deque<std::unique_ptr<Request>> pending_request_infos_;
THREAD_CHECKER(thread_checker_);
......
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