2013-03-13 19:12:05 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
2013-03-13 19:42:16 +00:00
|
|
|
#ifndef BRIGHTRAY_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|
|
|
|
#define BRIGHTRAY_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|
2013-03-13 19:12:05 +00:00
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/files/file_path.h"
|
|
|
|
#include "content/public/browser/browser_context.h"
|
|
|
|
#include "content/public/browser/content_browser_client.h"
|
|
|
|
#include "net/cookies/cookie_change_dispatcher.h"
|
|
|
|
#include "net/http/http_cache.h"
|
|
|
|
#include "net/http/transport_security_state.h"
|
|
|
|
#include "net/http/url_security_manager.h"
|
2017-12-15 17:32:33 +00:00
|
|
|
#include "net/url_request/url_request_context.h"
|
2013-03-13 19:12:05 +00:00
|
|
|
#include "net/url_request/url_request_context_getter.h"
|
|
|
|
|
2018-03-30 13:24:55 +00:00
|
|
|
#if DCHECK_IS_ON()
|
|
|
|
#include "base/debug/leak_tracker.h"
|
|
|
|
#endif
|
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
namespace base {
|
|
|
|
class MessageLoop;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace net {
|
|
|
|
class HostMappingRules;
|
|
|
|
class HostResolver;
|
|
|
|
class HttpAuthPreferences;
|
|
|
|
class NetworkDelegate;
|
|
|
|
class ProxyConfigService;
|
|
|
|
class URLRequestContextStorage;
|
|
|
|
class URLRequestJobFactory;
|
|
|
|
} // namespace net
|
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
namespace brightray {
|
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
class RequireCTDelegate;
|
|
|
|
class NetLog;
|
2015-08-11 10:29:55 +00:00
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
class URLRequestContextGetter : public net::URLRequestContextGetter {
|
2013-11-17 23:43:46 +00:00
|
|
|
public:
|
2018-08-13 23:16:04 +00:00
|
|
|
class Delegate {
|
|
|
|
public:
|
|
|
|
Delegate() {}
|
|
|
|
virtual ~Delegate() {}
|
|
|
|
|
|
|
|
virtual std::unique_ptr<net::NetworkDelegate> CreateNetworkDelegate();
|
|
|
|
virtual std::string GetUserAgent();
|
|
|
|
virtual std::unique_ptr<net::URLRequestJobFactory>
|
|
|
|
CreateURLRequestJobFactory(content::ProtocolHandlerMap* protocol_handlers);
|
|
|
|
virtual net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
|
|
|
|
const base::FilePath& base_path);
|
|
|
|
virtual std::unique_ptr<net::CertVerifier> CreateCertVerifier(
|
|
|
|
RequireCTDelegate* ct_delegate);
|
|
|
|
virtual net::SSLConfigService* CreateSSLConfigService();
|
|
|
|
virtual std::vector<std::string> GetCookieableSchemes();
|
|
|
|
virtual void NotifyCookieChange(const net::CanonicalCookie& cookie,
|
|
|
|
bool removed,
|
|
|
|
net::CookieChangeCause cause) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
URLRequestContextGetter(
|
|
|
|
Delegate* delegate,
|
|
|
|
NetLog* net_log,
|
|
|
|
const base::FilePath& base_path,
|
|
|
|
bool in_memory,
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
|
|
|
|
content::ProtocolHandlerMap* protocol_handlers,
|
|
|
|
content::URLRequestInterceptorScopedVector protocol_interceptors);
|
|
|
|
|
|
|
|
// net::CookieChangeDispatcher::CookieChangedCallback implementation.
|
|
|
|
void OnCookieChanged(const net::CanonicalCookie& cookie,
|
|
|
|
net::CookieChangeCause cause);
|
2017-11-27 03:27:14 +00:00
|
|
|
|
2014-08-20 07:19:25 +00:00
|
|
|
// net::URLRequestContextGetter:
|
2015-06-05 04:07:27 +00:00
|
|
|
net::URLRequestContext* GetURLRequestContext() override;
|
2017-03-23 22:47:30 +00:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
|
|
|
|
const override;
|
2013-03-13 19:12:05 +00:00
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
net::HostResolver* host_resolver();
|
|
|
|
net::URLRequestJobFactory* job_factory() const { return job_factory_; }
|
2018-08-13 22:22:45 +00:00
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
void NotifyContextShutdownOnIO();
|
2018-08-13 22:22:45 +00:00
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
private:
|
|
|
|
~URLRequestContextGetter() override;
|
2014-08-20 06:39:09 +00:00
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
Delegate* delegate_;
|
2013-03-13 19:12:05 +00:00
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
NetLog* net_log_;
|
|
|
|
base::FilePath base_path_;
|
|
|
|
bool in_memory_;
|
|
|
|
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
|
2018-08-13 22:22:45 +00:00
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
std::string user_agent_;
|
2016-06-22 06:52:04 +00:00
|
|
|
|
2018-03-30 13:24:55 +00:00
|
|
|
#if DCHECK_IS_ON()
|
|
|
|
base::debug::LeakTracker<URLRequestContextGetter> leak_tracker_;
|
|
|
|
#endif
|
|
|
|
|
2018-08-13 23:16:04 +00:00
|
|
|
std::unique_ptr<RequireCTDelegate> ct_delegate_;
|
|
|
|
std::unique_ptr<net::ProxyConfigService> proxy_config_service_;
|
|
|
|
std::unique_ptr<net::URLRequestContextStorage> storage_;
|
|
|
|
std::unique_ptr<net::URLRequestContext> url_request_context_;
|
|
|
|
std::unique_ptr<net::HostMappingRules> host_mapping_rules_;
|
|
|
|
std::unique_ptr<net::HttpAuthPreferences> http_auth_preferences_;
|
|
|
|
std::unique_ptr<net::HttpNetworkSession> http_network_session_;
|
|
|
|
std::unique_ptr<net::CookieChangeSubscription> cookie_change_sub_;
|
|
|
|
content::ProtocolHandlerMap protocol_handlers_;
|
|
|
|
content::URLRequestInterceptorScopedVector protocol_interceptors_;
|
|
|
|
|
|
|
|
net::URLRequestJobFactory* job_factory_; // weak ref
|
2016-06-15 11:30:26 +00:00
|
|
|
|
2018-03-30 13:24:55 +00:00
|
|
|
bool context_shutting_down_;
|
|
|
|
|
2013-03-13 19:12:05 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(URLRequestContextGetter);
|
|
|
|
};
|
|
|
|
|
2013-11-17 23:20:17 +00:00
|
|
|
} // namespace brightray
|
2013-03-13 19:12:05 +00:00
|
|
|
|
2017-05-18 22:05:25 +00:00
|
|
|
#endif // BRIGHTRAY_BROWSER_URL_REQUEST_CONTEXT_GETTER_H_
|