feat: ServiceWorkerMain (#45232)

* feat: ServiceWorkerMain

* refactor: disconnect remote

* handle version_info_ nullptr case

* initiate finish request when possible and enumerate errors

* explicit name for test method

* oops

* fix: wait for redundant version to stop before destroying

* docs: clarify when undefined is returned

* chore: remove extra semicolons
This commit is contained in:
Sam Maddock 2025-01-24 08:33:44 -05:00 committed by GitHub
parent 75eac86506
commit a467d0684e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 1265 additions and 50 deletions

View file

@ -0,0 +1,25 @@
// Copyright (c) 2025 Salesforce, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/gin_converters/service_worker_converter.h"
#include "base/containers/fixed_flat_map.h"
namespace gin {
// static
v8::Local<v8::Value> Converter<blink::EmbeddedWorkerStatus>::ToV8(
v8::Isolate* isolate,
const blink::EmbeddedWorkerStatus& val) {
static constexpr auto Lookup =
base::MakeFixedFlatMap<blink::EmbeddedWorkerStatus, std::string_view>({
{blink::EmbeddedWorkerStatus::kStarting, "starting"},
{blink::EmbeddedWorkerStatus::kRunning, "running"},
{blink::EmbeddedWorkerStatus::kStopping, "stopping"},
{blink::EmbeddedWorkerStatus::kStopped, "stopped"},
});
return StringToV8(isolate, Lookup.at(val));
}
} // namespace gin

View file

@ -0,0 +1,21 @@
// Copyright (c) 2025 Salesforce, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_SERVICE_WORKER_CONVERTER_H_
#define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_SERVICE_WORKER_CONVERTER_H_
#include "gin/converter.h"
#include "third_party/blink/public/common/service_worker/embedded_worker_status.h"
namespace gin {
template <>
struct Converter<blink::EmbeddedWorkerStatus> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const blink::EmbeddedWorkerStatus& val);
};
} // namespace gin
#endif // ELECTRON_SHELL_COMMON_GIN_CONVERTERS_SERVICE_WORKER_CONVERTER_H_