blob: a1ff767f6dcf25451da1d645a67c1492fef7ac8e [file] [log] [blame]
// Copyright 2014 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.
#ifndef SERVICES_NETWORK_PUBLIC_CPP_RESOURCE_RESPONSE_INFO_H_
#define SERVICES_NETWORK_PUBLIC_CPP_RESOURCE_RESPONSE_INFO_H_
#include <stdint.h>
#include <string>
#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "net/base/host_port_pair.h"
#include "net/base/load_timing_info.h"
#include "net/cert/ct_policy_status.h"
#include "net/cert/signed_certificate_timestamp_and_status.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/nqe/effective_connection_type.h"
#include "services/network/public/cpp/http_raw_request_response_info.h"
#include "services/network/public/interfaces/fetch_api.mojom-shared.h"
#include "url/gurl.h"
namespace network {
// NOTE: when modifying this structure, also update ResourceResponse::DeepCopy
// in resource_response.cc.
struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceResponseInfo {
ResourceResponseInfo();
ResourceResponseInfo(const ResourceResponseInfo& other);
~ResourceResponseInfo();
// The time at which the request was made that resulted in this response.
// For cached responses, this time could be "far" in the past.
base::Time request_time;
// The time at which the response headers were received. For cached
// responses, this time could be "far" in the past.
base::Time response_time;
// The response headers or NULL if the URL type does not support headers.
scoped_refptr<net::HttpResponseHeaders> headers;
// The mime type of the response. This may be a derived value.
std::string mime_type;
// The character encoding of the response or none if not applicable to the
// response's mime type. This may be a derived value.
std::string charset;
// The resource's compliance with the Certificate Transparency policy.
net::ct::CTPolicyCompliance ct_policy_compliance;
// True if the resource was loaded with an otherwise-valid legacy Symantec
// certificate which will be distrusted in future.
bool is_legacy_symantec_cert;
// Content length if available. -1 if not available
int64_t content_length;
// Length of the encoded data transferred over the network. In case there is
// no data, contains -1.
int64_t encoded_data_length;
// Length of the response body data before decompression. -1 unless the body
// has been read to the end.
int64_t encoded_body_length;
// The appcache this response was loaded from, or kAppCacheNoCacheId.
// TODO(rdsmith): Remove conceptual dependence on appcache.
int64_t appcache_id;
// The manifest url of the appcache this response was loaded from.
// Note: this value is only populated for main resource requests.
GURL appcache_manifest_url;
// Detailed timing information used by the WebTiming, HAR and Developer
// Tools. Includes socket ID and socket reuse information.
net::LoadTimingInfo load_timing;
// Actual request and response headers, as obtained from the network stack.
// Only present if the renderer set report_raw_headers to true and had the
// CanReadRawCookies permission.
scoped_refptr<HttpRawRequestResponseInfo> raw_request_response_info;
// The path to a file that will contain the response body. It may only
// contain a portion of the response body at the time that the ResponseInfo
// becomes available.
base::FilePath download_file_path;
// True if the response was delivered using SPDY.
bool was_fetched_via_spdy;
// True if the response was delivered after NPN is negotiated.
bool was_alpn_negotiated;
// True if response could use alternate protocol. However, browser will
// ignore the alternate protocol when spdy is not enabled on browser side.
bool was_alternate_protocol_available;
// Information about the type of connection used to fetch this response.
net::HttpResponseInfo::ConnectionInfo connection_info;
// ALPN protocol negotiated with the server.
std::string alpn_negotiated_protocol;
// Remote address of the socket which fetched this resource.
net::HostPortPair socket_address;
// True if the response was fetched by a ServiceWorker.
bool was_fetched_via_service_worker;
// True when a request whose mode is |CORS| or |CORS-with-forced-preflight|
// is sent to a ServiceWorker but FetchEvent.respondWith is not called. So the
// renderer has to resend the request with skip service worker flag
// considering the CORS preflight logic.
bool was_fallback_required_by_service_worker;
// The URL list of the response which was served by the ServiceWorker. See
// ServiceWorkerResponseInfo::url_list_via_service_worker().
std::vector<GURL> url_list_via_service_worker;
// The type of the response, if it was returned by a service worker. This is
// kDefault if the response was not returned by a service worker.
mojom::FetchResponseType response_type_via_service_worker;
// The time immediately before starting ServiceWorker. If the response is not
// provided by the ServiceWorker, kept empty.
// TODO(ksakamoto): Move this to net::LoadTimingInfo.
base::TimeTicks service_worker_start_time;
// The time immediately before dispatching fetch event in ServiceWorker.
// If the response is not provided by the ServiceWorker, kept empty.
// TODO(ksakamoto): Move this to net::LoadTimingInfo.
base::TimeTicks service_worker_ready_time;
// True when the response is served from the CacheStorage via the
// ServiceWorker.
bool is_in_cache_storage = false;
// The cache name of the CacheStorage from where the response is served via
// the ServiceWorker. Empty if the response isn't from the CacheStorage.
std::string cache_storage_cache_name;
// A bitmask of potentially several Previews optimizations that the resource
// could have requested.
// TODO(rdsmith, reillyg): Only used by DRP; should be removed as part of DRP
// servicification.
int previews_state;
// Effective connection type when the resource was fetched. This is populated
// only for responses that correspond to main frame requests.
net::EffectiveConnectionType effective_connection_type;
// DER-encoded X509Certificate certificate chain. Only present if the renderer
// process set report_raw_headers to true.
std::vector<std::string> certificate;
// Bitmask of status info of the SSL certificate. See cert_status_flags.h for
// values.
net::CertStatus cert_status;
// Information about the SSL connection itself. See
// ssl_connection_status_flags.h for values. The protocol version,
// ciphersuite, and compression in use are encoded within. Only present if
// the renderer process set report_raw_headers to true.
int ssl_connection_status;
// The key exchange group used by the SSL connection or zero if unknown or not
// applicable. Only present if the renderer process set report_raw_headers to
// true.
uint16_t ssl_key_exchange_group;
// List of Signed Certificate Timestamps (SCTs) and their corresponding
// validation status. Only present if the renderer process set
// report_raw_headers to true.
net::SignedCertificateTimestampAndStatusList signed_certificate_timestamps;
// In case this is a CORS response fetched by a ServiceWorker, this is the
// set of headers that should be exposed.
std::vector<std::string> cors_exposed_header_names;
// True if service worker navigation preload was performed due to the request
// for this response.
bool did_service_worker_navigation_preload;
// Is used to report that cross-site document request response was blocked
// from entering renderer. Corresponding message will be generated in devtools
// console if this flag is set to true.
bool blocked_cross_site_document;
// NOTE: When adding or changing fields here, also update
// ResourceResponse::DeepCopy in resource_response.cc.
};
} // namespace network
#endif // SERVICES_NETWORK_PUBLIC_CPP_RESOURCE_RESPONSE_INFO_H_