OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 // Posts a task that might depend on the context being initialized | 51 // Posts a task that might depend on the context being initialized |
52 // to the network thread. | 52 // to the network thread. |
53 void PostTaskToNetworkThread(const tracked_objects::Location& posted_from, | 53 void PostTaskToNetworkThread(const tracked_objects::Location& posted_from, |
54 const base::Closure& callback); | 54 const base::Closure& callback); |
55 | 55 |
56 bool IsOnNetworkThread() const; | 56 bool IsOnNetworkThread() const; |
57 | 57 |
58 net::URLRequestContext* GetURLRequestContext(); | 58 net::URLRequestContext* GetURLRequestContext(); |
59 | 59 |
60 void StartNetLogToFile(JNIEnv* env, jobject jcaller, jstring jfile_name); | 60 void StartNetLogToFile(JNIEnv* env, jobject jcaller, jstring jfile_name, |
| 61 jboolean jlog_all); |
61 | 62 |
62 void StopNetLog(JNIEnv* env, jobject jcaller); | 63 void StopNetLog(JNIEnv* env, jobject jcaller); |
63 | 64 |
64 // Default net::LOAD flags used to create requests. | 65 // Default net::LOAD flags used to create requests. |
65 int default_load_flags() const { return default_load_flags_; } | 66 int default_load_flags() const { return default_load_flags_; } |
66 | 67 |
67 // Called on main Java thread to initialize URLRequestContext. | 68 // Called on main Java thread to initialize URLRequestContext. |
68 void InitRequestContextOnMainThread(); | 69 void InitRequestContextOnMainThread(); |
69 | 70 |
70 private: | 71 private: |
71 // Initializes |context_| on the Network thread. | 72 // Initializes |context_| on the Network thread. |
72 void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config, | 73 void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config, |
73 const base::android::ScopedJavaGlobalRef< | 74 const base::android::ScopedJavaGlobalRef< |
74 jobject>& jcronet_url_request_context); | 75 jobject>& jcronet_url_request_context); |
75 | 76 |
76 // Runs a task that might depend on the context being initialized. | 77 // Runs a task that might depend on the context being initialized. |
77 // This method should only be run on the network thread. | 78 // This method should only be run on the network thread. |
78 void RunTaskAfterContextInitOnNetworkThread( | 79 void RunTaskAfterContextInitOnNetworkThread( |
79 const base::Closure& task_to_run_after_context_init); | 80 const base::Closure& task_to_run_after_context_init); |
80 | 81 |
81 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const; | 82 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const; |
82 | 83 |
83 void StartNetLogToFileOnNetworkThread(const std::string& file_name); | 84 void StartNetLogToFileOnNetworkThread(const std::string& file_name, |
| 85 bool log_all); |
84 | 86 |
85 void StopNetLogOnNetworkThread(); | 87 void StopNetLogOnNetworkThread(); |
86 | 88 |
87 // Network thread is owned by |this|, but is destroyed from java thread. | 89 // Network thread is owned by |this|, but is destroyed from java thread. |
88 base::Thread* network_thread_; | 90 base::Thread* network_thread_; |
89 // |net_log_logger_| and |context_| should only be accessed on network thread. | 91 // |net_log_logger_| and |context_| should only be accessed on network thread. |
90 scoped_ptr<net::NetLogLogger> net_log_logger_; | 92 scoped_ptr<net::NetLogLogger> net_log_logger_; |
91 scoped_ptr<net::URLRequestContext> context_; | 93 scoped_ptr<net::URLRequestContext> context_; |
92 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | 94 scoped_ptr<net::ProxyConfigService> proxy_config_service_; |
93 | 95 |
94 // Context config is only valid untng context is initialized. | 96 // Context config is only valid untng context is initialized. |
95 scoped_ptr<URLRequestContextConfig> context_config_; | 97 scoped_ptr<URLRequestContextConfig> context_config_; |
96 | 98 |
97 // A queue of tasks that need to be run after context has been initialized. | 99 // A queue of tasks that need to be run after context has been initialized. |
98 std::queue<base::Closure> tasks_waiting_for_context_; | 100 std::queue<base::Closure> tasks_waiting_for_context_; |
99 bool is_context_initialized_; | 101 bool is_context_initialized_; |
100 int default_load_flags_; | 102 int default_load_flags_; |
101 | 103 |
102 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); | 104 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); |
103 }; | 105 }; |
104 | 106 |
105 } // namespace cronet | 107 } // namespace cronet |
106 | 108 |
107 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 109 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
OLD | NEW |