| 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 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 class TimeTicks; | 29 class TimeTicks; |
| 30 } // namespace base | 30 } // namespace base |
| 31 | 31 |
| 32 namespace net { | 32 namespace net { |
| 33 class HttpServerPropertiesManager; | 33 class HttpServerPropertiesManager; |
| 34 class NetLog; | 34 class NetLog; |
| 35 class NetworkQualitiesPrefsManager; | 35 class NetworkQualitiesPrefsManager; |
| 36 class ProxyConfigService; | 36 class ProxyConfigService; |
| 37 class SdchOwner; | 37 class SdchOwner; |
| 38 class URLRequestContext; | 38 class URLRequestContext; |
| 39 class WriteToFileNetLogObserver; | |
| 40 class FileNetLogObserver; | 39 class FileNetLogObserver; |
| 41 } // namespace net | 40 } // namespace net |
| 42 | 41 |
| 43 namespace cronet { | 42 namespace cronet { |
| 44 class TestUtil; | 43 class TestUtil; |
| 45 | 44 |
| 46 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 45 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
| 47 class CronetDataReductionProxy; | 46 class CronetDataReductionProxy; |
| 48 #endif | 47 #endif |
| 49 | 48 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 75 | 74 |
| 76 // Posts a task that might depend on the context being initialized | 75 // Posts a task that might depend on the context being initialized |
| 77 // to the network thread. | 76 // to the network thread. |
| 78 void PostTaskToNetworkThread(const tracked_objects::Location& posted_from, | 77 void PostTaskToNetworkThread(const tracked_objects::Location& posted_from, |
| 79 const base::Closure& callback); | 78 const base::Closure& callback); |
| 80 | 79 |
| 81 bool IsOnNetworkThread() const; | 80 bool IsOnNetworkThread() const; |
| 82 | 81 |
| 83 net::URLRequestContext* GetURLRequestContext(); | 82 net::URLRequestContext* GetURLRequestContext(); |
| 84 | 83 |
| 85 // Starts NetLog logging to file. This can be called on any thread. Returns | 84 // TODO(xunjieli): Keep only one version of StartNetLog(). |
| 86 // false if it fails to open log file. | 85 |
| 87 bool StartNetLogToFile(JNIEnv* env, | 86 // Starts NetLog logging to file. This can be called on any thread. |
| 87 void StartNetLogToFile(JNIEnv* env, |
| 88 const base::android::JavaParamRef<jobject>& jcaller, | 88 const base::android::JavaParamRef<jobject>& jcaller, |
| 89 const base::android::JavaParamRef<jstring>& jfile_name, | 89 const base::android::JavaParamRef<jstring>& jfile_name, |
| 90 jboolean jlog_all); | 90 jboolean jlog_all); |
| 91 | 91 |
| 92 // Starts NetLog logging to disk with a bounded amount of disk space. This | 92 // Starts NetLog logging to disk with a bounded amount of disk space. This |
| 93 // can be called on any thread. | 93 // can be called on any thread. |
| 94 void StartNetLogToDisk(JNIEnv* env, | 94 void StartNetLogToDisk(JNIEnv* env, |
| 95 const base::android::JavaParamRef<jobject>& jcaller, | 95 const base::android::JavaParamRef<jobject>& jcaller, |
| 96 const base::android::JavaParamRef<jstring>& jdir_name, | 96 const base::android::JavaParamRef<jstring>& jdir_name, |
| 97 jboolean jlog_all, | 97 jboolean jlog_all, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void OnThroughputObservation( | 192 void OnThroughputObservation( |
| 193 int32_t throughput_kbps, | 193 int32_t throughput_kbps, |
| 194 const base::TimeTicks& timestamp, | 194 const base::TimeTicks& timestamp, |
| 195 net::NetworkQualityObservationSource source) override; | 195 net::NetworkQualityObservationSource source) override; |
| 196 | 196 |
| 197 // Same as StartNetLogToDisk, but called only on the network thread. | 197 // Same as StartNetLogToDisk, but called only on the network thread. |
| 198 void StartNetLogToBoundedFileOnNetworkThread(const std::string& dir_path, | 198 void StartNetLogToBoundedFileOnNetworkThread(const std::string& dir_path, |
| 199 bool include_socket_bytes, | 199 bool include_socket_bytes, |
| 200 int size); | 200 int size); |
| 201 | 201 |
| 202 // Stops NetLog logging to file by calling StopObserving() and destroying | 202 // Same as StartNetLogToFile, but called only on the network thread. |
| 203 // the |bounded_file_observer_|. | 203 void StartNetLogOnNetworkThread(const std::string& file_name, |
| 204 void StopBoundedFileNetLogOnNetworkThread(); | 204 bool include_socket_bytes); |
| 205 |
| 206 // Stops NetLog logging on the network thread. |
| 207 void StopNetLogOnNetworkThread(); |
| 205 | 208 |
| 206 // Callback for StopObserving() that unblocks the Java ConditionVariable and | 209 // Callback for StopObserving() that unblocks the Java ConditionVariable and |
| 207 // signals that it is safe to access the NetLog files. | 210 // signals that it is safe to access the NetLog files. |
| 208 void StopNetLogCompleted(); | 211 void StopNetLogCompleted(); |
| 209 | 212 |
| 210 // Helper method to stop NetLog logging to file. This can be called on any | 213 std::unique_ptr<base::DictionaryValue> GetNetLogInfo() const; |
| 211 // thread. This will flush any remaining writes to disk. | |
| 212 void StopNetLogHelper(); | |
| 213 | 214 |
| 214 // Network thread is owned by |this|, but is destroyed from java thread. | 215 // Network thread is owned by |this|, but is destroyed from java thread. |
| 215 base::Thread* network_thread_; | 216 base::Thread* network_thread_; |
| 216 | 217 |
| 217 // File thread should be destroyed last. | 218 // File thread should be destroyed last. |
| 218 std::unique_ptr<base::Thread> file_thread_; | 219 std::unique_ptr<base::Thread> file_thread_; |
| 219 | 220 |
| 220 // |write_to_file_observer_| should only be accessed with | 221 std::unique_ptr<net::FileNetLogObserver> net_log_file_observer_; |
| 221 // |write_to_file_observer_lock_|. | |
| 222 std::unique_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_; | |
| 223 base::Lock write_to_file_observer_lock_; | |
| 224 | |
| 225 std::unique_ptr<net::FileNetLogObserver> bounded_file_observer_; | |
| 226 | 222 |
| 227 // |pref_service_| should outlive the HttpServerPropertiesManager owned by | 223 // |pref_service_| should outlive the HttpServerPropertiesManager owned by |
| 228 // |context_|. | 224 // |context_|. |
| 229 std::unique_ptr<PrefService> pref_service_; | 225 std::unique_ptr<PrefService> pref_service_; |
| 230 std::unique_ptr<net::URLRequestContext> context_; | 226 std::unique_ptr<net::URLRequestContext> context_; |
| 231 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; | 227 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; |
| 232 scoped_refptr<JsonPrefStore> json_pref_store_; | 228 scoped_refptr<JsonPrefStore> json_pref_store_; |
| 233 net::HttpServerPropertiesManager* http_server_properties_manager_; | 229 net::HttpServerPropertiesManager* http_server_properties_manager_; |
| 234 | 230 |
| 235 // |sdch_owner_| should be destroyed before |json_pref_store_|, because | 231 // |sdch_owner_| should be destroyed before |json_pref_store_|, because |
| 236 // tearing down |sdch_owner_| forces |json_pref_store_| to flush pending | 232 // tearing down |sdch_owner_| forces |json_pref_store_| to flush pending |
| 237 // writes to the disk. | 233 // writes to the disk. |
| 238 std::unique_ptr<net::SdchOwner> sdch_owner_; | 234 std::unique_ptr<net::SdchOwner> sdch_owner_; |
| 239 | 235 |
| 240 // Context config is only valid until context is initialized. | 236 // Context config is only valid until context is initialized. |
| 241 std::unique_ptr<URLRequestContextConfig> context_config_; | 237 std::unique_ptr<URLRequestContextConfig> context_config_; |
| 242 | 238 |
| 239 // Effective experimental options. Kept for NetLog. |
| 240 std::unique_ptr<base::DictionaryValue> effective_experimental_options_; |
| 241 |
| 243 // A queue of tasks that need to be run after context has been initialized. | 242 // A queue of tasks that need to be run after context has been initialized. |
| 244 std::queue<base::Closure> tasks_waiting_for_context_; | 243 std::queue<base::Closure> tasks_waiting_for_context_; |
| 245 bool is_context_initialized_; | 244 bool is_context_initialized_; |
| 246 int default_load_flags_; | 245 int default_load_flags_; |
| 247 | 246 |
| 248 // A network quality estimator. | 247 // A network quality estimator. |
| 249 std::unique_ptr<net::NetworkQualityEstimator> network_quality_estimator_; | 248 std::unique_ptr<net::NetworkQualityEstimator> network_quality_estimator_; |
| 250 | 249 |
| 251 // Manages the writing and reading of the network quality prefs. | 250 // Manages the writing and reading of the network quality prefs. |
| 252 std::unique_ptr<net::NetworkQualitiesPrefsManager> | 251 std::unique_ptr<net::NetworkQualitiesPrefsManager> |
| 253 network_qualities_prefs_manager_; | 252 network_qualities_prefs_manager_; |
| 254 | 253 |
| 255 // Java object that owns this CronetURLRequestContextAdapter. | 254 // Java object that owns this CronetURLRequestContextAdapter. |
| 256 base::android::ScopedJavaGlobalRef<jobject> jcronet_url_request_context_; | 255 base::android::ScopedJavaGlobalRef<jobject> jcronet_url_request_context_; |
| 257 | 256 |
| 258 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 257 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
| 259 std::unique_ptr<CronetDataReductionProxy> data_reduction_proxy_; | 258 std::unique_ptr<CronetDataReductionProxy> data_reduction_proxy_; |
| 260 #endif | 259 #endif |
| 261 | 260 |
| 262 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); | 261 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); |
| 263 }; | 262 }; |
| 264 | 263 |
| 265 } // namespace cronet | 264 } // namespace cronet |
| 266 | 265 |
| 267 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 266 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| OLD | NEW |