// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_TEST_URL_LOADER_MONITOR_H_ #define CONTENT_PUBLIC_TEST_URL_LOADER_MONITOR_H_ #include <map> #include <memory> #include <optional> #include <set> #include "base/functional/callback.h" #include "base/run_loop.h" #include "base/synchronization/lock.h" #include "base/thread_annotations.h" #include "content/public/test/url_loader_interceptor.h" #include "services/network/public/cpp/resource_request.h" #include "services/network/public/mojom/url_loader_completion_status.mojom.h" #include "url/gurl.h" namespace content { // Helper class to monitor parameters passed to URLLoaderFactory calls for // tests. Records parameters of most recent request for each requested URL. // URLLoaderMonitor starts watching requested URLs as soon as it's constructed. // // Since URLLoaderMonitor uses a URLLoaderInterceptor, it cannot be used in // conjunctions with a URLLoaderInterceptor, and all monitored requests fail // with Mojo pipe closure errors on destruction of the URLLoaderMonitor. // // In general, it's better to add RequestHandlers or observers to the // EmbeddedTestServer than to use URLLoaderMonitor, for cases where that works. // This is useful for cases where that doesn't, however - examining particular // ResourceRequest parameters, examining requests that are blocked without // making it to the test server, etc. class URLLoaderMonitor { … }; } // namespace content #endif // CONTENT_PUBLIC_TEST_URL_LOADER_MONITOR_H_