| 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 4444f156cca488e3c13023ec37d3d7238eb472bf..679b26406cb7952649ffcefe059017d4eb04a23a 100644
|
| --- a/components/cronet/android/cronet_url_request_context_adapter.h
|
| +++ b/components/cronet/android/cronet_url_request_context_adapter.h
|
| @@ -22,11 +22,13 @@ class SingleThreadTaskRunner;
|
| namespace net {
|
| class NetLogLogger;
|
| class URLRequestContext;
|
| +class ProxyConfigService;
|
| } // namespace net
|
|
|
| namespace cronet {
|
|
|
| struct URLRequestContextConfig;
|
| +typedef base::Callback<void(void)> RunAfterContextInitTask;
|
|
|
| // Adapter between Java CronetUrlRequestContext and net::URLRequestContext.
|
| class CronetURLRequestContextAdapter {
|
| @@ -42,6 +44,11 @@ class CronetURLRequestContextAdapter {
|
| // 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);
|
| +
|
| net::URLRequestContext* GetURLRequestContext();
|
|
|
| scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const;
|
| @@ -50,12 +57,20 @@ class CronetURLRequestContextAdapter {
|
|
|
| void StopNetLog();
|
|
|
| + // Called on main Java thread to initialize URLRequestContext.
|
| + void InitRequestContextOnMainThread();
|
| +
|
| private:
|
| // Network thread is owned by |this|, but is destroyed from java thread.
|
| base::Thread* network_thread_;
|
| // |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_;
|
| +
|
| + // 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_ = false;
|
|
|
| // Initializes |context_| on the Network thread.
|
| void InitializeOnNetworkThread(
|
| @@ -64,6 +79,11 @@ class CronetURLRequestContextAdapter {
|
| void StartNetLogToFileOnNetworkThread(const std::string& file_name);
|
| void StopNetLogOnNetworkThread();
|
|
|
| + // 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);
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter);
|
| };
|
|
|
|
|