Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: components/cronet/android/url_request_context_adapter.h

Issue 617393005: Make URLRequestContextAdapter initialization asynchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6b438ac53e242527d6ed7367fd3301919a3aa843 100644
--- a/components/cronet/android/url_request_context_adapter.h
+++ b/components/cronet/android/url_request_context_adapter.h
@@ -7,6 +7,7 @@
#include <string>
+#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -24,6 +25,7 @@ class NetLogLogger;
namespace cronet {
struct URLRequestContextConfig;
+typedef struct base::Callback<void()> RunAfterContextInitTask;
mmenke 2014/10/02 19:51:18 nit: Know I was the one who added the "struct", b
xunjieli 2014/10/02 21:39:41 Done.
// Implementation of the Chromium NetLog observer interface.
class NetLogObserver : public net::NetLog::ThreadSafeObserver {
@@ -56,6 +58,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);
+ void RunTaskOnNetworkThread(const RunAfterContextInitTask& callback);
+
const std::string& GetUserAgent(const GURL& url) const;
// net::URLRequestContextGetter implementation:
@@ -75,6 +81,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_;
mmenke 2014/10/02 19:51:18 Maybe tasks_waiting_for_context_?
mmenke 2014/10/02 19:51:18 Should include <queue>
xunjieli 2014/10/02 21:39:41 Done.
xunjieli 2014/10/02 21:39:42 Done.
+ bool is_context_initialized_;
+
virtual ~URLRequestContextAdapter();
// Initializes |context_| on the Network thread.

Powered by Google App Engine
This is Rietveld 408576698