Use a per-frame task runner at WebApplicationCacheHostImpl's mojo binding
This CL switches task runners at several places from per-thread to per-frame. The purpose of this change is to make it possible to freeze tasks for bfcache. The actual test that executes JavaScript on the task runner is: virtual/cors-rfc1918/http/tests/security/cors-rfc1918/addressspace-document-appcache.https.html As a task type, kNetworking is adopted based on the spec: https://html.spec.whatwg.org/multipage/offline.html BUG=913912 Change-Id: I353b97a87d5a1083cc56bf7706dd111ccc150a41 Reviewed-on: https://chromium-review.googlesource.com/c/1482275 Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Alexander Timin <altimin@chromium.org> Cr-Commit-Position: refs/heads/master@{#635390}
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
#include "content/common/appcache_interfaces.h"
|
||||
#include "content/public/common/service_names.mojom.h"
|
||||
#include "content/public/renderer/render_thread.h"
|
||||
#include "content/renderer/render_frame_impl.h"
|
||||
#include "mojo/public/cpp/bindings/interface_request.h"
|
||||
#include "services/service_manager/public/cpp/connector.h"
|
||||
#include "third_party/blink/public/mojom/appcache/appcache.mojom.h"
|
||||
@ -65,7 +66,8 @@ WebApplicationCacheHostImpl* WebApplicationCacheHostImpl::FromId(int id) {
|
||||
WebApplicationCacheHostImpl::WebApplicationCacheHostImpl(
|
||||
WebApplicationCacheHostClient* client,
|
||||
int appcache_host_id,
|
||||
int render_frame_id)
|
||||
int render_frame_id,
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
|
||||
: binding_(this),
|
||||
client_(client),
|
||||
status_(blink::mojom::AppCacheStatus::APPCACHE_STATUS_UNCACHED),
|
||||
@ -93,9 +95,10 @@ WebApplicationCacheHostImpl::WebApplicationCacheHostImpl(
|
||||
backend_ = backend_ptr->get();
|
||||
|
||||
blink::mojom::AppCacheFrontendPtr frontend_ptr;
|
||||
binding_.Bind(mojo::MakeRequest(&frontend_ptr));
|
||||
backend_->RegisterHost(mojo::MakeRequest(&backend_host_),
|
||||
std::move(frontend_ptr), host_id_, render_frame_id);
|
||||
binding_.Bind(mojo::MakeRequest(&frontend_ptr, task_runner), task_runner);
|
||||
backend_->RegisterHost(
|
||||
mojo::MakeRequest(&backend_host_, std::move(task_runner)),
|
||||
std::move(frontend_ptr), host_id_, render_frame_id);
|
||||
}
|
||||
|
||||
WebApplicationCacheHostImpl::~WebApplicationCacheHostImpl() {
|
||||
|
@ -25,9 +25,11 @@ class WebApplicationCacheHostImpl : public blink::WebApplicationCacheHost,
|
||||
// Returns the host having given id or NULL if there is no such host.
|
||||
static WebApplicationCacheHostImpl* FromId(int id);
|
||||
|
||||
WebApplicationCacheHostImpl(blink::WebApplicationCacheHostClient* client,
|
||||
int appcache_host_id,
|
||||
int render_frame_id);
|
||||
WebApplicationCacheHostImpl(
|
||||
blink::WebApplicationCacheHostClient* client,
|
||||
int appcache_host_id,
|
||||
int render_frame_id,
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
|
||||
~WebApplicationCacheHostImpl() override;
|
||||
|
||||
int host_id() const { return host_id_; }
|
||||
|
@ -3952,9 +3952,13 @@ RenderFrameImpl::CreateApplicationCacheHost(
|
||||
? frame_->GetProvisionalDocumentLoader()
|
||||
: frame_->GetDocumentLoader());
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
|
||||
frame_->GetTaskRunner(blink::TaskType::kNetworking);
|
||||
|
||||
return std::make_unique<RendererWebApplicationCacheHostImpl>(
|
||||
RenderViewImpl::FromWebView(frame_->View()), client,
|
||||
navigation_state->commit_params().appcache_host_id, routing_id_);
|
||||
navigation_state->commit_params().appcache_host_id, routing_id_,
|
||||
std::move(task_runner));
|
||||
}
|
||||
|
||||
std::unique_ptr<blink::WebContentSettingsClient>
|
||||
|
@ -24,10 +24,12 @@ RendererWebApplicationCacheHostImpl::RendererWebApplicationCacheHostImpl(
|
||||
RenderViewImpl* render_view,
|
||||
WebApplicationCacheHostClient* client,
|
||||
int appcache_host_id,
|
||||
int frame_routing_id)
|
||||
int frame_routing_id,
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
|
||||
: WebApplicationCacheHostImpl(client,
|
||||
appcache_host_id,
|
||||
frame_routing_id),
|
||||
frame_routing_id,
|
||||
std::move(task_runner)),
|
||||
routing_id_(render_view->GetRoutingID()),
|
||||
frame_routing_id_(frame_routing_id) {}
|
||||
|
||||
|
@ -20,7 +20,8 @@ class RendererWebApplicationCacheHostImpl : public WebApplicationCacheHostImpl {
|
||||
RenderViewImpl* render_view,
|
||||
blink::WebApplicationCacheHostClient* client,
|
||||
int appcache_host_id,
|
||||
int frame_routing_id);
|
||||
int frame_routing_id,
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
|
||||
|
||||
// blink::mojom::AppCacheHostFrontend:
|
||||
void LogMessage(blink::mojom::ConsoleMessageLevel log_level,
|
||||
|
@ -54,10 +54,12 @@ class SharedWorkerWebApplicationCacheHostImpl
|
||||
public:
|
||||
SharedWorkerWebApplicationCacheHostImpl(
|
||||
blink::WebApplicationCacheHostClient* client,
|
||||
int appcache_host_id)
|
||||
int appcache_host_id,
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
|
||||
: WebApplicationCacheHostImpl(client,
|
||||
appcache_host_id,
|
||||
MSG_ROUTING_NONE) {}
|
||||
MSG_ROUTING_NONE,
|
||||
std::move(task_runner)) {}
|
||||
|
||||
// Main resource loading is different for workers. The main resource is
|
||||
// loaded by the worker using WorkerClassicScriptLoader.
|
||||
@ -247,7 +249,8 @@ EmbeddedSharedWorkerStub::CreateApplicationCacheHost(
|
||||
blink::WebApplicationCacheHostClient* client) {
|
||||
std::unique_ptr<WebApplicationCacheHostImpl> host =
|
||||
std::make_unique<SharedWorkerWebApplicationCacheHostImpl>(
|
||||
client, appcache_host_id_);
|
||||
client, appcache_host_id_,
|
||||
impl_->GetTaskRunner(blink::TaskType::kNetworking));
|
||||
app_cache_host_ = host.get();
|
||||
return std::move(host);
|
||||
}
|
||||
|
Reference in New Issue
Block a user