Commit d0a1ab99 authored by calamity's avatar calamity Committed by Commit Bot

Revert "NetworkService: Fix WebViewTest.ClearDataCache"

This reverts commit b94164ad.

Reason for revert: Suspected of causing
ExtensionWebRequestApiTest.WebRequestApiDoesNotCrashOnErrorAfterProfileDestroyed
failure in
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Win7%20Tests%20%28dbg%29%281%29/71221

Original change's description:
> NetworkService: Fix WebViewTest.ClearDataCache
> 
> This patch does 3 things to fix the test:
> 1. Register listeners before loading the actual guest page. See bug for
>    more background.
> 2. Add |was_fetched_via_cache| to |ResourceResponseInfo|.
> 3. Call |NetworkContext::ClearHttpCache()| in
>    |WebViewGuest::ClearData()| when Network Service was enabled. We
>    cannot use |BrowsingDataRemover| because it doesn't support
>    non-default |StoragePartition|.
> 
> Bug: 878060
> Cq-Include-Trybots: luci.chromium.try:linux_mojo
> Change-Id: I5f0ea8e62ee8f44944428cfb041f9d4e427bd67c
> Reviewed-on: https://chromium-review.googlesource.com/1195596
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Reviewed-by: Ken Rockot <rockot@chromium.org>
> Reviewed-by: Clark DuVall <cduvall@chromium.org>
> Commit-Queue: Chong Zhang <chongz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#587753}

TBR=rockot@chromium.org,tsepez@chromium.org,chongz@chromium.org,cduvall@chromium.org

