Index: components/cronet/android/cronet_url_request_context_adapter.h |
diff --git a/components/cronet/android/cronet_url_request_context_adapter.h b/components/cronet/android/cronet_url_request_context_adapter.h |
index b9d1e307da7974b397118e444531b4571ccd0823..9ce089791a04dc4ebc7070347bf68772fbd97f46 100644 |
--- a/components/cronet/android/cronet_url_request_context_adapter.h |
+++ b/components/cronet/android/cronet_url_request_context_adapter.h |
@@ -22,26 +22,35 @@ class SingleThreadTaskRunner; |
namespace net { |
class NetLogLogger; |
class URLRequestContext; |
+class ProxyConfigService; |
} // namespace net |
namespace cronet { |
struct URLRequestContextConfig; |
+typedef base::Callback<void(void)> RunAfterContextInitTask; |
mmenke
2015/01/23 20:41:41
Should just use base::Closure (Defined in callback
mef
2015/01/28 21:32:28
Done.
xunjieli
2015/01/29 16:38:59
I might be wrong, but I think we should still keep
|
// Adapter between Java CronetUrlRequestContext and net::URLRequestContext. |
class CronetURLRequestContextAdapter { |
public: |
- CronetURLRequestContextAdapter(); |
+ explicit CronetURLRequestContextAdapter( |
+ scoped_ptr<URLRequestContextConfig> context_config); |
~CronetURLRequestContextAdapter(); |
- void Initialize(scoped_ptr<URLRequestContextConfig> config, |
- const base::Closure& java_init_network_thread); |
+ // Called on main Java thread to initialize URLRequestContext. |
+ void InitRequestContextOnMainThread( |
+ const base::Closure& java_init_network_thread); |
// Releases all resources for the request context and deletes the object. |
// Blocks until network thread is destroyed after running all pending tasks. |
void Destroy(); |
+ // Posts a task that might depend on the context being initialized |
+ // to the network thread. |
+ void PostTaskToNetworkThread(const tracked_objects::Location& posted_from, |
+ const RunAfterContextInitTask& callback); |
mmenke
2015/01/23 20:41:41
With this change, GetNetworkTaskRunner() seems no
mef
2015/01/28 21:32:28
Done.
|
+ |
net::URLRequestContext* GetURLRequestContext(); |
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const; |
@@ -53,12 +62,22 @@ class CronetURLRequestContextAdapter { |
// Default net::LOAD flags used to create requests. |
int default_load_flags() const { return default_load_flags_; } |
+ // Called on main Java thread to initialize URLRequestContext. |
+ void InitRequestContextOnMainThread(); |
+ |
private: |
// Initializes |context_| on the Network thread. |
void InitializeOnNetworkThread( |
scoped_ptr<URLRequestContextConfig> config, |
const base::Closure& java_init_network_thread); |
+ |
+ // Runs a task that might depend on the context being initialized. |
+ // This method should only be run on the network thread. |
+ void RunTaskAfterContextInitOnNetworkThread( |
+ const RunAfterContextInitTask& callback); |
+ |
void StartNetLogToFileOnNetworkThread(const std::string& file_name); |
+ |
void StopNetLogOnNetworkThread(); |
// Network thread is owned by |this|, but is destroyed from java thread. |
@@ -66,6 +85,14 @@ class CronetURLRequestContextAdapter { |
// |net_log_logger_| and |context_| should only be accessed on network thread. |
scoped_ptr<net::NetLogLogger> net_log_logger_; |
scoped_ptr<net::URLRequestContext> context_; |
+ scoped_ptr<net::ProxyConfigService> proxy_config_service_; |
+ |
+ // Context config is only valid untng context is initialized. |
+ scoped_ptr<URLRequestContextConfig> context_config_; |
+ |
+ // A queue of tasks that need to be run after context has been initialized. |
+ std::queue<RunAfterContextInitTask> tasks_waiting_for_context_; |
+ bool is_context_initialized_; |
int default_load_flags_; |
DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); |