Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: components/cronet/ios/cronet_environment.h

Issue 1858483002: Cronet for iOS with C API for GRPC support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@small
Patch Set: Address comments, bundle libboringssl.a into libcronet.a Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/cronet/ios/cronet_c_for_grpc.cc ('k') | components/cronet/ios/cronet_environment.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_
6 #define COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_
7
8 #include <list>
9
10 #include "base/files/file_path.h"
11 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/synchronization/waitable_event.h"
14 #include "base/threading/thread.h"
15 #include "components/cronet/url_request_context_config.h"
16 #include "net/cert/cert_verifier.h"
17 #include "net/url_request/url_request.h"
18 #include "net/url_request/url_request_context.h"
19
20 class JsonPrefStore;
21
22 namespace base {
23 class WaitableEvent;
24 } // namespace base
25
26 namespace net {
27 class HttpCache;
28 class NetworkChangeNotifier;
29 class NetLog;
30 class ProxyConfigService;
31 class WriteToFileNetLogObserver;
32 } // namespace net
33
34 namespace cronet {
35 // CronetEnvironment contains all the network stack configuration
36 // and initialization.
37 class CronetEnvironment {
38 public:
39 // Initialize Cronet environment globals. Must be called only once on the
40 // main thread.
41 static void Initialize();
42
43 // |user_agent_product_name| will be used to generate the user-agent.
44 CronetEnvironment(const std::string& user_agent_product_name);
45 ~CronetEnvironment();
46
47 // Starts this instance of Cronet environment.
48 void Start();
49
50 // The full user-agent.
51 std::string user_agent();
52
53 // Creates a new net log (overwrites existing file with this name). If
54 // actively logging, this call is ignored.
55 void StartNetLog(base::FilePath::StringType file_name, bool log_bytes);
56 // Stops logging and flushes file. If not currently logging this call is
57 // ignored.
58 void StopNetLog();
59
60 void AddQuicHint(const std::string& host, int port, int alternate_port);
61
62 // Setters and getters for |http2_enabled_|, |quic_enabled_|, and
63 // |forced_quic_origin_|. These only have any effect before Start() is
64 // called.
65 void set_http2_enabled(bool enabled) { http2_enabled_ = enabled; }
66 void set_quic_enabled(bool enabled) { quic_enabled_ = enabled; }
67
68 bool http2_enabled() const { return http2_enabled_; }
69 bool quic_enabled() const { return quic_enabled_; }
70
71 void set_cert_verifier(scoped_ptr<net::CertVerifier> cert_verifier) {
72 cert_verifier_ = std::move(cert_verifier);
73 }
74
75 void set_host_resolver_rules(const std::string& host_resolver_rules) {
76 host_resolver_rules_ = host_resolver_rules;
77 }
78
79 void set_ssl_key_log_file_name(const std::string& ssl_key_log_file_name) {
80 ssl_key_log_file_name_ = ssl_key_log_file_name;
81 }
82
83 net::URLRequestContext* GetURLRequestContext() const;
84
85 bool IsOnNetworkThread();
86
87 // Runs a closure on the network thread.
88 void PostToNetworkThread(const tracked_objects::Location& from_here,
89 const base::Closure& task);
90
91 private:
92 // Performs initialization tasks that must happen on the network thread.
93 void InitializeOnNetworkThread();
94
95 // Runs a closure on the file user blocking thread.
96 void PostToFileUserBlockingThread(const tracked_objects::Location& from_here,
97 const base::Closure& task);
98
99 // Helper methods that start/stop net logging on the network thread.
100 void StartNetLogOnNetworkThread(const base::FilePath::StringType& file_name,
101 bool log_bytes);
102 void StopNetLogOnNetworkThread(base::WaitableEvent* log_stopped_event);
103
104 // Returns the HttpNetworkSession object from the passed in
105 // URLRequestContext or NULL if none exists.
106 net::HttpNetworkSession* GetHttpNetworkSession(
107 net::URLRequestContext* context);
108
109 bool http2_enabled_;
110 bool quic_enabled_;
111 std::string host_resolver_rules_;
112 std::string ssl_key_log_file_name_;
113
114 std::list<net::HostPortPair> quic_hints_;
115
116 scoped_ptr<base::Thread> network_io_thread_;
117 scoped_ptr<base::Thread> network_cache_thread_;
118 scoped_ptr<base::Thread> file_thread_;
119 scoped_ptr<base::Thread> file_user_blocking_thread_;
120 scoped_refptr<base::SequencedTaskRunner> pref_store_worker_pool_;
121 scoped_refptr<JsonPrefStore> net_pref_store_;
122 scoped_ptr<net::CertVerifier> cert_verifier_;
123 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
124 scoped_ptr<net::HttpServerProperties> http_server_properties_;
125 scoped_ptr<net::URLRequestContext> main_context_;
126 std::string user_agent_product_name_;
127 scoped_ptr<net::NetLog> net_log_;
128 scoped_ptr<net::WriteToFileNetLogObserver> net_log_observer_;
129
130 DISALLOW_COPY_AND_ASSIGN(CronetEnvironment);
131 };
132
133 } // namespace cronet
134
135 #endif // COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_
OLDNEW
« no previous file with comments | « components/cronet/ios/cronet_c_for_grpc.cc ('k') | components/cronet/ios/cronet_environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698