| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_IOS_CRONET_ENVIRONMENT_H_ | 5 #ifndef COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_ |
| 6 #define COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_ | 6 #define COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 namespace cronet { | 37 namespace cronet { |
| 38 // CronetEnvironment contains all the network stack configuration | 38 // CronetEnvironment contains all the network stack configuration |
| 39 // and initialization. | 39 // and initialization. |
| 40 class CronetEnvironment { | 40 class CronetEnvironment { |
| 41 public: | 41 public: |
| 42 // Initialize Cronet environment globals. Must be called only once on the | 42 // Initialize Cronet environment globals. Must be called only once on the |
| 43 // main thread. | 43 // main thread. |
| 44 static void Initialize(); | 44 static void Initialize(); |
| 45 | 45 |
| 46 // |user_agent| will be used to generate the user-agent if | 46 // |user_agent| will be used to generate the user-agent if |
| 47 // |user_agent_partial| | 47 // |user_agent_partial| is true, or will be used as the complete user-agent |
| 48 // is true, or will be used as complete user-agent otherwise. | 48 // otherwise. |
| 49 CronetEnvironment(const std::string& user_agent, bool user_agent_partial); | 49 CronetEnvironment(const std::string& user_agent, bool user_agent_partial); |
| 50 ~CronetEnvironment(); | 50 ~CronetEnvironment(); |
| 51 | 51 |
| 52 // Starts this instance of Cronet environment. | 52 // Starts this instance of Cronet environment. |
| 53 void Start(); | 53 void Start(); |
| 54 | 54 |
| 55 // The full user-agent. | 55 // The full user-agent. |
| 56 std::string user_agent(); | 56 std::string user_agent(); |
| 57 | 57 |
| 58 // Get global UMA histogram deltas. | 58 // Get global UMA histogram deltas. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 77 bool quic_enabled() const { return quic_enabled_; } | 77 bool quic_enabled() const { return quic_enabled_; } |
| 78 | 78 |
| 79 void set_accept_language(const std::string& accept_language) { | 79 void set_accept_language(const std::string& accept_language) { |
| 80 accept_language_ = accept_language; | 80 accept_language_ = accept_language; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void set_cert_verifier(std::unique_ptr<net::CertVerifier> cert_verifier) { | 83 void set_cert_verifier(std::unique_ptr<net::CertVerifier> cert_verifier) { |
| 84 cert_verifier_ = std::move(cert_verifier); | 84 cert_verifier_ = std::move(cert_verifier); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void set_host_resolver_rules(const std::string& host_resolver_rules) { | 87 void SetHostResolverRules(const std::string& host_resolver_rules); |
| 88 host_resolver_rules_ = host_resolver_rules; | |
| 89 } | |
| 90 | 88 |
| 91 void set_ssl_key_log_file_name(const std::string& ssl_key_log_file_name) { | 89 void set_ssl_key_log_file_name(const std::string& ssl_key_log_file_name) { |
| 92 ssl_key_log_file_name_ = ssl_key_log_file_name; | 90 ssl_key_log_file_name_ = ssl_key_log_file_name; |
| 93 } | 91 } |
| 94 | 92 |
| 93 // Returns the URLRequestContext associated with this object. |
| 95 net::URLRequestContext* GetURLRequestContext() const; | 94 net::URLRequestContext* GetURLRequestContext() const; |
| 96 | 95 |
| 96 // Return the URLRequestContextGetter associated with this object. |
| 97 net::URLRequestContextGetter* GetURLRequestContextGetter() const; | 97 net::URLRequestContextGetter* GetURLRequestContextGetter() const; |
| 98 | 98 |
| 99 bool IsOnNetworkThread(); | 99 private: |
| 100 // Performs initialization tasks that must happen on the network thread. |
| 101 void InitializeOnNetworkThread(); |
| 100 | 102 |
| 101 // Runs a closure on the network thread. | 103 // Runs a closure on the network thread. |
| 102 void PostToNetworkThread(const tracked_objects::Location& from_here, | 104 void PostToNetworkThread(const tracked_objects::Location& from_here, |
| 103 const base::Closure& task); | 105 const base::Closure& task); |
| 104 | 106 |
| 105 private: | |
| 106 // Performs initialization tasks that must happen on the network thread. | |
| 107 void InitializeOnNetworkThread(); | |
| 108 | |
| 109 // Runs a closure on the file user blocking thread. | 107 // Runs a closure on the file user blocking thread. |
| 110 void PostToFileUserBlockingThread(const tracked_objects::Location& from_here, | 108 void PostToFileUserBlockingThread(const tracked_objects::Location& from_here, |
| 111 const base::Closure& task); | 109 const base::Closure& task); |
| 112 | 110 |
| 113 // Helper methods that start/stop net logging on the network thread. | 111 // Helper methods that start/stop net logging on the network thread. |
| 114 void StartNetLogOnNetworkThread(const base::FilePath::StringType& file_name, | 112 void StartNetLogOnNetworkThread(const base::FilePath::StringType& file_name, |
| 115 bool log_bytes); | 113 bool log_bytes); |
| 116 void StopNetLogOnNetworkThread(base::WaitableEvent* log_stopped_event); | 114 void StopNetLogOnNetworkThread(base::WaitableEvent* log_stopped_event); |
| 117 | 115 |
| 118 // Returns the HttpNetworkSession object from the passed in | 116 // Returns the HttpNetworkSession object from the passed in |
| 119 // URLRequestContext or NULL if none exists. | 117 // URLRequestContext or NULL if none exists. |
| 120 net::HttpNetworkSession* GetHttpNetworkSession( | 118 net::HttpNetworkSession* GetHttpNetworkSession( |
| 121 net::URLRequestContext* context); | 119 net::URLRequestContext* context); |
| 122 | 120 |
| 121 // Sets host resolver rules on the network_io_thread_. |
| 122 void SetHostResolverRulesOnNetworkThread(const std::string& rules, |
| 123 base::WaitableEvent* event); |
| 124 |
| 123 bool http2_enabled_; | 125 bool http2_enabled_; |
| 124 bool quic_enabled_; | 126 bool quic_enabled_; |
| 125 std::string accept_language_; | 127 std::string accept_language_; |
| 126 std::string host_resolver_rules_; | |
| 127 std::string ssl_key_log_file_name_; | 128 std::string ssl_key_log_file_name_; |
| 128 | 129 |
| 129 std::list<net::HostPortPair> quic_hints_; | 130 std::list<net::HostPortPair> quic_hints_; |
| 130 | 131 |
| 131 std::unique_ptr<base::Thread> network_io_thread_; | 132 std::unique_ptr<base::Thread> network_io_thread_; |
| 132 std::unique_ptr<base::Thread> network_cache_thread_; | 133 std::unique_ptr<base::Thread> network_cache_thread_; |
| 133 std::unique_ptr<base::Thread> file_thread_; | 134 std::unique_ptr<base::Thread> file_thread_; |
| 134 std::unique_ptr<base::Thread> file_user_blocking_thread_; | 135 std::unique_ptr<base::Thread> file_user_blocking_thread_; |
| 135 scoped_refptr<base::SequencedTaskRunner> pref_store_worker_pool_; | 136 scoped_refptr<base::SequencedTaskRunner> pref_store_worker_pool_; |
| 136 scoped_refptr<JsonPrefStore> net_pref_store_; | 137 scoped_refptr<JsonPrefStore> net_pref_store_; |
| 137 std::unique_ptr<net::CertVerifier> cert_verifier_; | 138 std::unique_ptr<net::CertVerifier> cert_verifier_; |
| 138 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; | 139 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; |
| 139 std::unique_ptr<net::HttpServerProperties> http_server_properties_; | 140 std::unique_ptr<net::HttpServerProperties> http_server_properties_; |
| 140 std::unique_ptr<net::URLRequestContext> main_context_; | 141 std::unique_ptr<net::URLRequestContext> main_context_; |
| 141 scoped_refptr<net::URLRequestContextGetter> main_context_getter_; | 142 scoped_refptr<net::URLRequestContextGetter> main_context_getter_; |
| 142 std::string user_agent_; | 143 std::string user_agent_; |
| 143 bool user_agent_partial_; | 144 bool user_agent_partial_; |
| 144 std::unique_ptr<net::NetLog> net_log_; | 145 std::unique_ptr<net::NetLog> net_log_; |
| 145 std::unique_ptr<net::WriteToFileNetLogObserver> net_log_observer_; | 146 std::unique_ptr<net::WriteToFileNetLogObserver> net_log_observer_; |
| 146 | 147 |
| 147 DISALLOW_COPY_AND_ASSIGN(CronetEnvironment); | 148 DISALLOW_COPY_AND_ASSIGN(CronetEnvironment); |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 } // namespace cronet | 151 } // namespace cronet |
| 151 | 152 |
| 152 #endif // COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_ | 153 #endif // COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_ |
| OLD | NEW |