Change-Id: I0a4f300e25d7fd9160d9a8e9ac02c8c733654818
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 878060
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Reviewed-on: https://chromium-review.googlesource.com/1198642Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587892}
parent 1f0cd154
...@@ -96,16 +96,9 @@ ClearDataTester.prototype.testClearDataCache = function() { ...@@ -96,16 +96,9 @@ ClearDataTester.prototype.testClearDataCache = function() {
this.webview_.request.onResponseStarted.addListener( this.webview_.request.onResponseStarted.addListener(
responseStartedHandler, {urls: ['<all_urls>']}); responseStartedHandler, {urls: ['<all_urls>']});
this.webview_.addEventListener('loadstop', () => { for (var i = 0; i < 5; ++i) {
for (var i = 0; i < 5; ++i) { this.requestXhrFromWebView_();
this.requestXhrFromWebView_(); }
}
});
// Load the actual guest URL to start the test.
var guestURL = this.webview_.getAttribute('src').replace(
'/empty_guest.html', '/guest.html');
this.webview_.setAttribute('src', guestURL);
}; };
var tester = new ClearDataTester(); var tester = new ClearDataTester();
...@@ -124,26 +117,24 @@ window.runTest = function(testName) { ...@@ -124,26 +117,24 @@ window.runTest = function(testName) {
}; };
// window.* exported functions end. // window.* exported functions end.
function setUpTest(emptyGuestURL, doneCallback) { function setUpTest(guestURL, doneCallback) {
var webview = document.createElement('webview'); var webview = document.createElement('webview');
var listener = function(e) { webview.onloadstop = function(e) {
webview.removeEventListener('loadstop', listener);
LOG('webview has loaded.'); LOG('webview has loaded.');
doneCallback(webview); doneCallback(webview);
}; };
webview.addEventListener('loadstop', listener);
webview.setAttribute('src', emptyGuestURL); webview.setAttribute('src', guestURL);
document.body.appendChild(webview); document.body.appendChild(webview);
} }
onload = function() { onload = function() {
chrome.test.getConfig(function(config) { chrome.test.getConfig(function(config) {
LOG('config: ' + config.testServer.port); LOG('config: ' + config.testServer.port);
var emptyGuestURL = 'http://localhost:' + config.testServer.port + var guestURL = 'http://localhost:' + config.testServer.port +
'/extensions/platform_apps/web_view/clear_data_cache/empty_guest.html'; '/extensions/platform_apps/web_view/clear_data_cache/guest.html';
setUpTest(emptyGuestURL, function(webview) { setUpTest(guestURL, function(webview) {
LOG('Guest load completed.'); LOG('Guest load completed.');
//chrome.test.sendMessage('WebViewTest.LAUNCHED'); //chrome.test.sendMessage('WebViewTest.LAUNCHED');
chrome.test.sendMessage('Launched'); chrome.test.sendMessage('Launched');
......
<!--
* 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.
-->
<!doctype html>
<html>
<head>
<title>A simple guest that does nothing.</title>
</head>
<body>
</body>
</html>
...@@ -350,7 +350,11 @@ void WebRequestInfo::AddResponseInfoFromResourceResponse( ...@@ -350,7 +350,11 @@ void WebRequestInfo::AddResponseInfoFromResourceResponse(
if (response_headers) if (response_headers)
response_code = response_headers->response_code(); response_code = response_headers->response_code();
response_ip = response.socket_address.host(); response_ip = response.socket_address.host();
response_from_cache = response.was_fetched_via_cache;
// TODO(https://crbug.com/721414): We have no apparent source for this
// information yet in the Network Service case. Should indicate whether or not
// the response data came from cache.
response_from_cache = false;
} }
void WebRequestInfo::InitializeWebViewAndFrameData( void WebRequestInfo::InitializeWebViewAndFrameData(
......
...@@ -61,7 +61,6 @@ ...@@ -61,7 +61,6 @@
#include "net/base/escape.h" #include "net/base/escape.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/cookies/canonical_cookie.h" #include "net/cookies/canonical_cookie.h"
#include "services/network/public/cpp/features.h"
#include "ui/base/models/simple_menu_model.h" #include "ui/base/models/simple_menu_model.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "url/url_constants.h" #include "url/url_constants.h"
...@@ -756,24 +755,13 @@ bool WebViewGuest::ClearData(base::Time remove_since, ...@@ -756,24 +755,13 @@ bool WebViewGuest::ClearData(base::Time remove_since,
web_cache::WebCacheManager::GetInstance()->ClearCacheForProcess( web_cache::WebCacheManager::GetInstance()->ClearCacheForProcess(
render_process_id); render_process_id);
base::OnceClosure cache_removal_done_callback = base::BindOnce( base::Closure cache_removal_done_callback = base::Bind(
&WebViewGuest::ClearDataInternal, weak_ptr_factory_.GetWeakPtr(), &WebViewGuest::ClearDataInternal, weak_ptr_factory_.GetWeakPtr(),
remove_since, removal_mask, callback); remove_since, removal_mask, callback);
// components/, move |ClearCache| to WebViewGuest: http//crbug.com/471287.
// We cannot use |BrowsingDataRemover| here since it doesn't support partition->ClearHttpAndMediaCaches(remove_since, base::Time::Now(),
// non-default StoragePartition. base::Callback<bool(const GURL&)>(),
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) { cache_removal_done_callback);
// Note that we've deprecated the concept of a media cache, and are now
// using a single cache for both purposes.
partition->GetNetworkContext()->ClearHttpCache(
remove_since, base::Time::Now(), nullptr /* ClearDataFilter */,
std::move(cache_removal_done_callback));
} else {
partition->ClearHttpAndMediaCaches(
remove_since, base::Time::Now(),
base::RepeatingCallback<bool(const GURL&)>(),
std::move(cache_removal_done_callback));
}
return true; return true;
} }
......
...@@ -191,7 +191,6 @@ IPC_STRUCT_TRAITS_BEGIN(network::ResourceResponseInfo) ...@@ -191,7 +191,6 @@ IPC_STRUCT_TRAITS_BEGIN(network::ResourceResponseInfo)
IPC_STRUCT_TRAITS_MEMBER(connection_info) IPC_STRUCT_TRAITS_MEMBER(connection_info)
IPC_STRUCT_TRAITS_MEMBER(alpn_negotiated_protocol) IPC_STRUCT_TRAITS_MEMBER(alpn_negotiated_protocol)
IPC_STRUCT_TRAITS_MEMBER(socket_address) IPC_STRUCT_TRAITS_MEMBER(socket_address)
IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_cache)
IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker) IPC_STRUCT_TRAITS_MEMBER(was_fetched_via_service_worker)
IPC_STRUCT_TRAITS_MEMBER(was_fallback_required_by_service_worker) IPC_STRUCT_TRAITS_MEMBER(was_fallback_required_by_service_worker)
IPC_STRUCT_TRAITS_MEMBER(url_list_via_service_worker) IPC_STRUCT_TRAITS_MEMBER(url_list_via_service_worker)
......
...@@ -38,7 +38,6 @@ scoped_refptr<ResourceResponse> ResourceResponse::DeepCopy() const { ...@@ -38,7 +38,6 @@ scoped_refptr<ResourceResponse> ResourceResponse::DeepCopy() const {
new_response->head.connection_info = head.connection_info; new_response->head.connection_info = head.connection_info;
new_response->head.alpn_negotiated_protocol = head.alpn_negotiated_protocol; new_response->head.alpn_negotiated_protocol = head.alpn_negotiated_protocol;
new_response->head.socket_address = head.socket_address; new_response->head.socket_address = head.socket_address;
new_response->head.was_fetched_via_cache = head.was_fetched_via_cache;
new_response->head.was_fetched_via_service_worker = new_response->head.was_fetched_via_service_worker =
head.was_fetched_via_service_worker; head.was_fetched_via_service_worker;
new_response->head.was_fallback_required_by_service_worker = new_response->head.was_fallback_required_by_service_worker =
......
...@@ -108,9 +108,6 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceResponseInfo { ...@@ -108,9 +108,6 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceResponseInfo {
// Remote address of the socket which fetched this resource. // Remote address of the socket which fetched this resource.
net::HostPortPair socket_address; net::HostPortPair socket_address;
// True if the response came from cache.
bool was_fetched_via_cache = false;
// True if the response was delivered through a proxy. // True if the response was delivered through a proxy.
bool was_fetched_via_proxy; bool was_fetched_via_proxy;
......
...@@ -66,7 +66,6 @@ void PopulateResourceResponse(net::URLRequest* request, ...@@ -66,7 +66,6 @@ void PopulateResourceResponse(net::URLRequest* request,
response_info.alpn_negotiated_protocol; response_info.alpn_negotiated_protocol;
response->head.connection_info = response_info.connection_info; response->head.connection_info = response_info.connection_info;
response->head.socket_address = response_info.socket_address; response->head.socket_address = response_info.socket_address;
response->head.was_fetched_via_cache = request->was_cached();
response->head.was_fetched_via_proxy = request->was_fetched_via_proxy(); response->head.was_fetched_via_proxy = request->was_fetched_via_proxy();
response->head.network_accessed = response_info.network_accessed; response->head.network_accessed = response_info.network_accessed;
response->head.async_revalidation_requested = response->head.async_revalidation_requested =
......
...@@ -61,6 +61,9 @@ ...@@ -61,6 +61,9 @@
-NetInternalsTest.netInternalsTimelineViewZoomOut -NetInternalsTest.netInternalsTimelineViewZoomOut
-NetInternalsTest.netInternalsTourTabs -NetInternalsTest.netInternalsTourTabs
# https://crbug.com/721398
-WebViewTest.ClearDataCache
# https://crbug.com/853256 # https://crbug.com/853256
-ClientHintsBrowserTest.ClientHintsLifetimeNotAttachedCookiesBlocked/0 -ClientHintsBrowserTest.ClientHintsLifetimeNotAttachedCookiesBlocked/0
-ClientHintsBrowserTest.ClientHintsLifetimeNotAttachedCookiesBlocked/1 -ClientHintsBrowserTest.ClientHintsLifetimeNotAttachedCookiesBlocked/1
......
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