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

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: Make cronet_environment a cc. 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
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 "net/cert/cert_verifier.h"
16 #include "net/url_request/url_request.h"
17 #include "net/url_request/url_request_context.h"
18
19 class JsonPrefStore;
20
21 namespace net {
22 class HttpCache;
23 class NetworkChangeNotifier;
24 class NetLog;
25 class ProxyConfigService;
26 class WriteToFileNetLogObserver;
27 }
28
29 namespace cronet {
30 // CronetEnvironment contains all the network stack configuration
31 // and initialization.
32 class CronetEnvironment {
33 public:
34 // Must be called on the main thread.
35 static void Initialize();
36
37 // |user_agent_product_name| will be used to generate the user-agent.
38 CronetEnvironment(const std::string& user_agent_product_name);
39 ~CronetEnvironment();
40
41 // Installs this CrNet environment so requests are intercepted.
42 // Can only be called once; to enable/disable CrNet at runtime, use
43 // SetHTTPProtocolHandlerRegistered.
kapishnikov 2016/04/06 17:33:25 I think the comments should not mention the handle
mef 2016/04/08 15:13:01 Done.
44 void Install();
45
46 // The full user-agent.
47 std::string user_agent();
48
49 // Creates a new net log (overwrites existing file with this name). If
50 // actively logging, this call is ignored.
51 void StartNetLog(base::FilePath::StringType file_name, bool log_bytes);
52 // Stops logging and flushes file. If not currently logging this call is
53 // ignored.
54 void StopNetLog();
55
56 void AddQuicHint(const std::string& host, int port, int alternate_port);
57
58 // Setters and getters for |http2_enabled_|, |quic_enabled_|, and
59 // |forced_quic_origin_|. These only have any effect before Install() is
60 // called.
61 void set_http2_enabled(bool enabled) { http2_enabled_ = enabled; }
62 void set_quic_enabled(bool enabled) { quic_enabled_ = enabled; }
63
64 bool http2_enabled() const { return http2_enabled_; }
65 bool quic_enabled() const { return quic_enabled_; }
66
67 net::URLRequestContext* GetURLRequestContext() const;
68
69 bool IsOnNetworkThread();
70
71 // Runs a closure on the network thread.
72 void PostToNetworkThread(const tracked_objects::Location& from_here,
73 const base::Closure& task);
74
75 void set_cert_verifier(scoped_ptr<net::CertVerifier> cert_verifier) {
76 cert_verifier_ = std::move(cert_verifier);
77 }
78
79 void set_host_resolver_rules(const std::string& host_resolver_rules) {
80 host_resolver_rules_ = host_resolver_rules;
81 }
82
83 void set_ssl_key_log_file_name(const std::string& ssl_key_log_file_name) {
84 ssl_key_log_file_name_ = ssl_key_log_file_name;
85 }
86
87 private:
88 // Performs initialization tasks that must happen on the network thread.
89 void InitializeOnNetworkThread();
90
91 // Runs a closure on the file user blocking thread.
92 void PostToFileUserBlockingThread(const tracked_objects::Location& from_here,
93 const base::Closure& task);
94
95 // Helper methods that start/stop net-internals logging on the file
96 // user blocking thread.
97 void StartNetLogInternal(base::FilePath::StringType file_name,
98 bool log_bytes);
99 void StopNetLogInternal();
100
101 // Returns the HttpNeteworkSession object from the passed in
102 // URLRequestContext or NULL if none exists.
103 net::HttpNetworkSession* GetHttpNetworkSession(
104 net::URLRequestContext* context);
105
106 // Helper method that closes all current http2 sessions on the network IO
107 // thread.
108 void CloseAllhttp2SessionsInternal();
109
110 bool http2_enabled_;
111 bool quic_enabled_;
112 std::string host_resolver_rules_;
113 std::string ssl_key_log_file_name_;
114
115 std::list<net::HostPortPair> quic_hints_;
116
117 static CronetEnvironment* chrome_net_;
118 scoped_ptr<base::Thread> network_io_thread_;
119 scoped_ptr<base::Thread> network_cache_thread_;
120 scoped_ptr<base::Thread> file_thread_;
121 scoped_ptr<base::Thread> file_user_blocking_thread_;
122 scoped_refptr<base::SequencedTaskRunner> pref_store_worker_pool_;
123 scoped_refptr<JsonPrefStore> net_pref_store_;
124 scoped_ptr<net::CertVerifier> cert_verifier_;
125 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
126 scoped_ptr<net::HttpServerProperties> http_server_properties_;
127 scoped_ptr<net::URLRequestContext> main_context_;
128 std::string user_agent_product_name_;
129 scoped_ptr<net::NetLog> net_log_;
130 scoped_ptr<net::WriteToFileNetLogObserver> net_log_observer_;
131
132 DISALLOW_COPY_AND_ASSIGN(CronetEnvironment);
133 };
134
135 } // namespace cronet
136
137 #endif // COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698