#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_
#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_TEST_UTILS_H_
#include <memory>
#include "base/command_line.h"
#include "base/containers/queue.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "components/services/storage/public/mojom/service_worker_storage_control.mojom.h"
#include "content/browser/service_worker/service_worker_cache_writer.h"
#include "content/browser/service_worker/service_worker_host.h"
#include "content/browser/service_worker/service_worker_single_script_update_checker.h"
#include "content/common/navigation_client.mojom.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "net/base/completion_once_callback.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_provider.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
namespace blink {
class StorageKey;
}
namespace content {
class EmbeddedWorkerTestHelper;
class ScopedServiceWorkerClient;
class ServiceWorkerClient;
class ServiceWorkerContainerHost;
class ServiceWorkerContext;
class ServiceWorkerHost;
class ServiceWorkerRegistration;
class ServiceWorkerRegistry;
class ServiceWorkerVersion;
base::OnceCallback<void(blink::ServiceWorkerStatusCode)>
ReceiveServiceWorkerStatus(std::optional<blink::ServiceWorkerStatusCode>* out,
base::OnceClosure quit_closure);
blink::ServiceWorkerStatusCode WarmUpServiceWorker(
ServiceWorkerVersion* version);
bool WarmUpServiceWorker(ServiceWorkerContext& service_worker_context,
const GURL& url);
blink::ServiceWorkerStatusCode StartServiceWorker(
ServiceWorkerVersion* version);
void StopServiceWorker(ServiceWorkerVersion* version);
class CommittedServiceWorkerClient final { … };
ScopedServiceWorkerClient CreateServiceWorkerClient(
ServiceWorkerContextCore* context,
const GURL& document_url,
const url::Origin& top_frame_origin,
bool are_ancestors_secure = true,
int frame_tree_node_id = 1);
ScopedServiceWorkerClient CreateServiceWorkerClient(
ServiceWorkerContextCore* context,
const GURL& document_url,
bool are_ancestors_secure = true,
int frame_tree_node_id = 1);
ScopedServiceWorkerClient CreateServiceWorkerClient(
ServiceWorkerContextCore* context,
bool are_ancestors_secure = true,
int frame_tree_node_id = 1);
std::unique_ptr<ServiceWorkerHost> CreateServiceWorkerHost(
int process_id,
bool is_parent_frame_secure,
ServiceWorkerVersion& hosted_version,
base::WeakPtr<ServiceWorkerContextCore> context);
scoped_refptr<ServiceWorkerRegistration> CreateNewServiceWorkerRegistration(
ServiceWorkerRegistry* registry,
const blink::mojom::ServiceWorkerRegistrationOptions& options,
const blink::StorageKey& key);
scoped_refptr<ServiceWorkerVersion> CreateNewServiceWorkerVersion(
ServiceWorkerRegistry* registry,
scoped_refptr<ServiceWorkerRegistration> registration,
const GURL& script_url,
blink::mojom::ScriptType script_type);
scoped_refptr<ServiceWorkerRegistration>
CreateServiceWorkerRegistrationAndVersion(ServiceWorkerContextCore* context,
const GURL& scope,
const GURL& script,
const blink::StorageKey& key,
int64_t resource_id);
storage::mojom::ServiceWorkerResourceRecordPtr WriteToDiskCacheWithIdSync(
mojo::Remote<storage::mojom::ServiceWorkerStorageControl>& storage,
const GURL& script_url,
int64_t resource_id,
const std::vector<std::pair<std::string, std::string>>& headers,
const std::string& body,
const std::string& meta_data);
storage::mojom::ServiceWorkerResourceRecordPtr WriteToDiskCacheSync(
mojo::Remote<storage::mojom::ServiceWorkerStorageControl>& storage,
const GURL& script_url,
const std::vector<std::pair<std::string, std::string>>& headers,
const std::string& body,
const std::string& meta_data);
WriteToDiskCacheCallback;
void WriteToDiskCacheAsync(
mojo::Remote<storage::mojom::ServiceWorkerStorageControl>& storage,
const GURL& script_url,
const std::vector<std::pair<std::string, std::string>>& headers,
const std::string& body,
const std::string& meta_data,
WriteToDiskCacheCallback callback);
int64_t GetNewResourceIdSync(
mojo::Remote<storage::mojom::ServiceWorkerStorageControl>& storage);
class MockServiceWorkerResourceReader
: public storage::mojom::ServiceWorkerResourceReader { … };
class MockServiceWorkerResourceWriter
: public storage::mojom::ServiceWorkerResourceWriter { … };
class ServiceWorkerUpdateCheckTestUtils { … };
std::string ReadDataPipe(mojo::ScopedDataPipeConsumerHandle handle);
}
#endif