Fix network delegate race condition (#12044)

* Fix race condition when getting network delegate

* Remove the evil URLRequestContextGetter::network_delegate

* Move the arguments instead of const referrencing

Safer and more efficient.
This commit is contained in:
Cheng Zhao 2018-02-26 23:24:00 +09:00 committed by shelley vohr
parent fdd66bd76d
commit 53229e3d6c
5 changed files with 41 additions and 26 deletions

View file

@ -227,22 +227,22 @@ AtomNetworkDelegate::~AtomNetworkDelegate() {
void AtomNetworkDelegate::SetSimpleListenerInIO(
SimpleEvent type,
const URLPatterns& patterns,
const SimpleListener& callback) {
URLPatterns patterns,
SimpleListener callback) {
if (callback.is_null())
simple_listeners_.erase(type);
else
simple_listeners_[type] = { patterns, callback };
simple_listeners_[type] = { std::move(patterns), std::move(callback) };
}
void AtomNetworkDelegate::SetResponseListenerInIO(
ResponseEvent type,
const URLPatterns& patterns,
const ResponseListener& callback) {
URLPatterns patterns,
ResponseListener callback) {
if (callback.is_null())
response_listeners_.erase(type);
else
response_listeners_[type] = { patterns, callback };
response_listeners_[type] = { std::move(patterns), std::move(callback) };
}
void AtomNetworkDelegate::SetDevToolsNetworkEmulationClientId(