Commit c45a27bc authored by Tsuyoshi Horo's avatar Tsuyoshi Horo Committed by Commit Bot

Use unique request ID in SignedExchangeCertFetcher::Start()

Bug: 836832
Change-Id: I2930377b31e99e82704aa4d5e27780181c38c3ba
Reviewed-on: https://chromium-review.googlesource.com/1028530
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553922}
parent 34f0f203
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/web_package/signed_exchange_consts.h" #include "content/browser/web_package/signed_exchange_consts.h"
#include "content/browser/web_package/signed_exchange_utils.h" #include "content/browser/web_package/signed_exchange_utils.h"
#include "content/common/throttling_url_loader.h" #include "content/common/throttling_url_loader.h"
...@@ -115,7 +116,8 @@ SignedExchangeCertFetcher::~SignedExchangeCertFetcher() = default; ...@@ -115,7 +116,8 @@ SignedExchangeCertFetcher::~SignedExchangeCertFetcher() = default;
void SignedExchangeCertFetcher::Start() { void SignedExchangeCertFetcher::Start() {
url_loader_ = ThrottlingURLLoader::CreateLoaderAndStart( url_loader_ = ThrottlingURLLoader::CreateLoaderAndStart(
std::move(shared_url_loader_factory_), std::move(throttles_), std::move(shared_url_loader_factory_), std::move(throttles_),
0 /* routing_id */, 0 /* request_id */, 0 /* routing_id */,
ResourceDispatcherHostImpl::Get()->MakeRequestID() /* request_id */,
network::mojom::kURLLoadOptionNone, resource_request_.get(), this, network::mojom::kURLLoadOptionNone, resource_request_.get(), this,
kCertFetcherTrafficAnnotation, base::ThreadTaskRunnerHandle::Get()); kCertFetcherTrafficAnnotation, base::ThreadTaskRunnerHandle::Get());
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/public/common/resource_type.h" #include "content/public/common/resource_type.h"
#include "content/public/common/url_loader_throttle.h" #include "content/public/common/url_loader_throttle.h"
#include "content/public/common/weak_wrapper_shared_url_loader_factory.h" #include "content/public/common/weak_wrapper_shared_url_loader_factory.h"
...@@ -140,7 +141,10 @@ class SignedExchangeCertFetcherTest : public testing::Test { ...@@ -140,7 +141,10 @@ class SignedExchangeCertFetcherTest : public testing::Test {
SignedExchangeCertFetcherTest() SignedExchangeCertFetcherTest()
: url_(GURL("https://www.example.com/cert")), : url_(GURL("https://www.example.com/cert")),
request_initiator_( request_initiator_(
url::Origin::Create(GURL("https://htxg.example.com/test.htxg"))) {} url::Origin::Create(GURL("https://htxg.example.com/test.htxg"))),
resource_dispatcher_host_(CreateDownloadHandlerIntercept(),
base::ThreadTaskRunnerHandle::Get(),
true /* enable_resource_scheduler */) {}
~SignedExchangeCertFetcherTest() override {} ~SignedExchangeCertFetcherTest() override {}
protected: protected:
...@@ -236,6 +240,7 @@ class SignedExchangeCertFetcherTest : public testing::Test { ...@@ -236,6 +240,7 @@ class SignedExchangeCertFetcherTest : public testing::Test {
std::vector<std::unique_ptr<URLLoaderThrottle>> throttles_; std::vector<std::unique_ptr<URLLoaderThrottle>> throttles_;
base::test::ScopedTaskEnvironment scoped_task_environment_; base::test::ScopedTaskEnvironment scoped_task_environment_;
ResourceDispatcherHostImpl resource_dispatcher_host_;
private: private:
DISALLOW_COPY_AND_ASSIGN(SignedExchangeCertFetcherTest); DISALLOW_COPY_AND_ASSIGN(SignedExchangeCertFetcherTest);
......
<!DOCTYPE html>
<title>Prefetching double SignedHTTPExchange files must not crash</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="./resources/htxg-util.js"></script>
<body>
<script>
function addPrefetch(url) {
let link = document.createElement('link');
link.rel = 'prefetch';
link.href = url;
document.body.appendChild(link);
}
promise_test(async (t) => {
// The timestamp of the test HTXG file is "Apr 1 2018 00:00 UTC" and valid
// until "Apr 8 2018 00:00 UTC".
await setSignedExchangeVerificationTime(new Date("Apr 1 2018 00:01 UTC"));
const htxg1_url =
'http://127.0.0.1:8000/loading/htxg/resources/htxg-location.htxg?1';
const htxg2_url =
'http://127.0.0.1:8000/loading/htxg/resources/htxg-location.htxg?2';
addPrefetch(htxg1_url);
addPrefetch(htxg2_url);
await new Promise(resolve => {
setInterval(() => {
const entries = performance.getEntriesByType("resource");
let hit_count = 0;
for (let i = 0; i < entries.length; ++i) {
const entry = entries[i];
if (entry.name == htxg1_url || entry.name == htxg2_url) {
if (++hit_count == 2)
resolve();
}
}
}, 100);
});
}, 'Prefetching double SignedHTTPExchange files must not crash');
</script>
</body>
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