Remove the old network implementation (see issue #2622)

The `--disable-features=NetworkService` flag is no longer supported.
This commit is contained in:
Marshall Greenblatt
2019-07-29 17:27:12 -04:00
parent ccb06ce3cb
commit 67b61c4af9
76 changed files with 296 additions and 6113 deletions

View File

@@ -77,31 +77,6 @@ bool IsInternalHandledScheme(const std::string& scheme) {
return false;
}
bool IsInternalProtectedScheme(const std::string& scheme) {
// Some of these values originate from StoragePartitionImplMap::Get() in
// content/browser/storage_partition_impl_map.cc and are modified by
// InstallInternalProtectedHandlers().
static const char* schemes[] = {
url::kBlobScheme,
content::kChromeUIScheme,
url::kDataScheme,
extensions::kExtensionScheme,
url::kFileScheme,
url::kFileSystemScheme,
#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
url::kFtpScheme,
#endif
url::kJavaScriptScheme,
};
for (size_t i = 0; i < sizeof(schemes) / sizeof(schemes[0]); ++i) {
if (scheme == schemes[i])
return true;
}
return false;
}
bool IsStandardScheme(const std::string& scheme) {
url::Component scheme_comp(0, scheme.length());
return url::IsStandard(scheme.c_str(), scheme_comp);

View File

@@ -19,13 +19,6 @@ void AddInternalSchemes(content::ContentClient::Schemes* schemes);
// Returns true if the specified |scheme| is handled internally.
bool IsInternalHandledScheme(const std::string& scheme);
// Returns true if the specified |scheme| is handled internally and should not
// be explicitly registered or unregistered with the URLRequestJobFactory. A
// registered handler for one of these schemes (like "chrome") may still be
// triggered via chaining from an existing ProtocolHandler. |scheme| should
// always be a lower-case string.
bool IsInternalProtectedScheme(const std::string& scheme);
// Returns true if the specified |scheme| is a registered standard scheme.
bool IsStandardScheme(const std::string& scheme);

View File

@@ -1,16 +0,0 @@
// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "libcef/common/net_service/util.h"
#include "base/feature_list.h"
#include "services/network/public/cpp/features.h"
namespace net_service {
bool IsEnabled() {
return base::FeatureList::IsEnabled(network::features::kNetworkService);
}
} // namespace net_service

View File

@@ -1,16 +0,0 @@
// Copyright (c) 2019 The Chromium Embedded Framework 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 CEF_LIBCEF_COMMON_NET_SERVICE_UTIL_H_
#define CEF_LIBCEF_COMMON_NET_SERVICE_UTIL_H_
#pragma once
namespace net_service {
// Returns true if the NetworkService is enabled.
bool IsEnabled();
} // namespace net_service
#endif // CEF_LIBCEF_COMMON_NET_SERVICE_UTIL_H_

View File

@@ -22,7 +22,6 @@
#include "base/task/post_task.h"
#include "components/navigation_interception/navigation_params.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/resource_type.h"
#include "net/base/elements_upload_data_stream.h"
@@ -34,8 +33,6 @@
#include "net/http/http_request_headers.h"
#include "net/http/http_util.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request.h"
#include "services/network/public/cpp/data_element.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/network/public/cpp/resource_request.h"
@@ -50,7 +47,6 @@
namespace {
const char kReferrerLowerCase[] = "referer";
const char kContentTypeLowerCase[] = "content-type";
const char kCacheControlLowerCase[] = "cache-control";
const char kCacheControlDirectiveNoCacheLowerCase[] = "no-cache";
const char kCacheControlDirectiveNoStoreLowerCase[] = "no-store";
@@ -104,16 +100,6 @@ class FileElementReader : public net::UploadFileElementReader {
DISALLOW_COPY_AND_ASSIGN(FileElementReader);
};
std::string GetURLRequestReferrer(const GURL& referrer_url) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (!referrer_url.is_valid() ||
command_line->HasSwitch(network::switches::kNoReferrers)) {
return std::string();
}
return referrer_url.spec();
}
void MakeASCIILower(std::string* str) {
std::transform(str->begin(), str->end(), str->begin(), ::tolower);
}
@@ -602,82 +588,6 @@ void CefRequestImpl::Set(const net::HttpRequestHeaders& headers) {
::GetHeaderMap(headers, headermap_);
}
void CefRequestImpl::Set(const net::URLRequest* request) {
base::AutoLock lock_scope(lock_);
CHECK_READONLY_RETURN_VOID();
Reset();
url_ = request->url();
method_ = request->method();
identifier_ = request->identifier();
// URLRequest::SetReferrer ensures that we do not send username and password
// fields in the referrer.
GURL referrer(request->referrer());
// Our consumer should have made sure that this is a safe referrer. See for
// instance WebCore::FrameLoader::HideReferrer.
if (referrer.is_valid()) {
referrer_url_ = referrer;
referrer_policy_ =
static_cast<cef_referrer_policy_t>(request->referrer_policy());
}
// Transfer request headers.
::GetHeaderMap(request->extra_request_headers(), headermap_);
// Transfer post data, if any.
const net::UploadDataStream* data = request->get_upload();
if (data) {
postdata_ = CefPostData::Create();
static_cast<CefPostDataImpl*>(postdata_.get())->Set(*data);
}
first_party_for_cookies_ = request->site_for_cookies();
content::ResourceRequestInfo* info =
content::ResourceRequestInfo::ForRequest(request);
if (info) {
resource_type_ = static_cast<cef_resource_type_t>(info->GetResourceType());
transition_type_ =
static_cast<cef_transition_type_t>(info->GetPageTransition());
}
}
void CefRequestImpl::Get(net::URLRequest* request, bool changed_only) const {
base::AutoLock lock_scope(lock_);
if (ShouldSet(kChangedMethod, changed_only))
request->set_method(method_);
if (ShouldSet(kChangedReferrer, changed_only)) {
request->SetReferrer(GetURLRequestReferrer(referrer_url_));
request->set_referrer_policy(
static_cast<net::URLRequest::ReferrerPolicy>(referrer_policy_));
}
if (ShouldSet(kChangedHeaderMap, changed_only)) {
net::HttpRequestHeaders headers;
headers.AddHeadersFromString(HttpHeaderUtils::GenerateHeaders(headermap_));
request->SetExtraRequestHeaders(headers);
}
if (ShouldSet(kChangedPostData, changed_only)) {
if (postdata_.get()) {
request->set_upload(
static_cast<CefPostDataImpl*>(postdata_.get())->Get());
} else if (request->get_upload()) {
request->set_upload(std::unique_ptr<net::UploadDataStream>());
}
}
if (!first_party_for_cookies_.is_empty() &&
ShouldSet(kChangedFirstPartyForCookies, changed_only)) {
request->set_site_for_cookies(first_party_for_cookies_);
}
}
void CefRequestImpl::Set(
const navigation_interception::NavigationParams& params,
bool is_main_frame) {
@@ -867,106 +777,6 @@ void CefRequestImpl::Get(CefNavigateParams& params) const {
params.load_flags = flags_;
}
void CefRequestImpl::Get(net::URLFetcher& fetcher,
int64& upload_data_size) const {
base::AutoLock lock_scope(lock_);
if (!referrer_url_.is_empty()) {
fetcher.SetReferrer(GetURLRequestReferrer(referrer_url_));
fetcher.SetReferrerPolicy(
static_cast<net::URLRequest::ReferrerPolicy>(referrer_policy_));
}
CefRequest::HeaderMap headerMap = headermap_;
std::string content_type;
// Extract the Content-Type header value.
{
HeaderMap::iterator it = headerMap.begin();
for (; it != headerMap.end(); ++it) {
if (base::LowerCaseEqualsASCII(it->first.ToString(),
kContentTypeLowerCase)) {
content_type = it->second;
headerMap.erase(it);
break;
}
}
}
fetcher.SetExtraRequestHeaders(HttpHeaderUtils::GenerateHeaders(headerMap));
if (postdata_.get()) {
CefPostData::ElementVector elements;
postdata_->GetElements(elements);
if (elements.size() == 1) {
// Default to URL encoding if not specified.
if (content_type.empty())
content_type = net_service::kContentTypeApplicationFormURLEncoded;
CefPostDataElementImpl* impl =
static_cast<CefPostDataElementImpl*>(elements[0].get());
switch (elements[0]->GetType()) {
case PDE_TYPE_BYTES: {
const size_t size = impl->GetBytesCount();
if (flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS) {
// Return the upload data size.
upload_data_size = size;
}
fetcher.SetUploadData(
content_type,
std::string(static_cast<char*>(impl->GetBytes()), size));
break;
}
case PDE_TYPE_FILE:
fetcher.SetUploadFilePath(
content_type, base::FilePath(impl->GetFile()), 0,
std::numeric_limits<uint64_t>::max(), GetFileTaskRunner());
break;
case PDE_TYPE_EMPTY:
break;
}
} else if (elements.size() > 1) {
NOTIMPLEMENTED() << " multi-part form data is not supported";
}
}
if (!first_party_for_cookies_.is_empty())
fetcher.SetInitiator(url::Origin::Create(first_party_for_cookies_));
int flags = flags_;
if (!(flags & kURCachePolicyMask)) {
// Only consider the Cache-Control directives when a cache policy is not
// explicitly set on the request.
flags |= GetCacheControlHeaderPolicy(headerMap);
}
if (flags & UR_FLAG_NO_RETRY_ON_5XX)
fetcher.SetAutomaticallyRetryOn5xx(false);
if (flags & UR_FLAG_STOP_ON_REDIRECT)
fetcher.SetStopOnRedirect(true);
int net_flags = 0;
if (flags & UR_FLAG_SKIP_CACHE) {
net_flags |= net::LOAD_BYPASS_CACHE;
}
if (flags & UR_FLAG_ONLY_FROM_CACHE) {
net_flags |= net::LOAD_ONLY_FROM_CACHE | net::LOAD_SKIP_CACHE_VALIDATION;
}
if (flags & UR_FLAG_DISABLE_CACHE) {
net_flags |= net::LOAD_DISABLE_CACHE;
}
if (!(flags & UR_FLAG_ALLOW_STORED_CREDENTIALS)) {
net_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA |
net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES;
}
fetcher.SetLoadFlags(net_flags);
}
void CefRequestImpl::SetReadOnly(bool read_only) {
base::AutoLock lock_scope(lock_);
if (read_only_ == read_only)

View File

@@ -32,8 +32,6 @@ class UploadData;
class UploadDataStream;
class UploadElement;
class UploadElementReader;
class URLFetcher;
class URLRequest;
} // namespace net
namespace network {
@@ -103,13 +101,6 @@ class CefRequestImpl : public CefRequest {
// Populate this object from teh HttpRequestHeaders object.
void Set(const net::HttpRequestHeaders& headers);
// Populate this object from the URLRequest object.
void Set(const net::URLRequest* request);
// Populate the URLRequest object from this object.
// If |changed_only| is true then only the changed fields will be updated.
void Get(net::URLRequest* request, bool changed_only) const;
// Populate this object from the NavigationParams object.
// TODO(cef): Remove the |is_main_frame| argument once NavigationParams is
// reliable in reporting that value.
@@ -130,11 +121,6 @@ class CefRequestImpl : public CefRequest {
// Called from CefBrowserHostImpl::LoadRequest().
void Get(CefNavigateParams& params) const;
// Populate the URLFetcher object from this object.
// Called from
// CefBrowserURLRequestOld::Context::ContinueOnOriginatingThread().
void Get(net::URLFetcher& fetcher, int64& upload_data_size) const;
void SetReadOnly(bool read_only);
// Enable or disable tracking of changes. If |track_changes| is true the

View File

@@ -12,7 +12,6 @@
#include "base/strings/string_util.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/url_request/url_request.h"
#include "third_party/blink/public/platform/web_http_header_visitor.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h"
@@ -206,14 +205,6 @@ void CefResponseImpl::Set(const blink::WebURLResponse& response) {
response.VisitHttpHeaderFields(&visitor);
}
void CefResponseImpl::Set(const net::URLRequest* request) {
DCHECK(request);
const net::HttpResponseHeaders* headers = request->response_headers();
if (headers)
SetResponseHeaders(*headers);
}
void CefResponseImpl::SetReadOnly(bool read_only) {
base::AutoLock lock_scope(lock_);
read_only_ = read_only;

View File

@@ -12,7 +12,6 @@
namespace net {
class HttpResponseHeaders;
class URLRequest;
} // namespace net
namespace blink {
@@ -46,7 +45,6 @@ class CefResponseImpl : public CefResponse {
void SetResponseHeaders(const net::HttpResponseHeaders& headers);
void Set(const blink::WebURLResponse& response);
void Set(const net::URLRequest* request);
void SetReadOnly(bool read_only);

View File

@@ -3,10 +3,8 @@
// be found in the LICENSE file.
#include "include/cef_urlrequest.h"
#include "libcef/browser/net/browser_urlrequest_old_impl.h"
#include "libcef/browser/net_service/browser_urlrequest_impl.h"
#include "libcef/common/content_client.h"
#include "libcef/common/net_service/util.h"
#include "libcef/common/task_runner_impl.h"
#include "libcef/renderer/render_urlrequest_impl.h"
@@ -31,17 +29,10 @@ CefRefPtr<CefURLRequest> CefURLRequest::Create(
if (CefContentClient::Get()->browser()) {
// In the browser process.
if (net_service::IsEnabled()) {
CefRefPtr<CefBrowserURLRequest> impl =
new CefBrowserURLRequest(nullptr, request, client, request_context);
if (impl->Start())
return impl.get();
} else {
CefRefPtr<CefBrowserURLRequestOld> impl =
new CefBrowserURLRequestOld(request, client, request_context);
if (impl->Start())
return impl.get();
}
CefRefPtr<CefBrowserURLRequest> impl =
new CefBrowserURLRequest(nullptr, request, client, request_context);
if (impl->Start())
return impl.get();
return NULL;
} else if (CefContentClient::Get()->renderer()) {
// In the render process.