mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update source files for bracket style
This commit is contained in:
@@ -77,8 +77,9 @@ class RequestManager {
|
||||
}
|
||||
|
||||
void Remove(int32_t request_id) {
|
||||
if (request_id > kInitialRequestID)
|
||||
if (request_id > kInitialRequestID) {
|
||||
return;
|
||||
}
|
||||
|
||||
base::AutoLock lock_scope(lock_);
|
||||
RequestMap::iterator it = map_.find(request_id);
|
||||
@@ -87,8 +88,9 @@ class RequestManager {
|
||||
}
|
||||
|
||||
absl::optional<CefBrowserURLRequest::RequestInfo> Get(int32_t request_id) {
|
||||
if (request_id > kInitialRequestID)
|
||||
if (request_id > kInitialRequestID) {
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
base::AutoLock lock_scope(lock_);
|
||||
RequestMap::const_iterator it = map_.find(request_id);
|
||||
@@ -143,8 +145,9 @@ class CefBrowserURLRequest::Context
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
const GURL& url = GURL(request_->GetURL().ToString());
|
||||
if (!url.is_valid())
|
||||
if (!url.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!request_context_) {
|
||||
request_context_ = CefRequestContext::GetGlobalContext();
|
||||
@@ -166,8 +169,9 @@ class CefBrowserURLRequest::Context
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
// The request may already be complete or canceled.
|
||||
if (!url_request_)
|
||||
if (!url_request_) {
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK_EQ(status_, UR_IO_PENDING);
|
||||
status_ = UR_CANCELED;
|
||||
@@ -252,8 +256,9 @@ class CefBrowserURLRequest::Context
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
// The request may have been canceled.
|
||||
if (!url_request_)
|
||||
if (!url_request_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!loader_factory_getter) {
|
||||
// Cancel the request immediately.
|
||||
@@ -463,8 +468,9 @@ class CefBrowserURLRequest::Context
|
||||
DCHECK_EQ(status_, UR_IO_PENDING);
|
||||
|
||||
upload_data_size_ = total;
|
||||
if (position == total)
|
||||
if (position == total) {
|
||||
got_upload_progress_complete_ = true;
|
||||
}
|
||||
|
||||
client_->OnUploadProgress(url_request_.get(), position, total);
|
||||
}
|
||||
@@ -511,8 +517,9 @@ class CefBrowserURLRequest::Context
|
||||
DCHECK(CalledOnValidThread());
|
||||
|
||||
// The request may already be complete or canceled.
|
||||
if (!url_request_)
|
||||
if (!url_request_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Status will be UR_IO_PENDING if we're called when the request is complete
|
||||
// (via SimpleURLLoaderStreamConsumer or OnHeadersOnly). We can only call
|
||||
@@ -528,8 +535,9 @@ class CefBrowserURLRequest::Context
|
||||
response_was_cached_ = loader_->LoadedFromCache();
|
||||
}
|
||||
|
||||
if (success)
|
||||
if (success) {
|
||||
NotifyUploadProgressIfNecessary();
|
||||
}
|
||||
|
||||
client_->OnRequestComplete(url_request_.get());
|
||||
|
||||
@@ -629,50 +637,58 @@ CefBrowserURLRequest::CefBrowserURLRequest(
|
||||
CefBrowserURLRequest::~CefBrowserURLRequest() {}
|
||||
|
||||
bool CefBrowserURLRequest::Start() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
return context_->Start();
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> CefBrowserURLRequest::GetRequest() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->request();
|
||||
}
|
||||
|
||||
CefRefPtr<CefURLRequestClient> CefBrowserURLRequest::GetClient() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->client();
|
||||
}
|
||||
|
||||
CefURLRequest::Status CefBrowserURLRequest::GetRequestStatus() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return UR_UNKNOWN;
|
||||
}
|
||||
return context_->status();
|
||||
}
|
||||
|
||||
CefURLRequest::ErrorCode CefBrowserURLRequest::GetRequestError() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return ERR_NONE;
|
||||
}
|
||||
return context_->response()->GetError();
|
||||
}
|
||||
|
||||
CefRefPtr<CefResponse> CefBrowserURLRequest::GetResponse() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->response();
|
||||
}
|
||||
|
||||
bool CefBrowserURLRequest::ResponseWasCached() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
return context_->response_was_cached();
|
||||
}
|
||||
|
||||
void CefBrowserURLRequest::Cancel() {
|
||||
if (!VerifyContext())
|
||||
if (!VerifyContext()) {
|
||||
return;
|
||||
}
|
||||
return context_->Cancel();
|
||||
}
|
||||
|
||||
|
@@ -94,8 +94,9 @@ void ContinueWithLoadedCookies(const AllowCookieCallback& allow_cookie_callback,
|
||||
for (const auto& status : cookies) {
|
||||
bool allow = false;
|
||||
allow_cookie_callback.Run(status.cookie, &allow);
|
||||
if (allow)
|
||||
if (allow) {
|
||||
allowed_cookies.push_back(status.cookie);
|
||||
}
|
||||
}
|
||||
std::move(done_callback).Run(cookies.size(), std::move(allowed_cookies));
|
||||
}
|
||||
@@ -213,16 +214,18 @@ void SaveCookiesOnUIThread(
|
||||
bool IsCookieableScheme(
|
||||
const GURL& url,
|
||||
const absl::optional<std::vector<std::string>>& cookieable_schemes) {
|
||||
if (!url.has_scheme())
|
||||
if (!url.has_scheme()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cookieable_schemes) {
|
||||
// The client has explicitly registered the full set of schemes that should
|
||||
// be supported.
|
||||
const auto url_scheme = url.scheme_piece();
|
||||
for (auto scheme : *cookieable_schemes) {
|
||||
if (url_scheme == scheme)
|
||||
if (url_scheme == scheme) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -272,8 +275,9 @@ void SaveCookies(const CefBrowserContext::Getter& browser_context_getter,
|
||||
// Match the logic in
|
||||
// URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete.
|
||||
base::Time response_date;
|
||||
if (!headers->GetDateValue(&response_date))
|
||||
if (!headers->GetDateValue(&response_date)) {
|
||||
response_date = base::Time();
|
||||
}
|
||||
|
||||
const base::StringPiece name(net_service::kHTTPSetCookieHeaderName);
|
||||
std::string cookie_string;
|
||||
@@ -295,8 +299,9 @@ void SaveCookies(const CefBrowserContext::Getter& browser_context_getter,
|
||||
|
||||
bool allow = false;
|
||||
allow_cookie_callback.Run(*cookie, &allow);
|
||||
if (allow)
|
||||
if (allow) {
|
||||
allowed_cookies.push_back(*cookie);
|
||||
}
|
||||
}
|
||||
|
||||
if (!allowed_cookies.empty()) {
|
||||
|
@@ -37,8 +37,9 @@ CookieManager* GetCookieManager(CefBrowserContext* browser_context) {
|
||||
|
||||
// Always execute the callback asynchronously.
|
||||
void RunAsyncCompletionOnUIThread(CefRefPtr<CefCompletionCallback> callback) {
|
||||
if (!callback.get())
|
||||
if (!callback.get()) {
|
||||
return;
|
||||
}
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefCompletionCallback::OnComplete,
|
||||
callback.get()));
|
||||
}
|
||||
@@ -46,8 +47,9 @@ void RunAsyncCompletionOnUIThread(CefRefPtr<CefCompletionCallback> callback) {
|
||||
// Always execute the callback asynchronously.
|
||||
void SetCookieCallbackImpl(CefRefPtr<CefSetCookieCallback> callback,
|
||||
net::CookieAccessResult access_result) {
|
||||
if (!callback.get())
|
||||
if (!callback.get()) {
|
||||
return;
|
||||
}
|
||||
const bool is_include = access_result.status.IsInclude();
|
||||
if (!is_include) {
|
||||
LOG(WARNING) << "SetCookie failed with reason: "
|
||||
@@ -60,8 +62,9 @@ void SetCookieCallbackImpl(CefRefPtr<CefSetCookieCallback> callback,
|
||||
// Always execute the callback asynchronously.
|
||||
void DeleteCookiesCallbackImpl(CefRefPtr<CefDeleteCookiesCallback> callback,
|
||||
uint32_t num_deleted) {
|
||||
if (!callback.get())
|
||||
if (!callback.get()) {
|
||||
return;
|
||||
}
|
||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefDeleteCookiesCallback::OnComplete,
|
||||
callback.get(), num_deleted));
|
||||
}
|
||||
@@ -72,8 +75,9 @@ void ExecuteVisitor(CefRefPtr<CefCookieVisitor> visitor,
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
auto browser_context = GetBrowserContext(browser_context_getter);
|
||||
if (!browser_context)
|
||||
if (!browser_context) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto cookie_manager = GetCookieManager(browser_context);
|
||||
|
||||
@@ -88,8 +92,9 @@ void ExecuteVisitor(CefRefPtr<CefCookieVisitor> visitor,
|
||||
cookie_manager->DeleteCanonicalCookie(
|
||||
cc, CookieManager::DeleteCanonicalCookieCallback());
|
||||
}
|
||||
if (!keepLooping)
|
||||
if (!keepLooping) {
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -141,8 +146,9 @@ void CefCookieManagerImpl::Initialize(
|
||||
|
||||
bool CefCookieManagerImpl::VisitAllCookies(
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
if (!visitor.get())
|
||||
if (!visitor.get()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ValidContext()) {
|
||||
StoreOrTriggerInitCallback(base::BindOnce(
|
||||
@@ -158,12 +164,14 @@ bool CefCookieManagerImpl::VisitUrlCookies(
|
||||
const CefString& url,
|
||||
bool includeHttpOnly,
|
||||
CefRefPtr<CefCookieVisitor> visitor) {
|
||||
if (!visitor.get())
|
||||
if (!visitor.get()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GURL gurl = GURL(url.ToString());
|
||||
if (!gurl.is_valid())
|
||||
if (!gurl.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ValidContext()) {
|
||||
StoreOrTriggerInitCallback(base::BindOnce(
|
||||
@@ -179,8 +187,9 @@ bool CefCookieManagerImpl::SetCookie(const CefString& url,
|
||||
const CefCookie& cookie,
|
||||
CefRefPtr<CefSetCookieCallback> callback) {
|
||||
GURL gurl = GURL(url.ToString());
|
||||
if (!gurl.is_valid())
|
||||
if (!gurl.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ValidContext()) {
|
||||
StoreOrTriggerInitCallback(base::BindOnce(
|
||||
@@ -198,8 +207,9 @@ bool CefCookieManagerImpl::DeleteCookies(
|
||||
CefRefPtr<CefDeleteCookiesCallback> callback) {
|
||||
// Empty URLs are allowed but not invalid URLs.
|
||||
GURL gurl = GURL(url.ToString());
|
||||
if (!gurl.is_empty() && !gurl.is_valid())
|
||||
if (!gurl.is_empty() && !gurl.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ValidContext()) {
|
||||
StoreOrTriggerInitCallback(base::BindOnce(
|
||||
@@ -229,8 +239,9 @@ bool CefCookieManagerImpl::VisitAllCookiesInternal(
|
||||
DCHECK(visitor);
|
||||
|
||||
auto browser_context = GetBrowserContext(browser_context_getter_);
|
||||
if (!browser_context)
|
||||
if (!browser_context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GetCookieManager(browser_context)
|
||||
->GetAllCookies(base::BindOnce(&GetAllCookiesCallbackImpl, visitor,
|
||||
@@ -247,14 +258,16 @@ bool CefCookieManagerImpl::VisitUrlCookiesInternal(
|
||||
DCHECK(url.is_valid());
|
||||
|
||||
net::CookieOptions options;
|
||||
if (includeHttpOnly)
|
||||
if (includeHttpOnly) {
|
||||
options.set_include_httponly();
|
||||
}
|
||||
options.set_same_site_cookie_context(
|
||||
net::CookieOptions::SameSiteCookieContext::MakeInclusive());
|
||||
|
||||
auto browser_context = GetBrowserContext(browser_context_getter_);
|
||||
if (!browser_context)
|
||||
if (!browser_context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GetCookieManager(browser_context)
|
||||
->GetCookieList(url, options, net::CookiePartitionKeyCollection(),
|
||||
@@ -276,8 +289,9 @@ bool CefCookieManagerImpl::SetCookieInternal(
|
||||
std::string path = CefString(&cookie.path).ToString();
|
||||
|
||||
base::Time expiration_time;
|
||||
if (cookie.has_expires)
|
||||
if (cookie.has_expires) {
|
||||
expiration_time = CefBaseTime(cookie.expires);
|
||||
}
|
||||
|
||||
net::CookieSameSite same_site =
|
||||
net_service::MakeCookieSameSite(cookie.same_site);
|
||||
@@ -300,14 +314,16 @@ bool CefCookieManagerImpl::SetCookieInternal(
|
||||
}
|
||||
|
||||
net::CookieOptions options;
|
||||
if (cookie.httponly)
|
||||
if (cookie.httponly) {
|
||||
options.set_include_httponly();
|
||||
}
|
||||
options.set_same_site_cookie_context(
|
||||
net::CookieOptions::SameSiteCookieContext::MakeInclusive());
|
||||
|
||||
auto browser_context = GetBrowserContext(browser_context_getter_);
|
||||
if (!browser_context)
|
||||
if (!browser_context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GetCookieManager(browser_context)
|
||||
->SetCanonicalCookie(*canonical_cookie, url, options,
|
||||
@@ -337,8 +353,9 @@ bool CefCookieManagerImpl::DeleteCookiesInternal(
|
||||
}
|
||||
|
||||
auto browser_context = GetBrowserContext(browser_context_getter_);
|
||||
if (!browser_context)
|
||||
if (!browser_context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GetCookieManager(browser_context)
|
||||
->DeleteCookies(std::move(deletion_filter),
|
||||
@@ -351,8 +368,9 @@ bool CefCookieManagerImpl::FlushStoreInternal(
|
||||
DCHECK(ValidContext());
|
||||
|
||||
auto browser_context = GetBrowserContext(browser_context_getter_);
|
||||
if (!browser_context)
|
||||
if (!browser_context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GetCookieManager(browser_context)
|
||||
->FlushCookieStore(
|
||||
|
@@ -428,8 +428,9 @@ InterceptedRequest::InterceptedRequest(
|
||||
}
|
||||
|
||||
InterceptedRequest::~InterceptedRequest() {
|
||||
if (status_.error_code != net::OK)
|
||||
if (status_.error_code != net::OK) {
|
||||
SendErrorCallback(status_.error_code, false);
|
||||
}
|
||||
if (on_headers_received_callback_) {
|
||||
std::move(on_headers_received_callback_)
|
||||
.Run(net::ERR_ABORTED, absl::nullopt, GURL());
|
||||
@@ -443,8 +444,9 @@ void InterceptedRequest::Restart() {
|
||||
target_loader_.reset();
|
||||
}
|
||||
|
||||
if (header_client_receiver_.is_bound())
|
||||
if (header_client_receiver_.is_bound()) {
|
||||
std::ignore = header_client_receiver_.Unbind();
|
||||
}
|
||||
|
||||
current_request_uses_header_client_ =
|
||||
factory_->url_loader_header_client_receiver_.is_bound();
|
||||
@@ -500,8 +502,9 @@ void InterceptedRequest::InputStreamFailed(bool restart_needed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!restart_needed)
|
||||
if (!restart_needed) {
|
||||
return;
|
||||
}
|
||||
|
||||
input_stream_previously_failed_ = true;
|
||||
Restart();
|
||||
@@ -521,8 +524,9 @@ void InterceptedRequest::OnBeforeSendHeaders(
|
||||
std::move(callback).Run(net::OK, absl::nullopt);
|
||||
|
||||
// Resume handling of client messages after continuing from an async callback.
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
if (proxied_client_receiver_.is_bound()) {
|
||||
proxied_client_receiver_.Resume();
|
||||
}
|
||||
}
|
||||
|
||||
void InterceptedRequest::OnHeadersReceived(
|
||||
@@ -685,8 +689,9 @@ void InterceptedRequest::FollowRedirect(
|
||||
// If |OnURLLoaderClientError| was called then we're just waiting for the
|
||||
// connection error handler of |proxied_loader_receiver_|. Don't restart the
|
||||
// job since that'll create another URLLoader.
|
||||
if (!target_client_)
|
||||
if (!target_client_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Normally we would call FollowRedirect on the target loader and it would
|
||||
// begin loading the redirected request. However, the client might want to
|
||||
@@ -696,18 +701,21 @@ void InterceptedRequest::FollowRedirect(
|
||||
|
||||
void InterceptedRequest::SetPriority(net::RequestPriority priority,
|
||||
int32_t intra_priority_value) {
|
||||
if (target_loader_)
|
||||
if (target_loader_) {
|
||||
target_loader_->SetPriority(priority, intra_priority_value);
|
||||
}
|
||||
}
|
||||
|
||||
void InterceptedRequest::PauseReadingBodyFromNet() {
|
||||
if (target_loader_)
|
||||
if (target_loader_) {
|
||||
target_loader_->PauseReadingBodyFromNet();
|
||||
}
|
||||
}
|
||||
|
||||
void InterceptedRequest::ResumeReadingBodyFromNet() {
|
||||
if (target_loader_)
|
||||
if (target_loader_) {
|
||||
target_loader_->ResumeReadingBodyFromNet();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper methods.
|
||||
@@ -828,8 +836,9 @@ void InterceptedRequest::HandleResponseOrRedirectHeaders(
|
||||
redirect_url_ = redirect_info.has_value() ? redirect_info->new_url : GURL();
|
||||
original_url_ = request_.url;
|
||||
|
||||
if (!redirect_url_.is_empty())
|
||||
if (!redirect_url_.is_empty()) {
|
||||
redirect_in_progress_ = true;
|
||||
}
|
||||
|
||||
// |current_response_| may be nullptr when called from OnHeadersReceived.
|
||||
auto headers =
|
||||
@@ -841,8 +850,9 @@ void InterceptedRequest::HandleResponseOrRedirectHeaders(
|
||||
id_, request_, redirect_url_, headers.get());
|
||||
|
||||
// Pause handling of client messages before waiting on an async callback.
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
if (proxied_client_receiver_.is_bound()) {
|
||||
proxied_client_receiver_.Pause();
|
||||
}
|
||||
|
||||
factory_->request_handler_->OnRequestResponse(
|
||||
id_, &request_, headers.get(), redirect_info,
|
||||
@@ -884,8 +894,9 @@ void InterceptedRequest::ContinueToHandleOverrideHeaders(int error_code) {
|
||||
|
||||
DCHECK(on_headers_received_callback_);
|
||||
absl::optional<std::string> headers;
|
||||
if (override_headers_)
|
||||
if (override_headers_) {
|
||||
headers = override_headers_->raw_headers();
|
||||
}
|
||||
header_client_redirect_url_ = redirect_url_;
|
||||
std::move(on_headers_received_callback_).Run(net::OK, headers, redirect_url_);
|
||||
|
||||
@@ -893,8 +904,9 @@ void InterceptedRequest::ContinueToHandleOverrideHeaders(int error_code) {
|
||||
redirect_url_ = GURL();
|
||||
|
||||
// Resume handling of client messages after continuing from an async callback.
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
if (proxied_client_receiver_.is_bound()) {
|
||||
proxied_client_receiver_.Resume();
|
||||
}
|
||||
}
|
||||
|
||||
net::RedirectInfo InterceptedRequest::MakeRedirectResponseAndInfo(
|
||||
@@ -932,16 +944,18 @@ void InterceptedRequest::ContinueToBeforeRedirect(
|
||||
request_was_redirected_ = true;
|
||||
redirect_in_progress_ = false;
|
||||
|
||||
if (header_client_redirect_url_.is_valid())
|
||||
if (header_client_redirect_url_.is_valid()) {
|
||||
header_client_redirect_url_ = GURL();
|
||||
}
|
||||
|
||||
const GURL redirect_url = redirect_url_;
|
||||
override_headers_ = nullptr;
|
||||
redirect_url_ = GURL();
|
||||
|
||||
// Resume handling of client messages after continuing from an async callback.
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
if (proxied_client_receiver_.is_bound()) {
|
||||
proxied_client_receiver_.Resume();
|
||||
}
|
||||
|
||||
const auto original_url = request_.url;
|
||||
const auto original_method = request_.method;
|
||||
@@ -1045,8 +1059,9 @@ void InterceptedRequest::ContinueToResponseStarted(int error_code) {
|
||||
|
||||
// Resume handling of client messages after continuing from an async
|
||||
// callback.
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
if (proxied_client_receiver_.is_bound()) {
|
||||
proxied_client_receiver_.Resume();
|
||||
}
|
||||
|
||||
target_client_->OnReceiveResponse(
|
||||
std::move(current_response_),
|
||||
@@ -1075,8 +1090,9 @@ void InterceptedRequest::OnProcessRequestHeaders(
|
||||
|
||||
if (!modified_headers->IsEmpty() || !removed_headers->empty()) {
|
||||
request_.headers.MergeFrom(*modified_headers);
|
||||
for (const std::string& name : *removed_headers)
|
||||
for (const std::string& name : *removed_headers) {
|
||||
request_.headers.RemoveHeader(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1090,15 +1106,17 @@ void InterceptedRequest::OnURLLoaderClientError() {
|
||||
|
||||
void InterceptedRequest::OnURLLoaderError(uint32_t custom_reason,
|
||||
const std::string& description) {
|
||||
if (custom_reason == network::mojom::URLLoader::kClientDisconnectReason)
|
||||
if (custom_reason == network::mojom::URLLoader::kClientDisconnectReason) {
|
||||
SendErrorCallback(safe_browsing::kNetErrorCodeForSafeBrowsing, true);
|
||||
}
|
||||
|
||||
got_loader_error_ = true;
|
||||
|
||||
// If CallOnComplete was already called, then this object is ready to be
|
||||
// deleted.
|
||||
if (!target_client_)
|
||||
if (!target_client_) {
|
||||
OnDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
void InterceptedRequest::CallOnComplete(
|
||||
@@ -1106,8 +1124,9 @@ void InterceptedRequest::CallOnComplete(
|
||||
bool wait_for_loader_error) {
|
||||
status_ = status;
|
||||
|
||||
if (target_client_)
|
||||
if (target_client_) {
|
||||
target_client_->OnComplete(status);
|
||||
}
|
||||
|
||||
if (proxied_loader_receiver_.is_bound() &&
|
||||
(wait_for_loader_error && !got_loader_error_)) {
|
||||
@@ -1149,8 +1168,9 @@ void InterceptedRequest::SendErrorCallback(int error_code,
|
||||
bool safebrowsing_hit) {
|
||||
// Ensure we only send one error callback, e.g. to avoid sending two if
|
||||
// there's both a networking error and safe browsing blocked the request.
|
||||
if (sent_error_callback_)
|
||||
if (sent_error_callback_) {
|
||||
return;
|
||||
}
|
||||
|
||||
sent_error_callback_ = true;
|
||||
factory_->request_handler_->OnRequestError(id_, request_, error_code,
|
||||
@@ -1228,8 +1248,9 @@ ProxyURLLoaderFactory::ProxyURLLoaderFactory(
|
||||
proxy_receivers_.set_disconnect_handler(base::BindRepeating(
|
||||
&ProxyURLLoaderFactory::OnProxyBindingError, base::Unretained(this)));
|
||||
|
||||
if (header_client_receiver)
|
||||
if (header_client_receiver) {
|
||||
url_loader_header_client_receiver_.Bind(std::move(header_client_receiver));
|
||||
}
|
||||
}
|
||||
|
||||
ProxyURLLoaderFactory::~ProxyURLLoaderFactory() {
|
||||
@@ -1275,8 +1296,9 @@ void ProxyURLLoaderFactory::CreateProxy(
|
||||
|
||||
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>
|
||||
header_client_receiver;
|
||||
if (header_client)
|
||||
if (header_client) {
|
||||
header_client_receiver = header_client->InitWithNewPipeAndPassReceiver();
|
||||
}
|
||||
|
||||
content::ResourceContext* resource_context =
|
||||
browser_context->GetResourceContext();
|
||||
@@ -1362,8 +1384,9 @@ void ProxyURLLoaderFactory::OnLoaderCreated(
|
||||
mojo::PendingReceiver<network::mojom::TrustedHeaderClient> receiver) {
|
||||
CEF_REQUIRE_IOT();
|
||||
auto request_it = requests_.find(request_id);
|
||||
if (request_it != requests_.end())
|
||||
if (request_it != requests_.end()) {
|
||||
request_it->second->OnLoaderCreated(std::move(receiver));
|
||||
}
|
||||
}
|
||||
|
||||
void ProxyURLLoaderFactory::OnLoaderForCorsPreflightCreated(
|
||||
@@ -1382,8 +1405,9 @@ void ProxyURLLoaderFactory::OnTargetFactoryError() {
|
||||
}
|
||||
|
||||
void ProxyURLLoaderFactory::OnProxyBindingError() {
|
||||
if (proxy_receivers_.empty())
|
||||
if (proxy_receivers_.empty()) {
|
||||
target_factory_.reset();
|
||||
}
|
||||
|
||||
MaybeDestroySelf();
|
||||
}
|
||||
@@ -1399,8 +1423,9 @@ void ProxyURLLoaderFactory::RemoveRequest(InterceptedRequest* request) {
|
||||
void ProxyURLLoaderFactory::MaybeDestroySelf() {
|
||||
// Even if all URLLoaderFactory pipes connected to this object have been
|
||||
// closed it has to stay alive until all active requests have completed.
|
||||
if (target_factory_.is_bound() || !requests_.empty())
|
||||
if (target_factory_.is_bound() || !requests_.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
destroyed_ = true;
|
||||
|
||||
|
@@ -113,8 +113,9 @@ class HandlerProvider : public base::RefCountedThreadSafe<HandlerProvider> {
|
||||
|
||||
void Detach() {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
if (!handler_)
|
||||
if (!handler_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute on the expected thread.
|
||||
CEF_POST_TASK(CEF_IOT,
|
||||
@@ -186,8 +187,9 @@ class ReadResponseCallbackWrapper : public CefCallback {
|
||||
|
||||
void DoRead() {
|
||||
CEF_REQUIRE_IOT();
|
||||
if (!callback_)
|
||||
if (!callback_) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto handler = handler_provider_->handler();
|
||||
if (!handler) {
|
||||
@@ -489,8 +491,9 @@ class ResourceResponseWrapper : public ResourceResponse {
|
||||
|
||||
// A |content_length| value may already be specified if the request included
|
||||
// a Range header.
|
||||
if (response_length >= 0 && *content_length == -1)
|
||||
if (response_length >= 0 && *content_length == -1) {
|
||||
*content_length = response_length;
|
||||
}
|
||||
|
||||
CefResponse::HeaderMap headerMap;
|
||||
response->GetHeaderMap(headerMap);
|
||||
|
@@ -165,15 +165,17 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
|
||||
virtual ~DestructionObserver() {
|
||||
CEF_REQUIRE_UIT();
|
||||
if (!registered_)
|
||||
if (!registered_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify that the browser or context still exists before attempting to
|
||||
// remove the observer.
|
||||
if (browser_info_) {
|
||||
auto browser = browser_info_->browser();
|
||||
if (browser)
|
||||
if (browser) {
|
||||
browser->RemoveObserver(this);
|
||||
}
|
||||
} else if (CefContext::Get()) {
|
||||
// Network requests may be torn down during shutdown, so we can't check
|
||||
// CONTEXT_STATE_VALID() here.
|
||||
@@ -345,8 +347,9 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
base::AutoLock lock_scope(lock_);
|
||||
// May be nullptr if the InterceptedRequestHandlerWrapper has already
|
||||
// been deleted.
|
||||
if (!wrapper_)
|
||||
if (!wrapper_) {
|
||||
return;
|
||||
}
|
||||
wrapper_->SetInitialized(std::move(init_state));
|
||||
wrapper_ = nullptr;
|
||||
}
|
||||
@@ -401,8 +404,9 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
|
||||
// Continue any pending requests.
|
||||
if (!pending_requests_.empty()) {
|
||||
for (const auto& request : pending_requests_)
|
||||
for (const auto& request : pending_requests_) {
|
||||
request->Run(this);
|
||||
}
|
||||
pending_requests_.clear();
|
||||
}
|
||||
}
|
||||
@@ -555,8 +559,9 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
|
||||
// True if there's a possibility that the client might handle the request.
|
||||
const bool maybe_intercept_request = handler || scheme_factory;
|
||||
if (!maybe_intercept_request && requestPtr)
|
||||
if (!maybe_intercept_request && requestPtr) {
|
||||
requestPtr = nullptr;
|
||||
}
|
||||
|
||||
// May have a handler and/or scheme factory.
|
||||
state->Reset(handler, scheme_factory, requestPtr, request_was_redirected,
|
||||
@@ -812,16 +817,19 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!state->handler_)
|
||||
if (!state->handler_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!state->pending_response_)
|
||||
if (!state->pending_response_) {
|
||||
state->pending_response_ = new CefResponseImpl();
|
||||
else
|
||||
} else {
|
||||
state->pending_response_->SetReadOnly(false);
|
||||
}
|
||||
|
||||
if (headers)
|
||||
if (headers) {
|
||||
state->pending_response_->SetResponseHeaders(*headers);
|
||||
}
|
||||
|
||||
state->pending_response_->SetReadOnly(true);
|
||||
}
|
||||
@@ -1120,8 +1128,9 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
private:
|
||||
void CallHandlerOnComplete(RequestState* state,
|
||||
const network::URLLoaderCompletionStatus& status) {
|
||||
if (!state->handler_ || !state->pending_request_)
|
||||
if (!state->handler_ || !state->pending_request_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The request object may be currently flagged as writable in cases where we
|
||||
// abort a request that is waiting on a pending callack.
|
||||
@@ -1178,8 +1187,9 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
init_state_->iothread_state_->GetHandler(
|
||||
init_state_->global_id_, /*require_frame_match=*/false);
|
||||
if (context_handler) {
|
||||
if (!requestPtr)
|
||||
if (!requestPtr) {
|
||||
requestPtr = MakeRequest(request, request_id, true);
|
||||
}
|
||||
|
||||
handler = context_handler->GetResourceRequestHandler(
|
||||
init_state_->browser_, init_state_->frame_, requestPtr.get(),
|
||||
@@ -1202,16 +1212,18 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
|
||||
RequestState* GetState(int32_t request_id) const {
|
||||
RequestMap::const_iterator it = request_map_.find(request_id);
|
||||
if (it != request_map_.end())
|
||||
if (it != request_map_.end()) {
|
||||
return it->second.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void RemoveState(int32_t request_id) {
|
||||
RequestMap::iterator it = request_map_.find(request_id);
|
||||
DCHECK(it != request_map_.end());
|
||||
if (it != request_map_.end())
|
||||
if (it != request_map_.end()) {
|
||||
request_map_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
// Stop accepting new requests and cancel pending/in-flight requests when the
|
||||
@@ -1269,10 +1281,11 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
||||
bool read_only) {
|
||||
CefRefPtr<CefRequestImpl> requestPtr = new CefRequestImpl();
|
||||
requestPtr->Set(request, request_id);
|
||||
if (read_only)
|
||||
if (read_only) {
|
||||
requestPtr->SetReadOnly(true);
|
||||
else
|
||||
} else {
|
||||
requestPtr->SetTrackChanges(true);
|
||||
}
|
||||
return requestPtr;
|
||||
}
|
||||
|
||||
@@ -1399,8 +1412,9 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
|
||||
// TODO(navigation): Can we determine the |is_download| value?
|
||||
const bool is_download = false;
|
||||
url::Origin request_initiator;
|
||||
if (request.request_initiator.has_value())
|
||||
if (request.request_initiator.has_value()) {
|
||||
request_initiator = *request.request_initiator;
|
||||
}
|
||||
|
||||
auto init_state =
|
||||
std::make_unique<InterceptedRequestHandlerWrapper::InitState>();
|
||||
|
@@ -142,8 +142,9 @@ void ResponseFilterWrapper::Filter(const char* data, size_t size) {
|
||||
last_status_ = filter_->Filter(
|
||||
const_cast<char*>(data_in_ptr), data_in_size, data_in_read,
|
||||
const_cast<char*>(data_out_ptr), data_out_size, data_out_written);
|
||||
if (last_status_ == RESPONSE_FILTER_ERROR)
|
||||
if (last_status_ == RESPONSE_FILTER_ERROR) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Validate the out values.
|
||||
if (data_in_read > data_in_size) {
|
||||
@@ -268,13 +269,15 @@ void ResponseFilterWrapper::MaybeSuccess() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!read_pending_ && !write_pending_)
|
||||
if (!read_pending_ && !write_pending_) {
|
||||
Cleanup(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ResponseFilterWrapper::Cleanup(bool success) {
|
||||
if (!success && error_callback_)
|
||||
if (!success && error_callback_) {
|
||||
std::move(error_callback_).Run();
|
||||
}
|
||||
delete this;
|
||||
}
|
||||
|
||||
@@ -290,8 +293,9 @@ mojo::ScopedDataPipeConsumerHandle CreateResponseFilterHandler(
|
||||
auto filter_wrapper = new ResponseFilterWrapper(
|
||||
filter, std::move(source_handle), std::move(error_callback));
|
||||
mojo::ScopedDataPipeConsumerHandle output_handle;
|
||||
if (!filter_wrapper->CreateOutputHandle(&output_handle))
|
||||
if (!filter_wrapper->CreateOutputHandle(&output_handle)) {
|
||||
delete filter_wrapper;
|
||||
}
|
||||
return output_handle;
|
||||
}
|
||||
|
||||
|
@@ -79,8 +79,9 @@ class OpenInputStreamWrapper
|
||||
|
||||
void CancelOnJobThread() {
|
||||
DCHECK(job_thread_task_runner_->RunsTasksInCurrentSequence());
|
||||
if (callback_.is_null())
|
||||
if (callback_.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
callback_.Reset();
|
||||
|
||||
@@ -91,8 +92,9 @@ class OpenInputStreamWrapper
|
||||
|
||||
void CancelOnWorkThread() {
|
||||
DCHECK(work_thread_task_runner_->RunsTasksInCurrentSequence());
|
||||
if (is_canceled_)
|
||||
if (is_canceled_) {
|
||||
return;
|
||||
}
|
||||
is_canceled_ = true;
|
||||
OnCallback(nullptr);
|
||||
}
|
||||
@@ -100,8 +102,9 @@ class OpenInputStreamWrapper
|
||||
void OpenOnWorkThread(int32_t request_id,
|
||||
const network::ResourceRequest& request) {
|
||||
DCHECK(work_thread_task_runner_->RunsTasksInCurrentSequence());
|
||||
if (is_canceled_)
|
||||
if (is_canceled_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// |delegate_| will remain valid until OnCallback() is executed on
|
||||
// |job_thread_task_runner_|.
|
||||
@@ -312,8 +315,9 @@ void InputStreamReader::ReadOnWorkThread(scoped_refptr<net::IOBuffer> dest,
|
||||
pending_callback_id_));
|
||||
|
||||
// Check if the callback will execute asynchronously.
|
||||
if (result && bytes_read == 0)
|
||||
if (result && bytes_read == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
RunReadCallback(result || bytes_read <= 0 ? bytes_read : net::ERR_FAILED);
|
||||
}
|
||||
@@ -335,8 +339,9 @@ void InputStreamReader::SkipToRequestedRange() {
|
||||
pending_callback_id_));
|
||||
|
||||
// Check if the callback will execute asynchronously.
|
||||
if (result && skipped == 0)
|
||||
if (result && skipped == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!result || skipped <= 0) {
|
||||
RunSkipCallback(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE);
|
||||
@@ -383,13 +388,15 @@ void InputStreamReader::ContinueSkipCallbackOnWorkThread(
|
||||
DCHECK(work_thread_task_runner_->RunsTasksInCurrentSequence());
|
||||
|
||||
// Check for out of order callbacks.
|
||||
if (pending_callback_id_ != callback_id)
|
||||
if (pending_callback_id_ != callback_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK_LE(bytes_skipped, bytes_to_skip_);
|
||||
|
||||
if (bytes_to_skip_ > 0 && bytes_skipped > 0)
|
||||
if (bytes_to_skip_ > 0 && bytes_skipped > 0) {
|
||||
bytes_to_skip_ -= bytes_skipped;
|
||||
}
|
||||
|
||||
if (bytes_skipped <= 0) {
|
||||
RunSkipCallback(net::ERR_REQUEST_RANGE_NOT_SATISFIABLE);
|
||||
@@ -409,8 +416,9 @@ void InputStreamReader::ContinueReadCallbackOnWorkThread(int callback_id,
|
||||
DCHECK(work_thread_task_runner_->RunsTasksInCurrentSequence());
|
||||
|
||||
// Check for out of order callbacks.
|
||||
if (pending_callback_id_ != callback_id)
|
||||
if (pending_callback_id_ != callback_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
RunReadCallback(bytes_read);
|
||||
}
|
||||
@@ -637,13 +645,15 @@ void StreamReaderURLLoader::HeadersComplete(int orig_status_code,
|
||||
extra_headers, false /* allow_existing_header_override */);
|
||||
pending_response->headers = headers;
|
||||
|
||||
if (content_length >= 0)
|
||||
if (content_length >= 0) {
|
||||
pending_response->content_length = content_length;
|
||||
}
|
||||
|
||||
if (!mime_type.empty()) {
|
||||
pending_response->mime_type = mime_type;
|
||||
if (!charset.empty())
|
||||
if (!charset.empty()) {
|
||||
pending_response->charset = charset;
|
||||
}
|
||||
}
|
||||
|
||||
if (header_client_.is_bound()) {
|
||||
@@ -826,8 +836,9 @@ bool StreamReaderURLLoader::ParseRange(const net::HttpRequestHeaders& headers) {
|
||||
if (net::HttpUtil::ParseRangeHeader(range_header, &ranges)) {
|
||||
// In case of multi-range request only use the first range.
|
||||
// We don't support multirange requests.
|
||||
if (ranges.size() == 1)
|
||||
if (ranges.size() == 1) {
|
||||
byte_range_ = ranges[0];
|
||||
}
|
||||
} else {
|
||||
// This happens if the range header could not be parsed or is invalid.
|
||||
return false;
|
||||
|
@@ -95,8 +95,9 @@ URLLoaderFactoryGetter::GetURLLoaderFactory() {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
}
|
||||
|
||||
if (lazy_factory_)
|
||||
if (lazy_factory_) {
|
||||
return lazy_factory_;
|
||||
}
|
||||
|
||||
// Bind on the current thread.
|
||||
auto loader_factory =
|
||||
|
Reference in New Issue
Block a user