| 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 |
| 86 // Starts NetLog logging to file. This can be called on any thread. |
| 87 // Return false if |jfile_name| cannot be opened. |
| 87 bool StartNetLogToFile(JNIEnv* env, | 88 bool StartNetLogToFile(JNIEnv* env, |
| 88 const base::android::JavaParamRef<jobject>& jcaller, | 89 const base::android::JavaParamRef<jobject>& jcaller, |
| 89 const base::android::JavaParamRef<jstring>& jfile_name, | 90 const base::android::JavaParamRef<jstring>& jfile_name, |
| 90 jboolean jlog_all); | 91 jboolean jlog_all); |
| 91 | 92 |
| 92 // Starts NetLog logging to disk with a bounded amount of disk space. This | 93 // Starts NetLog logging to disk with a bounded amount of disk space. This |
| 93 // can be called on any thread. | 94 // can be called on any thread. |
| 94 void StartNetLogToDisk(JNIEnv* env, | 95 void StartNetLogToDisk(JNIEnv* env, |
| 95 const base::android::JavaParamRef<jobject>& jcaller, | 96 const base::android::JavaParamRef<jobject>& jcaller, |
| 96 const base::android::JavaParamRef<jstring>& jdir_name, | 97 const base::android::JavaParamRef<jstring>& jdir_name, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void OnThroughputObservation( | 193 void OnThroughputObservation( |
| 193 int32_t throughput_kbps, | 194 int32_t throughput_kbps, |
| 194 const base::TimeTicks& timestamp, | 195 const base::TimeTicks& timestamp, |
| 195 net::NetworkQualityObservationSource source) override; | 196 net::NetworkQualityObservationSource source) override; |
| 196 | 197 |
| 197 // Same as StartNetLogToDisk, but called only on the network thread. | 198 // Same as StartNetLogToDisk, but called only on the network thread. |
| 198 void StartNetLogToBoundedFileOnNetworkThread(const std::string& dir_path, | 199 void StartNetLogToBoundedFileOnNetworkThread(const std::string& dir_path, |
| 199 bool include_socket_bytes, | 200 bool include_socket_bytes, |
| 200 int size); | 201 int size); |
| 201 | 202 |
| 202 // Stops NetLog logging to file by calling StopObserving() and destroying | 203 // Same as StartNetLogToFile, but called only on the network thread. |
| 203 // the |bounded_file_observer_|. | 204 void StartNetLogOnNetworkThread(const base::FilePath& file_path, |
| 204 void StopBoundedFileNetLogOnNetworkThread(); | 205 bool include_socket_bytes); |
| 206 |
| 207 // Stops NetLog logging on the network thread. |
| 208 void StopNetLogOnNetworkThread(); |
| 205 | 209 |
| 206 // Callback for StopObserving() that unblocks the Java ConditionVariable and | 210 // Callback for StopObserving() that unblocks the Java ConditionVariable and |
| 207 // signals that it is safe to access the NetLog files. | 211 // signals that it is safe to access the NetLog files. |
| 208 void StopNetLogCompleted(); | 212 void StopNetLogCompleted(); |
| 209 | 213 |
| 210 // Helper method to stop NetLog logging to file. This can be called on any | 214 std::unique_ptr<base::DictionaryValue> GetNetLogInfo() const; |
| 211 // thread. This will flush any remaining writes to disk. | |
| 212 void StopNetLogHelper(); | |
| 213 | 215 |
| 214 // Network thread is owned by |this|, but is destroyed from java thread. | 216 // Network thread is owned by |this|, but is destroyed from java thread. |
| 215 base::Thread* network_thread_; | 217 base::Thread* network_thread_; |
| 216 | 218 |
| 217 // File thread should be destroyed last. | 219 // File thread should be destroyed last. |
| 218 std::unique_ptr<base::Thread> file_thread_; | 220 std::unique_ptr<base::Thread> file_thread_; |
| 219 | 221 |
| 220 // |write_to_file_observer_| should only be accessed with | 222 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 | 223 |
| 227 // |pref_service_| should outlive the HttpServerPropertiesManager owned by | 224 // |pref_service_| should outlive the HttpServerPropertiesManager owned by |
| 228 // |context_|. | 225 // |context_|. |
| 229 std::unique_ptr<PrefService> pref_service_; | 226 std::unique_ptr<PrefService> pref_service_; |
| 230 std::unique_ptr<net::URLRequestContext> context_; | 227 std::unique_ptr<net::URLRequestContext> context_; |
| 231 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; | 228 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; |
| 232 scoped_refptr<JsonPrefStore> json_pref_store_; | 229 scoped_refptr<JsonPrefStore> json_pref_store_; |
| 233 net::HttpServerPropertiesManager* http_server_properties_manager_; | 230 net::HttpServerPropertiesManager* http_server_properties_manager_; |
| 234 | 231 |
| 235 // |sdch_owner_| should be destroyed before |json_pref_store_|, because | 232 // |sdch_owner_| should be destroyed before |json_pref_store_|, because |
| 236 // tearing down |sdch_owner_| forces |json_pref_store_| to flush pending | 233 // tearing down |sdch_owner_| forces |json_pref_store_| to flush pending |
| 237 // writes to the disk. | 234 // writes to the disk. |
| 238 std::unique_ptr<net::SdchOwner> sdch_owner_; | 235 std::unique_ptr<net::SdchOwner> sdch_owner_; |
| 239 | 236 |
| 240 // Context config is only valid until context is initialized. | 237 // Context config is only valid until context is initialized. |
| 241 std::unique_ptr<URLRequestContextConfig> context_config_; | 238 std::unique_ptr<URLRequestContextConfig> context_config_; |
| 242 | 239 |
| 240 // Effective experimental options. Kept for NetLog. |
| 241 std::unique_ptr<base::DictionaryValue> effective_experimental_options_; |
| 242 |
| 243 // A queue of tasks that need to be run after context has been initialized. | 243 // A queue of tasks that need to be run after context has been initialized. |
| 244 std::queue<base::Closure> tasks_waiting_for_context_; | 244 std::queue<base::Closure> tasks_waiting_for_context_; |
| 245 bool is_context_initialized_; | 245 bool is_context_initialized_; |
| 246 int default_load_flags_; | 246 int default_load_flags_; |
| 247 | 247 |
| 248 // A network quality estimator. | 248 // A network quality estimator. |
| 249 std::unique_ptr<net::NetworkQualityEstimator> network_quality_estimator_; | 249 std::unique_ptr<net::NetworkQualityEstimator> network_quality_estimator_; |
| 250 | 250 |
| 251 // Manages the writing and reading of the network quality prefs. | 251 // Manages the writing and reading of the network quality prefs. |
| 252 std::unique_ptr<net::NetworkQualitiesPrefsManager> | 252 std::unique_ptr<net::NetworkQualitiesPrefsManager> |
| 253 network_qualities_prefs_manager_; | 253 network_qualities_prefs_manager_; |
| 254 | 254 |
| 255 // Java object that owns this CronetURLRequestContextAdapter. | 255 // Java object that owns this CronetURLRequestContextAdapter. |
| 256 base::android::ScopedJavaGlobalRef<jobject> jcronet_url_request_context_; | 256 base::android::ScopedJavaGlobalRef<jobject> jcronet_url_request_context_; |
| 257 | 257 |
| 258 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 258 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
| 259 std::unique_ptr<CronetDataReductionProxy> data_reduction_proxy_; | 259 std::unique_ptr<CronetDataReductionProxy> data_reduction_proxy_; |
| 260 #endif | 260 #endif |
| 261 | 261 |
| 262 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); | 262 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); |
| 263 }; | 263 }; |
| 264 | 264 |
| 265 } // namespace cronet | 265 } // namespace cronet |
| 266 | 266 |
| 267 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 267 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| OLD | NEW |