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

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

Issue 2644583002: Add configuration functions for HTTP cache type to Obj-C and C++ (Closed)
Patch Set: make enum more obj-c-compatible Created 3 years, 10 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_environment.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "components/cronet/ios/cronet_environment.h" 5 #include "components/cronet/ios/cronet_environment.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 int port, 214 int port,
215 int alternate_port) { 215 int alternate_port) {
216 DCHECK(port == alternate_port); 216 DCHECK(port == alternate_port);
217 quic_hints_.push_back(net::HostPortPair(host, port)); 217 quic_hints_.push_back(net::HostPortPair(host, port));
218 } 218 }
219 219
220 CronetEnvironment::CronetEnvironment(const std::string& user_agent, 220 CronetEnvironment::CronetEnvironment(const std::string& user_agent,
221 bool user_agent_partial) 221 bool user_agent_partial)
222 : http2_enabled_(false), 222 : http2_enabled_(false),
223 quic_enabled_(false), 223 quic_enabled_(false),
224 http_cache_(URLRequestContextConfig::HttpCacheType::DISK),
224 user_agent_(user_agent), 225 user_agent_(user_agent),
225 user_agent_partial_(user_agent_partial), 226 user_agent_partial_(user_agent_partial),
226 net_log_(new net::NetLog) {} 227 net_log_(new net::NetLog) {}
227 228
228 void CronetEnvironment::Start() { 229 void CronetEnvironment::Start() {
229 // Threads setup. 230 // Threads setup.
230 network_cache_thread_.reset(new base::Thread("Chrome Network Cache Thread")); 231 network_cache_thread_.reset(new base::Thread("Chrome Network Cache Thread"));
231 network_cache_thread_->StartWithOptions( 232 network_cache_thread_->StartWithOptions(
232 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 233 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
233 network_io_thread_.reset(new base::Thread("Chrome Network IO Thread")); 234 network_io_thread_.reset(new base::Thread("Chrome Network IO Thread"));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 281
281 // Cache 282 // Cache
282 base::FilePath cache_path; 283 base::FilePath cache_path;
283 if (!PathService::Get(base::DIR_CACHE, &cache_path)) 284 if (!PathService::Get(base::DIR_CACHE, &cache_path))
284 return; 285 return;
285 cache_path = cache_path.Append(FILE_PATH_LITERAL("cronet")); 286 cache_path = cache_path.Append(FILE_PATH_LITERAL("cronet"));
286 287
287 URLRequestContextConfigBuilder context_config_builder; 288 URLRequestContextConfigBuilder context_config_builder;
288 context_config_builder.enable_quic = quic_enabled_; // Enable QUIC. 289 context_config_builder.enable_quic = quic_enabled_; // Enable QUIC.
289 context_config_builder.enable_spdy = http2_enabled_; // Enable HTTP/2. 290 context_config_builder.enable_spdy = http2_enabled_; // Enable HTTP/2.
290 context_config_builder.http_cache = URLRequestContextConfig::DISK; 291 context_config_builder.http_cache = http_cache_; // Set HTTP cache
291 context_config_builder.storage_path = 292 context_config_builder.storage_path =
292 cache_path.value(); // Storage path for http cache and cookie storage. 293 cache_path.value(); // Storage path for http cache and cookie storage.
293 context_config_builder.user_agent = 294 context_config_builder.user_agent =
294 user_agent_; // User-Agent request header field. 295 user_agent_; // User-Agent request header field.
295 context_config_builder.mock_cert_verifier = std::move( 296 context_config_builder.mock_cert_verifier = std::move(
296 mock_cert_verifier_); // MockCertVerifier to use for testing purposes. 297 mock_cert_verifier_); // MockCertVerifier to use for testing purposes.
297 std::unique_ptr<URLRequestContextConfig> config = 298 std::unique_ptr<URLRequestContextConfig> config =
298 context_config_builder.Build(); 299 context_config_builder.Build();
299 300
300 net::URLRequestContextBuilder context_builder; 301 net::URLRequestContextBuilder context_builder;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 event->Signal(); 371 event->Signal();
371 } 372 }
372 373
373 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { 374 std::string CronetEnvironment::getDefaultQuicUserAgentId() const {
374 return base::SysNSStringToUTF8([[NSBundle mainBundle] 375 return base::SysNSStringToUTF8([[NSBundle mainBundle]
375 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + 376 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) +
376 " Cronet/" + CRONET_VERSION; 377 " Cronet/" + CRONET_VERSION;
377 } 378 }
378 379
379 } // namespace cronet 380 } // namespace cronet
OLDNEW
« no previous file with comments | « components/cronet/ios/cronet_environment.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698