Commit 5dc5ece2 authored by Makoto Shimazu's avatar Makoto Shimazu Committed by Commit Bot

Use mojo struct for EmbeddedWorkerStartParams

This patch removes [Native] and IPC_STRUCT for EmbeddedWorkerStartParams. In a
following patch, we can move all of params passed to
EmbeddedWorkerInstanceClient::StartWorker() to the
mojom::EmbeddedWorkerStartParams.
This patch is adding a typemap from content.mojom.EmbeddedWorkerStartParams to
content::EmbeddedWorkerStartParams in order to avoid fixing all users of the
params.

Bug: 776263
Change-Id: I7973e49be869b67e86e1a1b6cee7891b17c2f997
Reviewed-on: https://chromium-review.googlesource.com/784732Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Makoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519584}
parent ba884046
......@@ -35,8 +35,11 @@
// IPC messages for testing ---------------------------------------------------
#undef IPC_IPC_MESSAGE_MACROS_H_
#undef IPC_MESSAGE_EXTRA
#define IPC_MESSAGE_IMPL
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_message_templates_impl.h"
#define IPC_MESSAGE_START TestMsgStart
......
......@@ -28,6 +28,9 @@ enum ScrollbarButtonsPlacement;
[Native]
enum ScrollerStyle;
[Native]
enum V8CacheOptions;
[Native]
struct WebPreferences;
......
......@@ -4,20 +4,51 @@
module content.mojom;
import "content/common/native_types.mojom";
import "content/common/service_worker/controller_service_worker.mojom";
import "content/common/service_worker/service_worker_event_dispatcher.mojom";
import "content/common/service_worker/service_worker_installed_scripts_manager.mojom";
import "content/common/service_worker/service_worker_provider.mojom";
import "mojo/common/string16.mojom";
import "mojo/common/time.mojom";
import "mojo/common/unguessable_token.mojom";
import "services/service_manager/public/interfaces/interface_provider.mojom";
import "third_party/WebKit/public/platform/modules/serviceworker/service_worker.mojom";
import "third_party/WebKit/public/web/console_message.mojom";
import "third_party/WebKit/public/web/worker_content_settings_proxy.mojom";
import "url/mojo/url.mojom";
[Native]
struct EmbeddedWorkerStartParams;
// Parameters to launch a service worker. This is passed from the browser to the
// renderer at mojom::EmbeddedWorkerInstanceClient::StartWorker().
struct EmbeddedWorkerStartParams {
// The id of the embedded worker. This changes when the service worker is
// stopped and restarted.
int32 embedded_worker_id;
// The id of the service worker being started. This remains fixed even if the
// worker is stopped and restarted, or even if the browser restarts.
int64 service_worker_version_id;
// This service worker's registration's scope:
// https://w3c.github.io/ServiceWorker/#service-worker-registration-scope
url.mojom.Url scope;
// This service worker's script url:
// https://w3c.github.io/ServiceWorker/#dom-serviceworker-scripturl
url.mojom.Url script_url;
// The id to talk with the DevTools agent for the worker.
int32 worker_devtools_agent_route_id;
// Unique token identifying this worker for DevTools.
mojo.common.mojom.UnguessableToken devtools_worker_token;
// When true, worker script evaluation is blocked until
// EmbeddedWorkerInstanceClient::ResumeAfterDownload() is called.
bool pause_after_download;
// True if starting the worker should wait until DevTools gets ready.
bool wait_for_debugger;
// True if this service worker has been installed.
bool is_installed;
// Determines how eagerly V8 creates the code cache.
V8CacheOptions v8_cache_options;
// True if Data Saver is enabled.
bool data_saver_enabled;
};
// Holds timing information about the start worker sequence for UMA.
struct EmbeddedWorkerStartTiming {
......
......@@ -5,6 +5,8 @@
mojom = "//content/common/service_worker/embedded_worker.mojom"
public_headers =
[ "//content/common/service_worker/embedded_worker_start_params.h" ]
traits_headers =
[ "//content/common/service_worker/embedded_worker_messages.h" ]
traits_headers = [ "//content/common/service_worker/embedded_worker_start_params_struct_traits.h" ]
sources = [
"//content/common/service_worker/embedded_worker_start_params_struct_traits.cc",
]
type_mappings = [ "content.mojom.EmbeddedWorkerStartParams=::content::EmbeddedWorkerStartParams" ]
......@@ -23,25 +23,6 @@
#define IPC_MESSAGE_START EmbeddedWorkerMsgStart
IPC_STRUCT_TRAITS_BEGIN(content::EmbeddedWorkerSettings)
IPC_STRUCT_TRAITS_MEMBER(v8_cache_options)
IPC_STRUCT_TRAITS_MEMBER(data_saver_enabled)
IPC_STRUCT_TRAITS_END()
// Parameters structure for EmbeddedWorkerMsg_StartWorker.
IPC_STRUCT_TRAITS_BEGIN(content::EmbeddedWorkerStartParams)
IPC_STRUCT_TRAITS_MEMBER(embedded_worker_id)
IPC_STRUCT_TRAITS_MEMBER(service_worker_version_id)
IPC_STRUCT_TRAITS_MEMBER(scope)
IPC_STRUCT_TRAITS_MEMBER(script_url)
IPC_STRUCT_TRAITS_MEMBER(worker_devtools_agent_route_id)
IPC_STRUCT_TRAITS_MEMBER(devtools_worker_token)
IPC_STRUCT_TRAITS_MEMBER(pause_after_download)
IPC_STRUCT_TRAITS_MEMBER(wait_for_debugger)
IPC_STRUCT_TRAITS_MEMBER(is_installed)
IPC_STRUCT_TRAITS_MEMBER(settings)
IPC_STRUCT_TRAITS_END()
// Renderer -> Browser message to count an API use. |feature| must be one of the
// values from blink::UseCounter::Feature enum.
IPC_MESSAGE_CONTROL2(EmbeddedWorkerHostMsg_CountFeature,
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/common/service_worker/embedded_worker_start_params_struct_traits.h"
#include "content/public/common/common_param_traits_macros.h"
#include "mojo/common/common_custom_types_struct_traits.h"
#include "url/mojo/url_gurl_struct_traits.h"
namespace mojo {
// static
bool StructTraits<content::mojom::EmbeddedWorkerStartParamsDataView,
content::EmbeddedWorkerStartParams>::
Read(content::mojom::EmbeddedWorkerStartParamsDataView in,
content::EmbeddedWorkerStartParams* out) {
if (!in.ReadScope(&out->scope) || !in.ReadScriptUrl(&out->script_url) ||
!in.ReadDevtoolsWorkerToken(&out->devtools_worker_token) ||
!in.ReadV8CacheOptions(&out->settings.v8_cache_options)) {
return false;
}
out->embedded_worker_id = in.embedded_worker_id();
out->service_worker_version_id = in.service_worker_version_id();
out->worker_devtools_agent_route_id = in.worker_devtools_agent_route_id();
out->pause_after_download = in.pause_after_download();
out->wait_for_debugger = in.wait_for_debugger();
out->is_installed = in.is_installed();
out->settings.data_saver_enabled = in.data_saver_enabled();
return true;
}
} // namespace mojo
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_COMMON_SERVICE_WORKER_EMBEDDED_WORKER_START_PARAMS_STRUCT_TRAITS_H_
#define CONTENT_COMMON_SERVICE_WORKER_EMBEDDED_WORKER_START_PARAMS_STRUCT_TRAITS_H_
#include "content/common/service_worker/embedded_worker.mojom.h"
namespace mojo {
template <>
struct StructTraits<content::mojom::EmbeddedWorkerStartParamsDataView,
content::EmbeddedWorkerStartParams> {
static int embedded_worker_id(
const content::EmbeddedWorkerStartParams& info) {
return info.embedded_worker_id;
}
static int64_t service_worker_version_id(
const content::EmbeddedWorkerStartParams& info) {
return info.service_worker_version_id;
}
static const GURL& scope(const content::EmbeddedWorkerStartParams& info) {
return info.scope;
}
static const GURL& script_url(
const content::EmbeddedWorkerStartParams& info) {
return info.script_url;
}
static int worker_devtools_agent_route_id(
const content::EmbeddedWorkerStartParams& info) {
return info.worker_devtools_agent_route_id;
}
static const base::UnguessableToken& devtools_worker_token(
const content::EmbeddedWorkerStartParams& info) {
return info.devtools_worker_token;
}
static bool pause_after_download(
const content::EmbeddedWorkerStartParams& info) {
return info.pause_after_download;
}
static bool wait_for_debugger(
const content::EmbeddedWorkerStartParams& info) {
return info.wait_for_debugger;
}
static bool is_installed(const content::EmbeddedWorkerStartParams& info) {
return info.is_installed;
}
static content::V8CacheOptions v8_cache_options(
const content::EmbeddedWorkerStartParams& info) {
return info.settings.v8_cache_options;
}
static bool data_saver_enabled(
const content::EmbeddedWorkerStartParams& info) {
return info.settings.data_saver_enabled;
}
static bool Read(content::mojom::EmbeddedWorkerStartParamsDataView in,
content::EmbeddedWorkerStartParams* out);
};
} // namespace mojo
#endif // CONTENT_COMMON_SERVICE_WORKER_EMBEDDED_WORKER_START_PARAMS_STRUCT_TRAITS_H_
......@@ -2,7 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
mojom = "//content/common/renderer.mojom"
mojom = "//content/common/native_types.mojom"
public_headers = [ "//content/public/common/web_preferences.h" ]
traits_headers = [ "//content/public/common/common_param_traits_macros.h" ]
type_mappings = [ "content.mojom.WebPreferences=content::WebPreferences" ]
type_mappings = [
"content.mojom.V8CacheOptions=content::V8CacheOptions",
"content.mojom.WebPreferences=content::WebPreferences",
]
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