| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/prefs/json_pref_store.h" |
| 18 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
| 22 } // namespace base | 23 } // namespace base |
| 23 | 24 |
| 24 namespace net { | 25 namespace net { |
| 25 class WriteToFileNetLogObserver; | 26 class WriteToFileNetLogObserver; |
| 26 class URLRequestContext; | 27 class URLRequestContext; |
| 27 class ProxyConfigService; | 28 class ProxyConfigService; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 void RunTaskAfterContextInitOnNetworkThread( | 85 void RunTaskAfterContextInitOnNetworkThread( |
| 85 const base::Closure& task_to_run_after_context_init); | 86 const base::Closure& task_to_run_after_context_init); |
| 86 | 87 |
| 87 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const; | 88 scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() const; |
| 88 | 89 |
| 89 void StartNetLogToFileOnNetworkThread(const std::string& file_name, | 90 void StartNetLogToFileOnNetworkThread(const std::string& file_name, |
| 90 bool log_all); | 91 bool log_all); |
| 91 | 92 |
| 92 void StopNetLogOnNetworkThread(); | 93 void StopNetLogOnNetworkThread(); |
| 93 | 94 |
| 95 // Gets the file thread. Create one if there is none. |
| 96 base::Thread* GetFileThread(); |
| 97 |
| 94 // Network thread is owned by |this|, but is destroyed from java thread. | 98 // Network thread is owned by |this|, but is destroyed from java thread. |
| 95 base::Thread* network_thread_; | 99 base::Thread* network_thread_; |
| 100 |
| 101 // File thread should be destroyed last. |
| 102 scoped_ptr<base::Thread> file_thread_; |
| 103 |
| 96 // |write_to_file_observer_| and |context_| should only be accessed on | 104 // |write_to_file_observer_| and |context_| should only be accessed on |
| 97 // network thread. | 105 // network thread. |
| 98 scoped_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_; | 106 scoped_ptr<net::WriteToFileNetLogObserver> write_to_file_observer_; |
| 99 scoped_ptr<net::URLRequestContext> context_; | 107 scoped_ptr<net::URLRequestContext> context_; |
| 100 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | 108 scoped_ptr<net::ProxyConfigService> proxy_config_service_; |
| 109 |
| 110 // |sdch_owner_| should be destroyed before |json_pref_store_|, because |
| 111 // tearing down |sdch_owner_| forces |json_pref_store_| to flush pending |
| 112 // writes to the disk. |
| 113 scoped_refptr<JsonPrefStore> json_pref_store_; |
| 101 scoped_ptr<net::SdchOwner> sdch_owner_; | 114 scoped_ptr<net::SdchOwner> sdch_owner_; |
| 102 | 115 |
| 103 // Context config is only valid untng context is initialized. | 116 // Context config is only valid untng context is initialized. |
| 104 scoped_ptr<URLRequestContextConfig> context_config_; | 117 scoped_ptr<URLRequestContextConfig> context_config_; |
| 105 | 118 |
| 106 // A queue of tasks that need to be run after context has been initialized. | 119 // A queue of tasks that need to be run after context has been initialized. |
| 107 std::queue<base::Closure> tasks_waiting_for_context_; | 120 std::queue<base::Closure> tasks_waiting_for_context_; |
| 108 bool is_context_initialized_; | 121 bool is_context_initialized_; |
| 109 int default_load_flags_; | 122 int default_load_flags_; |
| 110 | 123 |
| 111 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 124 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
| 112 scoped_ptr<CronetDataReductionProxy> data_reduction_proxy_; | 125 scoped_ptr<CronetDataReductionProxy> data_reduction_proxy_; |
| 113 #endif | 126 #endif |
| 114 | 127 |
| 115 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); | 128 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); |
| 116 }; | 129 }; |
| 117 | 130 |
| 118 } // namespace cronet | 131 } // namespace cronet |
| 119 | 132 |
| 120 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 133 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| OLD | NEW |