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

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

Issue 726013002: [Cronet] Hook up library loader, system proxy and network change notifier to async api. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 11 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/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..8f05a10f3747405fe596617cc187b8eea6d79aa2 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 {
@@ -35,13 +37,20 @@ class CronetURLRequestContextAdapter {
~CronetURLRequestContextAdapter();
- void Initialize(scoped_ptr<URLRequestContextConfig> config,
- const base::Closure& java_init_network_thread);
+ // Called on main Java thread to initialize URLRequestContext.
+ void InitRequestContextOnMainThread(
+ scoped_ptr<URLRequestContextConfig> config,
+ 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);
+
net::URLRequestContext* GetURLRequestContext();
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const;
@@ -50,12 +59,18 @@ class CronetURLRequestContextAdapter {
void StopNetLog();
+
mmenke 2015/01/08 19:06:16 nit: Remove blank line.
mef 2015/01/08 21:17:02 Done.
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;
mmenke 2015/01/08 19:06:16 Member variables should go after methods (Hrm...Di
mmenke 2015/01/08 19:06:16 Don't inline initialization like this is a C++0x11
mef 2015/01/08 21:17:02 Done.
mef 2015/01/08 21:17:02 Done.
// 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);
};

Powered by Google App Engine
This is Rietveld 408576698