REVIEW: access GetApplicationLocale on sequence that allows IO

This commit is contained in:
deepak1556 2017-12-16 14:51:29 +05:30 committed by Cheng Zhao
parent 1912fbb073
commit a1592446da
13 changed files with 70 additions and 19 deletions

View file

@ -12,6 +12,7 @@
#include "base/strings/string_util.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/worker_pool.h"
#include "brightray/browser/browser_client.h"
#include "brightray/browser/net/devtools_network_controller_handle.h"
#include "brightray/browser/net/devtools_network_transaction_factory.h"
#include "brightray/browser/net/require_ct_delegate.h"
@ -53,7 +54,6 @@
#include "net/url_request/url_request_intercepting_job_factory.h"
#include "net/url_request/url_request_job_factory_impl.h"
#include "storage/browser/quota/special_storage_policy.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/url_constants.h"
#if defined(USE_NSS_CERTS)
@ -142,7 +142,7 @@ URLRequestContextGetter::URLRequestContextGetter(
protocol_interceptors_(std::move(protocol_interceptors)),
job_factory_(nullptr) {
// Must first be created on the UI thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (protocol_handlers)
std::swap(protocol_handlers_, *protocol_handlers);
@ -168,7 +168,7 @@ net::HostResolver* URLRequestContextGetter::host_resolver() {
}
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!url_request_context_.get()) {
ct_delegate_.reset(new RequireCTDelegate);
@ -204,10 +204,10 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
storage_->set_channel_id_service(base::MakeUnique<net::ChannelIDService>(
new net::DefaultChannelIDStore(nullptr)));
std::string accept_lang = l10n_util::GetApplicationLocale("");
storage_->set_http_user_agent_settings(base::WrapUnique(
new net::StaticHttpUserAgentSettings(
net::HttpUtil::GenerateAcceptLanguageHeader(accept_lang),
storage_->set_http_user_agent_settings(
base::WrapUnique(new net::StaticHttpUserAgentSettings(
net::HttpUtil::GenerateAcceptLanguageHeader(
BrowserClient::Get()->GetApplicationLocale()),
user_agent_)));
std::unique_ptr<net::HostResolver> host_resolver(