Skip to content

Commit

Permalink
Disable network service memory cache when DevTools is attached
Browse files Browse the repository at this point in the history
The in-memory cache doesn't support DevTools yet.

Fixes request-paused-network-id-internal.js in
http/tests/inspector-protocol/fetch/.

Bug: 1339708
Change-Id: I565fab3fe2000a3371f6e23117da1a793ec69c0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3773578
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1026138}
  • Loading branch information
bashi authored and Chromium LUCI CQ committed Jul 20, 2022
1 parent 26e9b41 commit 1ec652b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion services/network/cors/cors_url_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,9 @@ void CorsURLLoader::StartNetworkRequest() {
network_loader_start_time_ = base::TimeTicks::Now();

// Check whether a fresh entry exists in the in-memory cache.
// TODO(https://crbug.com/1339708): In-memory cache should support DevTools.
absl::optional<std::string> cache_key;
if (memory_cache_) {
if (memory_cache_ && !request_.devtools_request_id.has_value()) {
cache_key = memory_cache_->CanServe(request_,
isolation_info_.network_isolation_key(),
cross_origin_embedder_policy_);
Expand Down
10 changes: 10 additions & 0 deletions services/network/network_service_memory_cache_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,16 @@ TEST_F(NetworkServiceMemoryCacheTest, CanServe_UnsupportedMultipleVaryHeader) {
ASSERT_FALSE(CanServeFromMemoryCache(request));
}

TEST_F(NetworkServiceMemoryCacheTest, CanServe_DevToolsAttached) {
ResourceRequest request = CreateRequest("/cacheable");
request.devtools_request_id = "fake-id";
StoreResponseToMemoryCache(request);

// TODO(https://crbug.com/1339708): Change the the expectation when the
// in-memory supports DevTools.
ASSERT_FALSE(CanServeFromMemoryCache(request));
}

TEST_F(NetworkServiceMemoryCacheTest, UpdateStoredCache) {
ResourceRequest request = CreateRequest("/cacheable");

Expand Down
3 changes: 2 additions & 1 deletion services/network/url_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,8 @@ void URLLoader::OnResponseStarted(net::URLRequest* url_request, int net_error) {
return;
}

if (memory_cache_) {
// TODO(https://crbug.com/1339708): In-memory cache should support DevTools.
if (memory_cache_ && !devtools_request_id().has_value()) {
memory_cache_writer_ = memory_cache_->MaybeCreateWriter(
url_request_.get(), request_destination_, response_);
}
Expand Down

0 comments on commit 1ec652b

Please sign in to comment.