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_URL_REQUEST_CONTEXT_ADAPTER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ |
6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
18 #include "net/base/net_log.h" | 18 #include "net/base/net_log.h" |
19 #include "net/base/network_change_notifier.h" | 19 #include "net/base/network_change_notifier.h" |
20 #include "net/proxy/proxy_config_service.h" | |
20 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
21 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
22 | 23 |
23 namespace net { | 24 namespace net { |
24 class NetLogLogger; | 25 class NetLogLogger; |
25 } // namespace net | 26 } // namespace net |
26 | 27 |
27 namespace cronet { | 28 namespace cronet { |
28 | 29 |
29 struct URLRequestContextConfig; | 30 struct URLRequestContextConfig; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 | 73 |
73 const std::string& GetUserAgent(const GURL& url) const; | 74 const std::string& GetUserAgent(const GURL& url) const; |
74 | 75 |
75 // net::URLRequestContextGetter implementation: | 76 // net::URLRequestContextGetter implementation: |
76 virtual net::URLRequestContext* GetURLRequestContext() override; | 77 virtual net::URLRequestContext* GetURLRequestContext() override; |
77 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 78 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
78 const override; | 79 const override; |
79 | 80 |
80 void StartNetLogToFile(const std::string& file_name); | 81 void StartNetLogToFile(const std::string& file_name); |
81 void StopNetLog(); | 82 void StopNetLog(); |
83 // Called by main java UI thread to initialize URLRequestContext. | |
mef
2014/10/10 21:20:37
Called _on_ main...
xunjieli
2014/10/14 19:14:48
Done.
| |
84 void InitRequestContextOnUIThread(); | |
82 | 85 |
83 private: | 86 private: |
84 scoped_refptr<URLRequestContextAdapterDelegate> delegate_; | 87 scoped_refptr<URLRequestContextAdapterDelegate> delegate_; |
85 scoped_ptr<net::URLRequestContext> context_; | 88 scoped_ptr<net::URLRequestContext> context_; |
86 std::string user_agent_; | 89 std::string user_agent_; |
87 base::Thread* network_thread_; | 90 base::Thread* network_thread_; |
88 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 91 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
89 scoped_ptr<NetLogObserver> net_log_observer_; | 92 scoped_ptr<NetLogObserver> net_log_observer_; |
90 scoped_ptr<net::NetLogLogger> net_log_logger_; | 93 scoped_ptr<net::NetLogLogger> net_log_logger_; |
94 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | |
95 scoped_ptr<URLRequestContextConfig> config_; | |
91 | 96 |
92 // A queue of tasks that need to be run after context has been initialized. | 97 // A queue of tasks that need to be run after context has been initialized. |
93 std::queue<RunAfterContextInitTask> tasks_waiting_for_context_; | 98 std::queue<RunAfterContextInitTask> tasks_waiting_for_context_; |
94 bool is_context_initialized_; | 99 bool is_context_initialized_; |
95 | 100 |
96 virtual ~URLRequestContextAdapter(); | 101 virtual ~URLRequestContextAdapter(); |
97 | 102 |
98 // Initializes |context_| on the Network thread. | 103 // Initializes |context_| on the Network thread. |
99 void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config); | 104 void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config); |
100 | 105 |
101 // Helper function to start writing NetLog data to file. This should only be | 106 // Helper function to start writing NetLog data to file. This should only be |
102 // run after context is initialized. | 107 // run after context is initialized. |
103 void StartNetLogToFileHelper(const std::string& file_name); | 108 void StartNetLogToFileHelper(const std::string& file_name); |
104 // Helper function to stop writing NetLog data to file. This should only be | 109 // Helper function to stop writing NetLog data to file. This should only be |
105 // run after context is initialized. | 110 // run after context is initialized. |
106 void StopNetLogHelper(); | 111 void StopNetLogHelper(); |
107 | 112 |
108 DISALLOW_COPY_AND_ASSIGN(URLRequestContextAdapter); | 113 DISALLOW_COPY_AND_ASSIGN(URLRequestContextAdapter); |
109 }; | 114 }; |
110 | 115 |
111 } // namespace cronet | 116 } // namespace cronet |
112 | 117 |
113 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ | 118 #endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_ |
OLD | NEW |