Commit 35729677 authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

DevtoolsProtocol dependency maintenance.

Resolve domain dependency cycle Page <-> Network,
by moving ResourceType to Network.

Also add some "depends on" declarations that were missing.
This breaks client code (easy to fix) but won't change
the wire protocol.

Change-Id: I8b0321d45923b8897f39cb7420e63a7ddffd5357
Reviewed-on: https://chromium-review.googlesource.com/1212091Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589569}
parent 5b442915
......@@ -663,48 +663,49 @@ String NetErrorToString(int net_error) {
bool AddInterceptedResourceType(
const std::string& resource_type,
base::flat_set<ResourceType>* intercepted_resource_types) {
if (resource_type == protocol::Page::ResourceTypeEnum::Document) {
if (resource_type == protocol::Network::ResourceTypeEnum::Document) {
intercepted_resource_types->insert(RESOURCE_TYPE_MAIN_FRAME);
intercepted_resource_types->insert(RESOURCE_TYPE_SUB_FRAME);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::Stylesheet) {
if (resource_type == protocol::Network::ResourceTypeEnum::Stylesheet) {
intercepted_resource_types->insert(RESOURCE_TYPE_STYLESHEET);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::Image) {
if (resource_type == protocol::Network::ResourceTypeEnum::Image) {
intercepted_resource_types->insert(RESOURCE_TYPE_IMAGE);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::Media) {
if (resource_type == protocol::Network::ResourceTypeEnum::Media) {
intercepted_resource_types->insert(RESOURCE_TYPE_MEDIA);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::Font) {
if (resource_type == protocol::Network::ResourceTypeEnum::Font) {
intercepted_resource_types->insert(RESOURCE_TYPE_FONT_RESOURCE);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::Script) {
if (resource_type == protocol::Network::ResourceTypeEnum::Script) {
intercepted_resource_types->insert(RESOURCE_TYPE_SCRIPT);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::XHR) {
if (resource_type == protocol::Network::ResourceTypeEnum::XHR) {
intercepted_resource_types->insert(RESOURCE_TYPE_XHR);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::Fetch) {
if (resource_type == protocol::Network::ResourceTypeEnum::Fetch) {
intercepted_resource_types->insert(RESOURCE_TYPE_PREFETCH);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::CSPViolationReport) {
if (resource_type ==
protocol::Network::ResourceTypeEnum::CSPViolationReport) {
intercepted_resource_types->insert(RESOURCE_TYPE_CSP_REPORT);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::Ping) {
if (resource_type == protocol::Network::ResourceTypeEnum::Ping) {
intercepted_resource_types->insert(RESOURCE_TYPE_PING);
return true;
}
if (resource_type == protocol::Page::ResourceTypeEnum::Other) {
if (resource_type == protocol::Network::ResourceTypeEnum::Other) {
intercepted_resource_types->insert(RESOURCE_TYPE_SUB_RESOURCE);
intercepted_resource_types->insert(RESOURCE_TYPE_OBJECT);
intercepted_resource_types->insert(RESOURCE_TYPE_WORKER);
......@@ -1602,7 +1603,7 @@ void NetworkHandler::NavigationRequestWillBeSent(
frontend_->RequestWillBeSent(
id, id, url_without_fragment, std::move(request), current_ticks,
current_wall_time, std::move(initiator), std::move(redirect_response),
std::string(Page::ResourceTypeEnum::Document), std::move(frame_token),
std::string(Network::ResourceTypeEnum::Document), std::move(frame_token),
common_params.has_user_gesture);
}
......@@ -1639,7 +1640,7 @@ void NetworkHandler::RequestSent(const std::string& request_id,
static_cast<double>(base::Time::kMicrosecondsPerSecond),
base::Time::Now().ToDoubleT(), std::move(initiator),
std::unique_ptr<Network::Response>(),
std::string(Page::ResourceTypeEnum::Other),
std::string(Network::ResourceTypeEnum::Other),
Maybe<std::string>() /* frame_id */, request.has_user_gesture);
}
......@@ -2040,43 +2041,43 @@ namespace {
const char* ResourceTypeToString(ResourceType resource_type) {
switch (resource_type) {
case RESOURCE_TYPE_MAIN_FRAME:
return protocol::Page::ResourceTypeEnum::Document;
return protocol::Network::ResourceTypeEnum::Document;
case RESOURCE_TYPE_SUB_FRAME:
return protocol::Page::ResourceTypeEnum::Document;
return protocol::Network::ResourceTypeEnum::Document;
case RESOURCE_TYPE_STYLESHEET:
return protocol::Page::ResourceTypeEnum::Stylesheet;
return protocol::Network::ResourceTypeEnum::Stylesheet;
case RESOURCE_TYPE_SCRIPT:
return protocol::Page::ResourceTypeEnum::Script;
return protocol::Network::ResourceTypeEnum::Script;
case RESOURCE_TYPE_IMAGE:
return protocol::Page::ResourceTypeEnum::Image;
return protocol::Network::ResourceTypeEnum::Image;
case RESOURCE_TYPE_FONT_RESOURCE:
return protocol::Page::ResourceTypeEnum::Font;
return protocol::Network::ResourceTypeEnum::Font;
case RESOURCE_TYPE_SUB_RESOURCE:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
case RESOURCE_TYPE_OBJECT:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
case RESOURCE_TYPE_MEDIA:
return protocol::Page::ResourceTypeEnum::Media;
return protocol::Network::ResourceTypeEnum::Media;
case RESOURCE_TYPE_WORKER:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
case RESOURCE_TYPE_SHARED_WORKER:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
case RESOURCE_TYPE_PREFETCH:
return protocol::Page::ResourceTypeEnum::Fetch;
return protocol::Network::ResourceTypeEnum::Fetch;
case RESOURCE_TYPE_FAVICON:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
case RESOURCE_TYPE_XHR:
return protocol::Page::ResourceTypeEnum::XHR;
return protocol::Network::ResourceTypeEnum::XHR;
case RESOURCE_TYPE_PING:
return protocol::Page::ResourceTypeEnum::Ping;
return protocol::Network::ResourceTypeEnum::Ping;
case RESOURCE_TYPE_SERVICE_WORKER:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
case RESOURCE_TYPE_CSP_REPORT:
return protocol::Page::ResourceTypeEnum::CSPViolationReport;
return protocol::Network::ResourceTypeEnum::CSPViolationReport;
case RESOURCE_TYPE_PLUGIN_RESOURCE:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
default:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
}
}
......
......@@ -209,7 +209,7 @@ void RenderFrameDevToolsAgentHost::OnNavigationResponseReceived(
std::string frame_id = ftn->devtools_frame_token().ToString();
GURL url = nav_request.common_params().url;
DispatchToAgents(ftn, &protocol::NetworkHandler::ResponseReceived, id, id,
url, protocol::Page::ResourceTypeEnum::Document,
url, protocol::Network::ResourceTypeEnum::Document,
response.head, frame_id);
}
......@@ -220,7 +220,7 @@ void RenderFrameDevToolsAgentHost::OnNavigationRequestFailed(
FrameTreeNode* ftn = nav_request.frame_tree_node();
std::string id = nav_request.devtools_navigation_token().ToString();
DispatchToAgents(ftn, &protocol::NetworkHandler::LoadingComplete, id,
protocol::Page::ResourceTypeEnum::Document, status);
protocol::Network::ResourceTypeEnum::Document, status);
}
// static
......@@ -261,7 +261,7 @@ void RenderFrameDevToolsAgentHost::OnSignedExchangeCertificateResponseReceived(
const network::ResourceResponseHead& head) {
DispatchToAgents(frame_tree_node, &protocol::NetworkHandler::ResponseReceived,
request_id.ToString(), loader_id.ToString(), url,
protocol::Page::ResourceTypeEnum::Other, head,
protocol::Network::ResourceTypeEnum::Other, head,
protocol::Maybe<std::string>());
}
......@@ -272,7 +272,7 @@ void RenderFrameDevToolsAgentHost::OnSignedExchangeCertificateRequestCompleted(
const network::URLLoaderCompletionStatus& status) {
DispatchToAgents(frame_tree_node, &protocol::NetworkHandler::LoadingComplete,
request_id.ToString(),
protocol::Page::ResourceTypeEnum::Other, status);
protocol::Network::ResourceTypeEnum::Other, status);
}
// static
......
......@@ -205,7 +205,7 @@ void ServiceWorkerDevToolsManager::NavigationPreloadResponseReceived(
return;
for (auto* network : protocol::NetworkHandler::ForAgentHost(it->second.get()))
network->ResponseReceived(request_id, std::string(), url,
protocol::Page::ResourceTypeEnum::Other, head,
protocol::Network::ResourceTypeEnum::Other, head,
protocol::Maybe<std::string>());
}
......@@ -219,8 +219,8 @@ void ServiceWorkerDevToolsManager::NavigationPreloadCompleted(
if (it == live_hosts_.end())
return;
for (auto* network : protocol::NetworkHandler::ForAgentHost(it->second.get()))
network->LoadingComplete(request_id,
protocol::Page::ResourceTypeEnum::Other, status);
network->LoadingComplete(
request_id, protocol::Network::ResourceTypeEnum::Other, status);
}
} // namespace content
......@@ -1909,6 +1909,7 @@ domain DOM
domain DOMDebugger
depends on DOM
depends on Debugger
depends on Runtime
# DOM breakpoint type.
type DOMBreakpointType extends string
......@@ -3482,6 +3483,26 @@ domain Network
depends on Runtime
depends on Security
# Resource type as it was perceived by the rendering engine.
type ResourceType extends string
enum
Document
Stylesheet
Image
Media
Font
Script
TextTrack
XHR
Fetch
EventSource
WebSocket
Manifest
SignedExchange
Ping
CSPViolationReport
Other
# Unique loader identifier.
type LoaderId extends string
......@@ -3765,7 +3786,7 @@ domain Network
# Resource URL. This is the url of the original network request.
string url
# Type of this resource.
Page.ResourceType type
ResourceType type
# Cached response data.
optional Response response
# Cached response body size.
......@@ -3881,7 +3902,7 @@ domain Network
# backslash. Omitting is equivalent to "*".
optional string urlPattern
# If set, only requests for matching resource types will be intercepted.
optional Page.ResourceType resourceType
optional ResourceType resourceType
# Stage at wich to begin intercepting requests. Default is Request.
optional InterceptionStage interceptionStage
......@@ -4252,7 +4273,7 @@ domain Network
# Timestamp.
MonotonicTime timestamp
# Resource type.
Page.ResourceType type
ResourceType type
# User friendly error message.
string errorText
# True if loading was canceled.
......@@ -4285,7 +4306,7 @@ domain Network
# The id of the frame that initiated the request.
Page.FrameId frameId
# How the requested resource will be used.
Page.ResourceType resourceType
ResourceType resourceType
# Whether this is a navigation request, which can abort the navigation completely.
boolean isNavigationRequest
# Set if the request is a navigation that will result in a download.
......@@ -4332,7 +4353,7 @@ domain Network
# Redirect response data.
optional Response redirectResponse
# Type of this resource.
optional Page.ResourceType type
optional ResourceType type
# Frame identifier.
optional Page.FrameId frameId
# Whether the request is initiated by a user gesture. Defaults to false.
......@@ -4366,7 +4387,7 @@ domain Network
# Timestamp.
MonotonicTime timestamp
# Resource type.
Page.ResourceType type
ResourceType type
# Response data.
Response response
# Frame identifier.
......@@ -4623,26 +4644,7 @@ domain Page
depends on Debugger
depends on DOM
depends on Network
# Resource type as it was perceived by the rendering engine.
type ResourceType extends string
enum
Document
Stylesheet
Image
Media
Font
Script
TextTrack
XHR
Fetch
EventSource
WebSocket
Manifest
SignedExchange
Ping
CSPViolationReport
Other
depends on Runtime
# Unique frame identifier.
type FrameId extends string
......@@ -4673,7 +4675,7 @@ domain Page
# Resource URL.
string url
# Type of this resource.
ResourceType type
Network.ResourceType type
# Resource mimeType as determined by the browser.
string mimeType
# last-modified timestamp as reported by server.
......
......@@ -373,35 +373,35 @@ String InspectorPageAgent::ResourceTypeJson(
InspectorPageAgent::ResourceType resource_type) {
switch (resource_type) {
case kDocumentResource:
return protocol::Page::ResourceTypeEnum::Document;
return protocol::Network::ResourceTypeEnum::Document;
case kFontResource:
return protocol::Page::ResourceTypeEnum::Font;
return protocol::Network::ResourceTypeEnum::Font;
case kImageResource:
return protocol::Page::ResourceTypeEnum::Image;
return protocol::Network::ResourceTypeEnum::Image;
case kMediaResource:
return protocol::Page::ResourceTypeEnum::Media;
return protocol::Network::ResourceTypeEnum::Media;
case kScriptResource:
return protocol::Page::ResourceTypeEnum::Script;
return protocol::Network::ResourceTypeEnum::Script;
case kStylesheetResource:
return protocol::Page::ResourceTypeEnum::Stylesheet;
return protocol::Network::ResourceTypeEnum::Stylesheet;
case kTextTrackResource:
return protocol::Page::ResourceTypeEnum::TextTrack;
return protocol::Network::ResourceTypeEnum::TextTrack;
case kXHRResource:
return protocol::Page::ResourceTypeEnum::XHR;
return protocol::Network::ResourceTypeEnum::XHR;
case kFetchResource:
return protocol::Page::ResourceTypeEnum::Fetch;
return protocol::Network::ResourceTypeEnum::Fetch;
case kEventSourceResource:
return protocol::Page::ResourceTypeEnum::EventSource;
return protocol::Network::ResourceTypeEnum::EventSource;
case kWebSocketResource:
return protocol::Page::ResourceTypeEnum::WebSocket;
return protocol::Network::ResourceTypeEnum::WebSocket;
case kManifestResource:
return protocol::Page::ResourceTypeEnum::Manifest;
return protocol::Network::ResourceTypeEnum::Manifest;
case kSignedExchangeResource:
return protocol::Page::ResourceTypeEnum::SignedExchange;
return protocol::Network::ResourceTypeEnum::SignedExchange;
case kOtherResource:
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
}
return protocol::Page::ResourceTypeEnum::Other;
return protocol::Network::ResourceTypeEnum::Other;
}
InspectorPageAgent::ResourceType InspectorPageAgent::ToResourceType(
......
......@@ -443,7 +443,7 @@ SDK.NetworkDispatcher = class {
* @param {!Protocol.Network.TimeSinceEpoch} wallTime
* @param {!Protocol.Network.Initiator} initiator
* @param {!Protocol.Network.Response=} redirectResponse
* @param {!Protocol.Page.ResourceType=} resourceType
* @param {!Protocol.Network.ResourceType=} resourceType
* @param {!Protocol.Page.FrameId=} frameId
*/
requestWillBeSent(
......@@ -457,8 +457,10 @@ SDK.NetworkDispatcher = class {
// ignores the internally generated |redirectResponse|. The
// |outerResponse| of SignedExchangeInfo was set to |networkRequest| in
// signedExchangeReceived().
if (!networkRequest.signedExchangeInfo())
this.responseReceived(requestId, loaderId, time, Protocol.Page.ResourceType.Other, redirectResponse, frameId);
if (!networkRequest.signedExchangeInfo()) {
this.responseReceived(
requestId, loaderId, time, Protocol.Network.ResourceType.Other, redirectResponse, frameId);
}
networkRequest = this._appendRedirect(requestId, time, request.url);
this._manager.dispatchEventToListeners(SDK.NetworkManager.Events.RequestRedirected, networkRequest);
} else {
......@@ -469,7 +471,7 @@ SDK.NetworkDispatcher = class {
this._updateNetworkRequestWithRequest(networkRequest, request);
networkRequest.setIssueTime(time, wallTime);
networkRequest.setResourceType(
resourceType ? Common.resourceTypes[resourceType] : Protocol.Page.ResourceType.Other);
resourceType ? Common.resourceTypes[resourceType] : Protocol.Network.ResourceType.Other);
this._startNetworkRequest(networkRequest);
}
......@@ -491,7 +493,7 @@ SDK.NetworkDispatcher = class {
* @param {!Protocol.Network.RequestId} requestId
* @param {!Protocol.Network.LoaderId} loaderId
* @param {!Protocol.Network.MonotonicTime} time
* @param {!Protocol.Page.ResourceType} resourceType
* @param {!Protocol.Network.ResourceType} resourceType
* @param {!Protocol.Network.Response} response
* @param {!Protocol.Page.FrameId=} frameId
*/
......@@ -586,7 +588,7 @@ SDK.NetworkDispatcher = class {
* @override
* @param {!Protocol.Network.RequestId} requestId
* @param {!Protocol.Network.MonotonicTime} time
* @param {!Protocol.Page.ResourceType} resourceType
* @param {!Protocol.Network.ResourceType} resourceType
* @param {string} localizedDescription
* @param {boolean=} canceled
* @param {!Protocol.Network.BlockedReason=} blockedReason
......@@ -751,7 +753,7 @@ SDK.NetworkDispatcher = class {
* @param {!Protocol.Network.InterceptionId} interceptionId
* @param {!Protocol.Network.Request} request
* @param {!Protocol.Page.FrameId} frameId
* @param {!Protocol.Page.ResourceType} resourceType
* @param {!Protocol.Network.ResourceType} resourceType
* @param {boolean} isNavigationRequest
* @param {boolean=} isDownload
* @param {string=} redirectUrl
......@@ -1219,7 +1221,7 @@ SDK.MultitargetNetworkManager.InterceptedRequest = class {
* @param {!Protocol.Network.InterceptionId} interceptionId
* @param {!Protocol.Network.Request} request
* @param {!Protocol.Page.FrameId} frameId
* @param {!Protocol.Page.ResourceType} resourceType
* @param {!Protocol.Network.ResourceType} resourceType
* @param {boolean} isNavigationRequest
* @param {boolean=} isDownload
* @param {string=} redirectUrl
......
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