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