Commit 4f0a6d01 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Worker: Move ClientImpl to worklet_module_responses_map_test.cc for cleanup

ClientImpl is only used from WorkletModuleResponsesMapTest. Originally
this was in the anonymous namespace in worklet_module_responses_map_test.cc, but
it was moved out because of Jumbo build breakage (see
https://crrev.com/c/968363/).

Bug: n/a
Change-Id: If39397b7320af6228591f61dfad1acb511faf961
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1874991Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708517}
parent 283a0491
......@@ -1589,7 +1589,6 @@ jumbo_source_set("unit_tests") {
"workers/dedicated_worker_test.cc",
"workers/main_thread_worklet_test.cc",
"workers/threaded_worklet_test.cc",
"workers/worker_fetch_test_helper.h",
"workers/worker_thread_test.cc",
"workers/worker_thread_test_helper.h",
"workers/worklet_module_responses_map_test.cc",
......
// Copyright 2018 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 THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKER_FETCH_TEST_HELPER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKER_FETCH_TEST_HELPER_H_
#include "base/optional.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/testing/fetch_testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
namespace blink {
class ClientImpl final : public GarbageCollected<ClientImpl>,
public ModuleScriptFetcher::Client {
USING_GARBAGE_COLLECTED_MIXIN(ClientImpl);
public:
enum class Result { kInitial, kOK, kFailed };
void NotifyFetchFinished(
const base::Optional<ModuleScriptCreationParams>& params,
const HeapVector<Member<ConsoleMessage>>&) override {
ASSERT_EQ(Result::kInitial, result_);
if (params) {
result_ = Result::kOK;
params_.emplace(*params);
} else {
result_ = Result::kFailed;
}
}
Result GetResult() const { return result_; }
base::Optional<ModuleScriptCreationParams> GetParams() const {
return params_;
}
private:
Result result_ = Result::kInitial;
base::Optional<ModuleScriptCreationParams> params_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_WORKERS_WORKER_FETCH_TEST_HELPER_H_
......@@ -3,13 +3,13 @@
// found in the LICENSE file.
#include "third_party/blink/renderer/core/workers/worklet_module_responses_map.h"
#include "base/optional.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/web_url_loader_mock_factory.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h"
#include "third_party/blink/renderer/core/loader/modulescript/worklet_module_script_fetcher.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/core/workers/worker_fetch_test_helper.h"
#include "third_party/blink/renderer/platform/loader/testing/fetch_testing_platform_support.h"
#include "third_party/blink/renderer/platform/loader/testing/mock_fetch_context.h"
#include "third_party/blink/renderer/platform/loader/testing/test_loader_factory.h"
......@@ -35,6 +35,35 @@ class WorkletModuleResponsesMapTest : public testing::Test {
map_ = MakeGarbageCollected<WorkletModuleResponsesMap>();
}
class ClientImpl final : public GarbageCollected<ClientImpl>,
public ModuleScriptFetcher::Client {
USING_GARBAGE_COLLECTED_MIXIN(ClientImpl);
public:
enum class Result { kInitial, kOK, kFailed };
void NotifyFetchFinished(
const base::Optional<ModuleScriptCreationParams>& params,
const HeapVector<Member<ConsoleMessage>>&) override {
ASSERT_EQ(Result::kInitial, result_);
if (params) {
result_ = Result::kOK;
params_.emplace(*params);
} else {
result_ = Result::kFailed;
}
}
Result GetResult() const { return result_; }
base::Optional<ModuleScriptCreationParams> GetParams() const {
return params_;
}
private:
Result result_ = Result::kInitial;
base::Optional<ModuleScriptCreationParams> params_;
};
void Fetch(const KURL& url, ClientImpl* client) {
ResourceRequest resource_request(url);
// TODO(nhiroki): Specify worklet-specific request context (e.g.,
......
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