Adding systematic checks on the atom_request_ pointer as it may be reset to null.
This commit is contained in:
parent
a655cca0a1
commit
8c5751e9f7
1 changed files with 26 additions and 7 deletions
|
@ -278,7 +278,7 @@ void URLRequest::Cancel() {
|
||||||
|
|
||||||
bool URLRequest::SetExtraHeader(const std::string& name,
|
bool URLRequest::SetExtraHeader(const std::string& name,
|
||||||
const std::string& value) {
|
const std::string& value) {
|
||||||
// State must be equal to not started.
|
// Request state must be in the initial non started state.
|
||||||
if (!request_state_.NotStarted()) {
|
if (!request_state_.NotStarted()) {
|
||||||
// Cannot change headers after send.
|
// Cannot change headers after send.
|
||||||
return false;
|
return false;
|
||||||
|
@ -292,7 +292,10 @@ bool URLRequest::SetExtraHeader(const std::string& name,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
atom_request_->SetExtraHeader(name, value);
|
DCHECK(atom_request_);
|
||||||
|
if (atom_request_) {
|
||||||
|
atom_request_->SetExtraHeader(name, value);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +305,10 @@ void URLRequest::RemoveExtraHeader(const std::string& name) {
|
||||||
// Cannot change headers after send.
|
// Cannot change headers after send.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
atom_request_->RemoveExtraHeader(name);
|
DCHECK(atom_request_);
|
||||||
|
if (atom_request_) {
|
||||||
|
atom_request_->RemoveExtraHeader(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void URLRequest::SetChunkedUpload(bool is_chunked_upload) {
|
void URLRequest::SetChunkedUpload(bool is_chunked_upload) {
|
||||||
|
@ -311,11 +317,24 @@ void URLRequest::SetChunkedUpload(bool is_chunked_upload) {
|
||||||
// Cannot change headers after send.
|
// Cannot change headers after send.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
atom_request_->SetChunkedUpload(is_chunked_upload);
|
DCHECK(atom_request_);
|
||||||
|
if (atom_request_) {
|
||||||
|
atom_request_->SetChunkedUpload(is_chunked_upload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void URLRequest::OnAuthenticationRequired(
|
void URLRequest::OnAuthenticationRequired(
|
||||||
scoped_refptr<const net::AuthChallengeInfo> auth_info) {
|
scoped_refptr<const net::AuthChallengeInfo> auth_info) {
|
||||||
|
if (request_state_.Canceled() ||
|
||||||
|
request_state_.Closed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DCHECK(atom_request_);
|
||||||
|
if (!atom_request_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EmitRequestEvent(
|
EmitRequestEvent(
|
||||||
false,
|
false,
|
||||||
"login",
|
"login",
|
||||||
|
@ -367,15 +386,15 @@ void URLRequest::OnResponseCompleted() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void URLRequest::OnRequestError(const std::string& error) {
|
void URLRequest::OnRequestError(const std::string& error) {
|
||||||
request_state_.SetFlag(RequestStateFlags::kFailed);
|
|
||||||
auto error_object = v8::Exception::Error(mate::StringToV8(isolate(), error));
|
auto error_object = v8::Exception::Error(mate::StringToV8(isolate(), error));
|
||||||
|
request_state_.SetFlag(RequestStateFlags::kFailed);
|
||||||
EmitRequestEvent(false, "error", error_object);
|
EmitRequestEvent(false, "error", error_object);
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void URLRequest::OnResponseError(const std::string& error) {
|
void URLRequest::OnResponseError(const std::string& error) {
|
||||||
response_state_.SetFlag(ResponseStateFlags::kFailed);
|
|
||||||
auto error_object = v8::Exception::Error(mate::StringToV8(isolate(), error));
|
auto error_object = v8::Exception::Error(mate::StringToV8(isolate(), error));
|
||||||
|
response_state_.SetFlag(ResponseStateFlags::kFailed);
|
||||||
EmitResponseEvent(false, "error", error_object);
|
EmitResponseEvent(false, "error", error_object);
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue