chromium/third_party/blink/renderer/modules/service_worker/service_worker_router_type_converter.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/service_worker/service_worker_router_type_converter.h"

#include "services/network/public/mojom/service_worker_router_info.mojom-shared.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/safe_url_pattern.h"
#include "third_party/blink/public/common/service_worker/service_worker_router_rule.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_urlpattern_urlpatterninit_usvstring.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_router_condition.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_router_rule.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_router_source.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_router_source_enum.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_routersource_routersourceenum.h"
#include "third_party/blink/renderer/core/fetch/request_util.h"
#include "third_party/blink/renderer/core/url_pattern/url_pattern.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_utils.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/liburlpattern/parse.h"
#include "third_party/liburlpattern/pattern.h"

namespace blink {

namespace {

std::optional<ServiceWorkerRouterCondition> RouterConditionToBlink(
    v8::Isolate* isolate,
    RouterCondition* v8_condition,
    const KURL& url_pattern_base_url,
    ExceptionState& exception_state);

[[nodiscard]] bool ExceedsMaxConditionDepth(const RouterCondition* v8_condition,
                                            ExceptionState& exception_state,
                                            int depth = 0) {}

std::optional<SafeUrlPattern> RouterUrlPatternConditionToBlink(
    v8::Isolate* isolate,
    const V8URLPatternCompatible* url_pattern_compatible,
    const KURL& url_pattern_base_url,
    ExceptionState& exception_state) {}

std::optional<ServiceWorkerRouterRequestCondition>
RouterRequestConditionToBlink(RouterCondition* v8_condition,
                              ExceptionState& exception_state) {}

std::optional<ServiceWorkerRouterRunningStatusCondition>
RouterRunningStatusConditionToBlink(RouterCondition* v8_condition,
                                    ExceptionState& exception_state) {}

std::optional<ServiceWorkerRouterOrCondition> RouterOrConditionToBlink(
    v8::Isolate* isolate,
    RouterCondition* v8_condition,
    const KURL& url_pattern_base_url,
    ExceptionState& exception_state) {}

std::optional<ServiceWorkerRouterNotCondition> RouterNotConditionToBlink(
    v8::Isolate* isolate,
    RouterCondition* v8_condition,
    const KURL& url_pattern_base_url,
    ExceptionState& exception_state) {}

std::optional<ServiceWorkerRouterCondition> RouterConditionToBlink(
    v8::Isolate* isolate,
    RouterCondition* v8_condition,
    const KURL& url_pattern_base_url,
    ExceptionState& exception_state) {}

std::optional<ServiceWorkerRouterSource> RouterSourceEnumToBlink(
    V8RouterSourceEnum v8_source_enum,
    mojom::blink::ServiceWorkerFetchHandlerType fetch_handler_type,
    ExceptionState& exception_state) {}

std::optional<ServiceWorkerRouterSource> RouterSourceToBlink(
    const RouterSource* v8_source,
    ExceptionState& exception_state) {}

std::optional<ServiceWorkerRouterSource> RouterSourceInputToBlink(
    const V8RouterSourceInput* router_source_input,
    mojom::blink::ServiceWorkerFetchHandlerType fetch_handler_type,
    ExceptionState& exception_state) {}

}  // namespace

std::optional<ServiceWorkerRouterRule> ConvertV8RouterRuleToBlink(
    v8::Isolate* isolate,
    const RouterRule* input,
    const KURL& url_pattern_base_url,
    mojom::blink::ServiceWorkerFetchHandlerType fetch_handler_type,
    ExceptionState& exception_state) {}

}  // namespace blink