client_id is accessed on different threads
This commit is contained in:
parent
b8e04f4947
commit
ddf962c6ea
2 changed files with 11 additions and 2 deletions
|
@ -229,6 +229,7 @@ void AtomNetworkDelegate::SetResponseListenerInIO(
|
|||
|
||||
void AtomNetworkDelegate::SetDevToolsNetworkEmulationClientId(
|
||||
const std::string& client_id) {
|
||||
base::AutoLock auto_lock(lock_);
|
||||
client_id_ = client_id;
|
||||
}
|
||||
|
||||
|
@ -247,10 +248,16 @@ int AtomNetworkDelegate::OnBeforeSendHeaders(
|
|||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
net::HttpRequestHeaders* headers) {
|
||||
if (!client_id_.empty())
|
||||
std::string client_id;
|
||||
{
|
||||
base::AutoLock auto_lock(lock_);
|
||||
client_id = client_id_;
|
||||
}
|
||||
|
||||
if (!client_id.empty())
|
||||
headers->SetHeader(
|
||||
DevToolsNetworkTransaction::kDevToolsEmulateNetworkConditionsClientId,
|
||||
client_id_);
|
||||
client_id);
|
||||
if (!ContainsKey(response_listeners_, kOnBeforeSendHeaders))
|
||||
return brightray::NetworkDelegate::OnBeforeSendHeaders(
|
||||
request, callback, headers);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "brightray/browser/network_delegate.h"
|
||||
#include "base/callback.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/values.h"
|
||||
#include "extensions/common/url_pattern.h"
|
||||
#include "net/base/net_errors.h"
|
||||
|
@ -119,6 +120,7 @@ class AtomNetworkDelegate : public brightray::NetworkDelegate {
|
|||
std::map<ResponseEvent, ResponseListenerInfo> response_listeners_;
|
||||
std::map<uint64_t, net::CompletionCallback> callbacks_;
|
||||
|
||||
base::Lock lock_;
|
||||
// Client id for devtools network emulation.
|
||||
std::string client_id_;
|
||||
|
||||
|
|
Loading…
Reference in a new issue