Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: content/browser/service_worker/embedded_worker_instance.cc

Issue 2637743002: ServiceWorker: remove EmbeddedWorkerMsg_StartWorker (Closed)
Patch Set: Remove SendStartWorker from EWRegistry Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/embedded_worker_instance.cc
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc
index aa9b94f326f4df643ad5fd4c5dab77f60ae4098a..b2237b90afd8aa292d539d9b9301570a55ca05d4 100644
--- a/content/browser/service_worker/embedded_worker_instance.cc
+++ b/content/browser/service_worker/embedded_worker_instance.cc
@@ -103,20 +103,6 @@ void SetupOnUI(
base::Bind(callback, worker_devtools_agent_route_id, wait_for_debugger));
}
-void SetupEventDispatcherOnUIThread(
- int process_id,
- int thread_id,
- mojom::ServiceWorkerEventDispatcherRequest request) {
- DCHECK(!ServiceWorkerUtils::IsMojoForServiceWorkerEnabled());
- RenderProcessHost* rph = RenderProcessHost::FromID(process_id);
- // |rph| or its InterfaceProvider may be NULL in unit tests.
- if (!rph || !rph->GetRemoteInterfaces())
- return;
- mojom::EmbeddedWorkerSetupPtr setup;
- rph->GetRemoteInterfaces()->GetInterface(&setup);
- setup->AttachServiceWorkerEventDispatcher(thread_id, std::move(request));
-}
-
void CallDetach(EmbeddedWorkerInstance* instance) {
// This could be called on the UI thread if |client_| still be valid when the
// message loop on the UI thread gets destructed.
@@ -401,35 +387,12 @@ class EmbeddedWorkerInstance::StartTask {
params->worker_devtools_agent_route_id = worker_devtools_agent_route_id;
params->wait_for_debugger = wait_for_debugger;
- if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled())
- SendMojoStartWorker(std::move(params));
- else
- SendStartWorker(std::move(params));
+ SendStartWorker(std::move(params));
falken 2017/01/16 05:07:45 Can we collapse SendStartWorker into this function
shimazu 2017/01/16 05:49:53 Done.
}
void SendStartWorker(std::unique_ptr<EmbeddedWorkerStartParams> params) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- ServiceWorkerStatusCode status = instance_->registry_->SendStartWorker(
- std::move(params), instance_->process_id());
- TRACE_EVENT_ASYNC_STEP_PAST1(
- "ServiceWorker", "EmbeddedWorkerInstance::Start", this,
- "SendStartWorker", "Status", ServiceWorkerStatusToString(status));
- if (status != SERVICE_WORKER_OK) {
- StatusCallback callback = start_callback_;
- start_callback_.Reset();
- instance_->OnStartFailed(callback, status);
- // |this| may be destroyed.
- return;
- }
- instance_->OnStartWorkerMessageSent();
-
- // |start_callback_| will be called via RunStartCallback() when the script
- // is evaluated.
- }
-
- void SendMojoStartWorker(std::unique_ptr<EmbeddedWorkerStartParams> params) {
ServiceWorkerStatusCode status =
- instance_->SendMojoStartWorker(std::move(params));
+ instance_->SendStartWorker(std::move(params));
if (status != SERVICE_WORKER_OK) {
StatusCallback callback = start_callback_;
start_callback_.Reset();
@@ -500,11 +463,9 @@ void EmbeddedWorkerInstance::Start(
params->settings.v8_cache_options = GetV8CacheOptions();
mojom::EmbeddedWorkerInstanceClientRequest request;
- if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) {
- request = mojo::MakeRequest(&client_);
- client_.set_connection_error_handler(
- base::Bind(&CallDetach, base::Unretained(this)));
- }
+ request = mojo::MakeRequest(&client_);
falken 2017/01/16 05:07:45 Can we initialize request in line 465?
shimazu 2017/01/16 05:49:53 Yes, that's right. Done.
+ client_.set_connection_error_handler(
+ base::Bind(&CallDetach, base::Unretained(this)));
pending_dispatcher_request_ = std::move(dispatcher_request);
@@ -635,7 +596,7 @@ void EmbeddedWorkerInstance::OnRegisteredToDevToolsManager(
observer.OnRegisteredToDevToolsManager();
}
-ServiceWorkerStatusCode EmbeddedWorkerInstance::SendMojoStartWorker(
+ServiceWorkerStatusCode EmbeddedWorkerInstance::SendStartWorker(
std::unique_ptr<EmbeddedWorkerStartParams> params) {
if (!context_)
return SERVICE_WORKER_ERROR_ABORT;
@@ -743,16 +704,6 @@ void EmbeddedWorkerInstance::OnThreadStarted(int thread_id) {
thread_id_ = thread_id;
for (auto& observer : listener_list_)
observer.OnThreadStarted();
-
- // The pending request is sent at StartWorker if mojo for the service worker
- // is enabled.
- if (!ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) {
- DCHECK(pending_dispatcher_request_.is_pending());
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(SetupEventDispatcherOnUIThread, process_id(), thread_id_,
- base::Passed(&pending_dispatcher_request_)));
- }
}
void EmbeddedWorkerInstance::OnScriptLoadFailed() {

Powered by Google App Engine
This is Rietveld 408576698