| 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..9dcf5509b6783f351ef68ce1510ac0a704940ec4 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(void)> RunAfterContextInitTask;
|
|
|
| // Implementation of the Chromium NetLog observer interface.
|
| class NetLogObserver : public net::NetLog::ThreadSafeObserver {
|
| @@ -56,6 +59,15 @@ class URLRequestContextAdapter : public net::URLRequestContextGetter {
|
| std::string user_agent);
|
| void Initialize(scoped_ptr<URLRequestContextConfig> config);
|
|
|
| + // Runs a task that might depend on the context being initialized.
|
| + // This method can be called on any thread.
|
| + void RunTaskAfterContextInit(const RunAfterContextInitTask& callback);
|
| +
|
| + // 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);
|
| +
|
| const std::string& GetUserAgent(const GURL& url) const;
|
|
|
| // net::URLRequestContextGetter implementation:
|
| @@ -75,11 +87,22 @@ 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.
|
| void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config);
|
|
|
| + // Helper function to start netlog. This should only be run after context is
|
| + // initialized.
|
| + void StartNetLogToFileHelper(const std::string& file_name);
|
| + // Helper function to stop netlog. This should only be run after context is
|
| + // initialized.
|
| + void StopNetLogHelper();
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(URLRequestContextAdapter);
|
| };
|
|
|
|
|