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 #include "components/cronet/android/url_request_context_peer.h" | 5 #include "components/cronet/android/url_request_context_peer.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/base/net_log_logger.h" | 9 #include "net/base/net_log_logger.h" |
10 #include "net/cert/cert_verifier.h" | 10 #include "net/cert/cert_verifier.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 base::Thread::Options options; | 125 base::Thread::Options options; |
126 options.message_loop_type = base::MessageLoop::TYPE_IO; | 126 options.message_loop_type = base::MessageLoop::TYPE_IO; |
127 network_thread_->StartWithOptions(options); | 127 network_thread_->StartWithOptions(options); |
128 | 128 |
129 GetNetworkTaskRunner()->PostTask( | 129 GetNetworkTaskRunner()->PostTask( |
130 FROM_HERE, | 130 FROM_HERE, |
131 base::Bind(&URLRequestContextPeer::InitializeURLRequestContext, this)); | 131 base::Bind(&URLRequestContextPeer::InitializeURLRequestContext, this)); |
132 } | 132 } |
133 | 133 |
134 void URLRequestContextPeer::InitializeURLRequestContext() { | 134 void URLRequestContextPeer::InitializeURLRequestContext() { |
135 // TODO(mmenke): Add method to have the builder enable SPDY. | |
mmenke
2014/05/22 14:51:12
I plan to do this right after this CL lands.
| |
135 net::URLRequestContextBuilder context_builder; | 136 net::URLRequestContextBuilder context_builder; |
136 context_builder.set_network_delegate(new BasicNetworkDelegate()); | 137 context_builder.set_network_delegate(new BasicNetworkDelegate()); |
137 context_builder.set_proxy_config_service( | 138 context_builder.set_proxy_config_service( |
138 new net::ProxyConfigServiceFixed(net::ProxyConfig())); | 139 new net::ProxyConfigServiceFixed(net::ProxyConfig())); |
139 context_builder.DisableHttpCache(); | 140 context_builder.DisableHttpCache(); |
140 | 141 |
141 context_.reset(context_builder.Build()); | 142 context_.reset(context_builder.Build()); |
142 | 143 |
143 if (VLOG_IS_ON(2)) { | 144 if (VLOG_IS_ON(2)) { |
144 net_log_observer_.reset(new NetLogObserver(logging_level_)); | 145 net_log_observer_.reset(new NetLogObserver(logging_level_)); |
145 context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), | 146 context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), |
146 net::NetLog::LOG_ALL_BUT_BYTES); | 147 net::NetLog::LOG_ALL_BUT_BYTES); |
147 } | 148 } |
148 | 149 |
149 net::HttpStreamFactory::EnableNpnSpdy31(); | |
150 | |
151 delegate_->OnContextInitialized(this); | 150 delegate_->OnContextInitialized(this); |
152 } | 151 } |
153 | 152 |
154 URLRequestContextPeer::~URLRequestContextPeer() { | 153 URLRequestContextPeer::~URLRequestContextPeer() { |
155 if (net_log_observer_) { | 154 if (net_log_observer_) { |
156 context_->net_log()->RemoveThreadSafeObserver(net_log_observer_.get()); | 155 context_->net_log()->RemoveThreadSafeObserver(net_log_observer_.get()); |
157 net_log_observer_.reset(); | 156 net_log_observer_.reset(); |
158 } | 157 } |
159 StopNetLog(); | 158 StopNetLog(); |
160 } | 159 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 | 198 |
200 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { | 199 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
201 if (VLOG_IS_ON(2)) { | 200 if (VLOG_IS_ON(2)) { |
202 VLOG(2) << "Net log entry: type=" << entry.type() | 201 VLOG(2) << "Net log entry: type=" << entry.type() |
203 << ", source=" << entry.source().type | 202 << ", source=" << entry.source().type |
204 << ", phase=" << entry.phase(); | 203 << ", phase=" << entry.phase(); |
205 } | 204 } |
206 } | 205 } |
207 | 206 |
208 } // namespace cronet | 207 } // namespace cronet |
OLD | NEW |