Chromium Code Reviews| Index: components/cronet/android/url_request_context_adapter.h |
| diff --git a/components/cronet/android/url_request_context_adapter.h b/components/cronet/android/url_request_context_adapter.h |
| index 1bb2e70632d377b7366450f1e6f984c4a11e1b4d..48ff139d8ac74dcfd23b2fcc7794ccdd215256f0 100644 |
| --- a/components/cronet/android/url_request_context_adapter.h |
| +++ b/components/cronet/android/url_request_context_adapter.h |
| @@ -5,8 +5,10 @@ |
| #ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| +#include <queue> |
| #include <string> |
| +#include "base/callback.h" |
| #include "base/compiler_specific.h" |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| @@ -24,6 +26,7 @@ class NetLogLogger; |
| namespace cronet { |
| struct URLRequestContextConfig; |
| +typedef base::Callback<void()> RunAfterContextInitTask; |
| // Implementation of the Chromium NetLog observer interface. |
| class NetLogObserver : public net::NetLog::ThreadSafeObserver { |
| @@ -56,6 +59,10 @@ class URLRequestContextAdapter : public net::URLRequestContextGetter { |
| std::string user_agent); |
| void Initialize(scoped_ptr<URLRequestContextConfig> config); |
| + // Runs a task that might depend on context being initialized. |
| + void RunTask(const RunAfterContextInitTask& callback); |
|
mmenke
2014/10/02 22:11:52
Maybe RunTaskAfterContextInit? It's a bit unwield
xunjieli
2014/10/03 14:32:55
Done.
|
| + void RunTaskOnNetworkThread(const RunAfterContextInitTask& callback); |
| + |
| const std::string& GetUserAgent(const GURL& url) const; |
| // net::URLRequestContextGetter implementation: |
| @@ -75,6 +82,10 @@ class URLRequestContextAdapter : public net::URLRequestContextGetter { |
| scoped_ptr<NetLogObserver> net_log_observer_; |
| scoped_ptr<net::NetLogLogger> net_log_logger_; |
| + // 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_; |
| + |
| virtual ~URLRequestContextAdapter(); |
| // Initializes |context_| on the Network thread. |