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

Side by Side Diff: components/cronet/url_request_context_config.cc

Issue 1839283002: [Cronet] Purge storage directory if version does not match (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Misha's comments and test suggestion 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
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/url_request_context_config.h" 5 #include "components/cronet/url_request_context_config.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "net/cert/cert_verifier.h" 16 #include "net/cert/cert_verifier.h"
17 #include "net/dns/host_resolver.h" 17 #include "net/dns/host_resolver.h"
18 #include "net/http/http_server_properties.h" 18 #include "net/http/http_server_properties.h"
19 #include "net/quic/quic_protocol.h" 19 #include "net/quic/quic_protocol.h"
20 #include "net/quic/quic_utils.h" 20 #include "net/quic/quic_utils.h"
21 #include "net/socket/ssl_client_socket.h" 21 #include "net/socket/ssl_client_socket.h"
22 #include "net/url_request/url_request_context_builder.h" 22 #include "net/url_request/url_request_context_builder.h"
23 23
24 namespace cronet { 24 namespace cronet {
25 25
26 namespace { 26 namespace {
27 27
28 // Name of disk cache directory.
29 const char kDiskCacheDirectoryName[] = "disk_cache";
28 // TODO(xunjieli): Refactor constants in io_thread.cc. 30 // TODO(xunjieli): Refactor constants in io_thread.cc.
29 const char kQuicFieldTrialName[] = "QUIC"; 31 const char kQuicFieldTrialName[] = "QUIC";
30 const char kQuicConnectionOptions[] = "connection_options"; 32 const char kQuicConnectionOptions[] = "connection_options";
31 const char kQuicStoreServerConfigsInProperties[] = 33 const char kQuicStoreServerConfigsInProperties[] =
32 "store_server_configs_in_properties"; 34 "store_server_configs_in_properties";
33 const char kQuicMaxServerConfigsStoredInProperties[] = 35 const char kQuicMaxServerConfigsStoredInProperties[] =
34 "max_server_configs_stored_in_properties"; 36 "max_server_configs_stored_in_properties";
35 const char kQuicDelayTcpRace[] = "delay_tcp_race"; 37 const char kQuicDelayTcpRace[] = "delay_tcp_race";
36 const char kQuicMaxNumberOfLossyConnections[] = 38 const char kQuicMaxNumberOfLossyConnections[] =
37 "max_number_of_lossy_connections"; 39 "max_number_of_lossy_connections";
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 271
270 void URLRequestContextConfig::ConfigureURLRequestContextBuilder( 272 void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
271 net::URLRequestContextBuilder* context_builder, 273 net::URLRequestContextBuilder* context_builder,
272 net::NetLog* net_log, 274 net::NetLog* net_log,
273 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { 275 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) {
274 std::string config_cache; 276 std::string config_cache;
275 if (http_cache != DISABLED) { 277 if (http_cache != DISABLED) {
276 net::URLRequestContextBuilder::HttpCacheParams cache_params; 278 net::URLRequestContextBuilder::HttpCacheParams cache_params;
277 if (http_cache == DISK && !storage_path.empty()) { 279 if (http_cache == DISK && !storage_path.empty()) {
278 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK; 280 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK;
279 cache_params.path = base::FilePath(storage_path); 281 cache_params.path =
282 base::FilePath(storage_path)
283 .Append(FILE_PATH_LITERAL(kDiskCacheDirectoryName));
mef 2016/04/05 18:00:50 Do we have and/or need a test that 'disk_cache' di
xunjieli 2016/04/05 18:22:55 Done. Added the assertions in the original tests.
280 } else { 284 } else {
281 cache_params.type = 285 cache_params.type =
282 net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY; 286 net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY;
283 } 287 }
284 cache_params.max_size = http_cache_max_size; 288 cache_params.max_size = http_cache_max_size;
285 context_builder->EnableHttpCache(cache_params); 289 context_builder->EnableHttpCache(cache_params);
286 } else { 290 } else {
287 context_builder->DisableHttpCache(); 291 context_builder->DisableHttpCache();
288 } 292 }
289 context_builder->set_user_agent(user_agent); 293 context_builder->set_user_agent(user_agent);
290 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic); 294 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic);
291 context_builder->set_sdch_enabled(enable_sdch); 295 context_builder->set_sdch_enabled(enable_sdch);
292 if (enable_quic) 296 if (enable_quic)
293 context_builder->set_quic_user_agent_id(quic_user_agent_id); 297 context_builder->set_quic_user_agent_id(quic_user_agent_id);
294 298
295 ParseAndSetExperimentalOptions(experimental_options, context_builder, net_log, 299 ParseAndSetExperimentalOptions(experimental_options, context_builder, net_log,
296 file_task_runner); 300 file_task_runner);
297 301
298 if (mock_cert_verifier) 302 if (mock_cert_verifier)
299 context_builder->SetCertVerifier(std::move(mock_cert_verifier)); 303 context_builder->SetCertVerifier(std::move(mock_cert_verifier));
300 // TODO(mef): Use |config| to set cookies. 304 // TODO(mef): Use |config| to set cookies.
301 } 305 }
302 306
303 } // namespace cronet 307 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698