Commit 67969167 authored by Mikhail Atuchin's avatar Mikhail Atuchin Committed by Commit Bot

[extensions] Fix using the wrong thread id after SW restarting

If SW was restarted and the same process could be used.
Update UIThreadWorkerResponseCallbackWrapper to not store worker_thread_id in it
and instead use the correct worker_thread_id per callback returned via CreateCallback.

Change-Id: I5caead02f2d45fbac967b9e5d42e0e1ef5d970fc
Bug: 1019677
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879258
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Auto-Submit: Mikhail Atuchin <atuchin@yandex-team.ru>
Cr-Commit-Position: refs/heads/master@{#711155}
parent 54b0f2f9
...@@ -157,8 +157,7 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper ...@@ -157,8 +157,7 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper
int worker_thread_id) int worker_thread_id)
: dispatcher_(dispatcher), : dispatcher_(dispatcher),
observer_(this), observer_(this),
render_process_host_(render_process_host), render_process_host_(render_process_host) {
worker_thread_id_(worker_thread_id) {
observer_.Add(render_process_host_); observer_.Add(render_process_host_);
DCHECK(ExtensionsClient::Get() DCHECK(ExtensionsClient::Get()
...@@ -179,10 +178,11 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper ...@@ -179,10 +178,11 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper
CleanUp(); CleanUp();
} }
ExtensionFunction::ResponseCallback CreateCallback(int request_id) { ExtensionFunction::ResponseCallback CreateCallback(int request_id,
int worker_thread_id) {
return base::Bind( return base::Bind(
&UIThreadWorkerResponseCallbackWrapper::OnExtensionFunctionCompleted, &UIThreadWorkerResponseCallbackWrapper::OnExtensionFunctionCompleted,
weak_ptr_factory_.GetWeakPtr(), request_id); weak_ptr_factory_.GetWeakPtr(), request_id, worker_thread_id);
} }
private: private:
...@@ -196,6 +196,7 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper ...@@ -196,6 +196,7 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper
} }
void OnExtensionFunctionCompleted(int request_id, void OnExtensionFunctionCompleted(int request_id,
int worker_thread_id,
ExtensionFunction::ResponseType type, ExtensionFunction::ResponseType type,
const base::ListValue& results, const base::ListValue& results,
const std::string& error) { const std::string& error) {
...@@ -204,7 +205,7 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper ...@@ -204,7 +205,7 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper
return; return;
} }
render_process_host_->Send(new ExtensionMsg_ResponseWorker( render_process_host_->Send(new ExtensionMsg_ResponseWorker(
worker_thread_id_, request_id, type == ExtensionFunction::SUCCEEDED, worker_thread_id, request_id, type == ExtensionFunction::SUCCEEDED,
results, error)); results, error));
} }
...@@ -212,7 +213,6 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper ...@@ -212,7 +213,6 @@ class ExtensionFunctionDispatcher::UIThreadWorkerResponseCallbackWrapper
ScopedObserver<content::RenderProcessHost, content::RenderProcessHostObserver> ScopedObserver<content::RenderProcessHost, content::RenderProcessHostObserver>
observer_{this}; observer_{this};
content::RenderProcessHost* const render_process_host_; content::RenderProcessHost* const render_process_host_;
const int worker_thread_id_;
base::WeakPtrFactory<UIThreadWorkerResponseCallbackWrapper> weak_ptr_factory_{ base::WeakPtrFactory<UIThreadWorkerResponseCallbackWrapper> weak_ptr_factory_{
this}; this};
...@@ -317,7 +317,8 @@ void ExtensionFunctionDispatcher::Dispatch( ...@@ -317,7 +317,8 @@ void ExtensionFunctionDispatcher::Dispatch(
} }
DispatchWithCallbackInternal( DispatchWithCallbackInternal(
params, nullptr, render_process_id, params, nullptr, render_process_id,
callback_wrapper->CreateCallback(params.request_id)); callback_wrapper->CreateCallback(params.request_id,
params.worker_thread_id));
} }
} }
......
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