#ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
#define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_
#include <string>
#include "base/basictypes.h"
#include "base/files/file_path.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "net/base/net_export.h"
namespace net {
class FtpTransactionFactory;
class HostResolver;
class HostMappingRules;
class ProxyConfigService;
class URLRequestContext;
class NetworkDelegate;
class NET_EXPORT URLRequestContextBuilder {
public:
struct NET_EXPORT HttpCacheParams {
enum Type {
IN_MEMORY,
DISK,
};
HttpCacheParams();
~HttpCacheParams();
Type type;
int max_size;
base::FilePath path;
};
struct NET_EXPORT HttpNetworkSessionParams {
HttpNetworkSessionParams();
~HttpNetworkSessionParams();
bool ignore_certificate_errors;
HostMappingRules* host_mapping_rules;
bool http_pipelining_enabled;
uint16 testing_fixed_http_port;
uint16 testing_fixed_https_port;
std::string trusted_spdy_proxy;
};
URLRequestContextBuilder();
~URLRequestContextBuilder();
void set_proxy_config_service(ProxyConfigService* proxy_config_service);
void set_accept_language(const std::string& accept_language) {
accept_language_ = accept_language;
}
void set_user_agent(const std::string& user_agent) {
user_agent_ = user_agent;
}
void set_data_enabled(bool enable) {
data_enabled_ = enable;
}
void set_file_enabled(bool enable) {
file_enabled_ = enable;
}
#if !defined(DISABLE_FTP_SUPPORT)
void set_ftp_enabled(bool enable) {
ftp_enabled_ = enable;
}
#endif
void set_host_resolver(HostResolver* host_resolver) {
host_resolver_.reset(host_resolver);
}
void set_network_delegate(NetworkDelegate* delegate) {
network_delegate_.reset(delegate);
}
void EnableHttpCache(const HttpCacheParams& params) {
http_cache_enabled_ = true;
http_cache_params_ = params;
}
void DisableHttpCache() {
http_cache_enabled_ = false;
http_cache_params_ = HttpCacheParams();
}
void set_http_network_session_params(
const HttpNetworkSessionParams& http_network_session_params) {
http_network_session_params_ = http_network_session_params;
}
URLRequestContext* Build();
private:
std::string accept_language_;
std::string user_agent_;
bool data_enabled_;
bool file_enabled_;
#if !defined(DISABLE_FTP_SUPPORT)
bool ftp_enabled_;
#endif
bool http_cache_enabled_;
HttpCacheParams http_cache_params_;
HttpNetworkSessionParams http_network_session_params_;
scoped_ptr<HostResolver> host_resolver_;
scoped_ptr<ProxyConfigService> proxy_config_service_;
scoped_ptr<NetworkDelegate> network_delegate_;
scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_;
DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder);
};
}
#endif