This source file includes following definitions.
- GetURLRequestContext
- GetNetworkTaskRunner
#include "sync/test/accounts_client/url_request_context_getter.h"
#include <string>
#include "net/proxy/proxy_config_service_fixed.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
URLRequestContextGetter::URLRequestContextGetter(
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
: network_task_runner_(network_task_runner) {
}
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
CHECK(network_task_runner_->BelongsToCurrentThread());
if (!url_request_context_) {
net::URLRequestContextBuilder builder;
builder.set_user_agent("sync-test-accounts-client");
builder.DisableHttpCache();
#if defined(OS_LINUX) || defined(OS_ANDROID)
builder.set_proxy_config_service(
new net::ProxyConfigServiceFixed(net::ProxyConfig::CreateDirect()));
#endif
url_request_context_.reset(builder.Build());
}
return url_request_context_.get();
}
scoped_refptr<base::SingleThreadTaskRunner>
URLRequestContextGetter::GetNetworkTaskRunner() const {
return network_task_runner_;
}
URLRequestContextGetter::~URLRequestContextGetter() {}