Commit 99443748 authored by shimazu's avatar shimazu Committed by Commit bot

ServiceWorker: adding a crash key to check if a new process is launched

This patch is to check if the mismatching EmbeddedWorker was launched on a new
process. If it's true, OnSetHostedVersionId IPC might be reached after
restarting the EmbeddedWorker.

BUG=668633

Review-Url: https://codereview.chromium.org/2627723004
Cr-Commit-Position: refs/heads/master@{#443543}
parent 6422f3b2
...@@ -103,6 +103,8 @@ size_t RegisterEngineCrashKeys() { ...@@ -103,6 +103,8 @@ size_t RegisterEngineCrashKeys() {
// Temporary for https://crbug.com/668633. // Temporary for https://crbug.com/668633.
{ "swdh_set_hosted_version_worker_pid", crash_keys::kSmallSize }, { "swdh_set_hosted_version_worker_pid", crash_keys::kSmallSize },
{ "swdh_set_hosted_version_host_pid", crash_keys::kSmallSize }, { "swdh_set_hosted_version_host_pid", crash_keys::kSmallSize },
{ "swdh_set_hosted_version_is_new_process", crash_keys::kSmallSize },
{ "swdh_set_hosted_version_restart_count", crash_keys::kSmallSize },
}; };
return base::debug::InitCrashKeys(engine_keys, arraysize(engine_keys), return base::debug::InitCrashKeys(engine_keys, arraysize(engine_keys),
......
...@@ -197,6 +197,8 @@ size_t RegisterCrashKeysHelper() { ...@@ -197,6 +197,8 @@ size_t RegisterCrashKeysHelper() {
// Temporary for https://crbug.com/668633. // Temporary for https://crbug.com/668633.
{"swdh_set_hosted_version_worker_pid", crash_keys::kSmallSize}, {"swdh_set_hosted_version_worker_pid", crash_keys::kSmallSize},
{"swdh_set_hosted_version_host_pid", crash_keys::kSmallSize}, {"swdh_set_hosted_version_host_pid", crash_keys::kSmallSize},
{"swdh_set_hosted_version_is_new_process", crash_keys::kSmallSize},
{"swdh_set_hosted_version_restart_count", crash_keys::kSmallSize},
}; };
// This dynamic set of keys is used for sets of key value pairs when gathering // This dynamic set of keys is used for sets of key value pairs when gathering
......
...@@ -250,6 +250,8 @@ size_t RegisterChromeCrashKeys() { ...@@ -250,6 +250,8 @@ size_t RegisterChromeCrashKeys() {
// Temporary for https://crbug.com/668633. // Temporary for https://crbug.com/668633.
{ "swdh_set_hosted_version_worker_pid", crash_keys::kSmallSize }, { "swdh_set_hosted_version_worker_pid", crash_keys::kSmallSize },
{ "swdh_set_hosted_version_host_pid", crash_keys::kSmallSize }, { "swdh_set_hosted_version_host_pid", crash_keys::kSmallSize },
{ "swdh_set_hosted_version_is_new_process", crash_keys::kSmallSize },
{ "swdh_set_hosted_version_restart_count", crash_keys::kSmallSize },
}; };
// This dynamic set of keys is used for sets of key value pairs when gathering // This dynamic set of keys is used for sets of key value pairs when gathering
......
...@@ -108,6 +108,8 @@ size_t RegisterCastCrashKeys() { ...@@ -108,6 +108,8 @@ size_t RegisterCastCrashKeys() {
// Temporary for https://crbug.com/668633. // Temporary for https://crbug.com/668633.
{ "swdh_set_hosted_version_worker_pid", kSmallSize }, { "swdh_set_hosted_version_worker_pid", kSmallSize },
{ "swdh_set_hosted_version_host_pid", kSmallSize }, { "swdh_set_hosted_version_host_pid", kSmallSize },
{ "swdh_set_hosted_version_is_new_process", kSmallSize },
{ "swdh_set_hosted_version_restart_count", kSmallSize },
}; };
return base::debug::InitCrashKeys(fixed_keys, arraysize(fixed_keys), return base::debug::InitCrashKeys(fixed_keys, arraysize(fixed_keys),
......
...@@ -477,6 +477,7 @@ void EmbeddedWorkerInstance::Start( ...@@ -477,6 +477,7 @@ void EmbeddedWorkerInstance::Start(
std::unique_ptr<EmbeddedWorkerStartParams> params, std::unique_ptr<EmbeddedWorkerStartParams> params,
mojom::ServiceWorkerEventDispatcherRequest dispatcher_request, mojom::ServiceWorkerEventDispatcherRequest dispatcher_request,
const StatusCallback& callback) { const StatusCallback& callback) {
restart_count_++;
if (!context_) { if (!context_) {
callback.Run(SERVICE_WORKER_ERROR_ABORT); callback.Run(SERVICE_WORKER_ERROR_ABORT);
// |this| may be destroyed by the callback. // |this| may be destroyed by the callback.
...@@ -597,6 +598,7 @@ EmbeddedWorkerInstance::EmbeddedWorkerInstance( ...@@ -597,6 +598,7 @@ EmbeddedWorkerInstance::EmbeddedWorkerInstance(
embedded_worker_id_(embedded_worker_id), embedded_worker_id_(embedded_worker_id),
status_(EmbeddedWorkerStatus::STOPPED), status_(EmbeddedWorkerStatus::STOPPED),
starting_phase_(NOT_STARTING), starting_phase_(NOT_STARTING),
restart_count_(0),
thread_id_(kInvalidEmbeddedWorkerThreadId), thread_id_(kInvalidEmbeddedWorkerThreadId),
devtools_attached_(false), devtools_attached_(false),
network_accessed_for_script_(false), network_accessed_for_script_(false),
......
...@@ -136,6 +136,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { ...@@ -136,6 +136,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance {
DCHECK_EQ(EmbeddedWorkerStatus::STARTING, status()); DCHECK_EQ(EmbeddedWorkerStatus::STARTING, status());
return starting_phase_; return starting_phase_;
} }
int restart_count() const { return restart_count_; }
int process_id() const; int process_id() const;
int thread_id() const { return thread_id_; } int thread_id() const { return thread_id_; }
// This should be called only when the worker instance has a valid process, // This should be called only when the worker instance has a valid process,
...@@ -296,6 +297,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance { ...@@ -296,6 +297,7 @@ class CONTENT_EXPORT EmbeddedWorkerInstance {
EmbeddedWorkerStatus status_; EmbeddedWorkerStatus status_;
StartingPhase starting_phase_; StartingPhase starting_phase_;
int restart_count_;
// Current running information. // Current running information.
std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_; std::unique_ptr<EmbeddedWorkerInstance::WorkerProcessHandle> process_handle_;
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/browser_side_navigation_policy.h" #include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/origin_util.h" #include "content/public/common/origin_util.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
...@@ -1087,6 +1088,15 @@ void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id, ...@@ -1087,6 +1088,15 @@ void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id,
base::debug::ScopedCrashKey scope_provider_host_pid( base::debug::ScopedCrashKey scope_provider_host_pid(
"swdh_set_hosted_version_host_pid", "swdh_set_hosted_version_host_pid",
base::IntToString(provider_host->process_id())); base::IntToString(provider_host->process_id()));
if (version->embedded_worker()->process_id() !=
ChildProcessHost::kInvalidUniqueID) {
base::debug::ScopedCrashKey scope_is_new_process(
"swdh_set_hosted_version_is_new_process",
version->embedded_worker()->is_new_process() ? "true" : "false");
}
base::debug::ScopedCrashKey scope_worker_restart_count(
"swdh_set_hosted_version_restart_count",
base::IntToString(version->embedded_worker()->restart_count()));
bad_message::ReceivedBadMessage( bad_message::ReceivedBadMessage(
this, bad_message::SWDH_SET_HOSTED_VERSION_PROCESS_MISMATCH); this, bad_message::SWDH_SET_HOSTED_VERSION_PROCESS_MISMATCH);
return; return;
......
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