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

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 Helen's comments. 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 } // namespace net
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 Cronet environment. Can only be called once.
42 void Install();
43
44 // The full user-agent.
45 std::string user_agent();
46
47 // Creates a new net log (overwrites existing file with this name). If
48 // actively logging, this call is ignored.
49 void StartNetLog(base::FilePath::StringType file_name, bool log_bytes);
50 // Stops logging and flushes file. If not currently logging this call is
51 // ignored.
52 void StopNetLog();
53
54 void AddQuicHint(const std::string& host, int port, int alternate_port);
55
56 // Setters and getters for |http2_enabled_|, |quic_enabled_|, and
57 // |forced_quic_origin_|. These only have any effect before Install() is
58 // called.
59 void set_http2_enabled(bool enabled) { http2_enabled_ = enabled; }
60 void set_quic_enabled(bool enabled) { quic_enabled_ = enabled; }
61
62 bool http2_enabled() const { return http2_enabled_; }
63 bool quic_enabled() const { return quic_enabled_; }
64
65 void set_cert_verifier(scoped_ptr<net::CertVerifier> cert_verifier) {
66 cert_verifier_ = std::move(cert_verifier);
67 }
68
69 void set_host_resolver_rules(const std::string& host_resolver_rules) {
70 host_resolver_rules_ = host_resolver_rules;
71 }
72
73 void set_ssl_key_log_file_name(const std::string& ssl_key_log_file_name) {
74 ssl_key_log_file_name_ = ssl_key_log_file_name;
75 }
76
77 net::URLRequestContext* GetURLRequestContext() const;
78
79 bool IsOnNetworkThread();
80
81 // Runs a closure on the network thread.
82 void PostToNetworkThread(const tracked_objects::Location& from_here,
83 const base::Closure& task);
84
85 private:
86 // Performs initialization tasks that must happen on the network thread.
87 void InitializeOnNetworkThread();
88
89 // Runs a closure on the file user blocking thread.
90 void PostToFileUserBlockingThread(const tracked_objects::Location& from_here,
91 const base::Closure& task);
92
93 // Helper methods that start/stop net-internals logging on the file
94 // user blocking thread.
95 void StartNetLogInternal(const base::FilePath::StringType& file_name,
96 bool log_bytes);
97 void StopNetLogInternal();
98
99 // Returns the HttpNetworkSession object from the passed in
100 // URLRequestContext or NULL if none exists.
101 net::HttpNetworkSession* GetHttpNetworkSession(
102 net::URLRequestContext* context);
103
104 bool http2_enabled_;
105 bool quic_enabled_;
106 std::string host_resolver_rules_;
107 std::string ssl_key_log_file_name_;
108
109 std::list<net::HostPortPair> quic_hints_;
110
111 static CronetEnvironment* chrome_net_;
112 scoped_ptr<base::Thread> network_io_thread_;
113 scoped_ptr<base::Thread> network_cache_thread_;
114 scoped_ptr<base::Thread> file_thread_;
115 scoped_ptr<base::Thread> file_user_blocking_thread_;
116 scoped_refptr<base::SequencedTaskRunner> pref_store_worker_pool_;
117 scoped_refptr<JsonPrefStore> net_pref_store_;
118 scoped_ptr<net::CertVerifier> cert_verifier_;
119 scoped_ptr<net::ProxyConfigService> proxy_config_service_;
120 scoped_ptr<net::HttpServerProperties> http_server_properties_;
121 scoped_ptr<net::URLRequestContext> main_context_;
122 std::string user_agent_product_name_;
123 scoped_ptr<net::NetLog> net_log_;
124 scoped_ptr<net::WriteToFileNetLogObserver> net_log_observer_;
125
126 DISALLOW_COPY_AND_ASSIGN(CronetEnvironment);
127 };
128
129 } // namespace cronet
130
131 #endif // COMPONENTS_CRONET_IOS_CRONET_ENVIRONMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698