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 "ios/crnet/crnet_environment.h" | 5 #include "ios/crnet/crnet_environment.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/files/scoped_file.h" | 13 #include "base/files/scoped_file.h" |
14 #include "base/i18n/icu_util.h" | 14 #include "base/i18n/icu_util.h" |
15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
16 #include "base/mac/bind_objc_block.h" | 16 #include "base/mac/bind_objc_block.h" |
17 #include "base/mac/foundation_util.h" | 17 #include "base/mac/foundation_util.h" |
18 #include "base/mac/scoped_block.h" | 18 #include "base/mac/scoped_block.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/threading/worker_pool.h" | 20 #include "base/threading/worker_pool.h" |
21 #import "components/webp_transcode/webp_network_client_factory.h" | 21 #import "components/webp_transcode/webp_network_client_factory.h" |
22 #include "crypto/nss_util.h" | 22 #include "crypto/nss_util.h" |
23 #include "ios/net/cookies/cookie_store_ios.h" | 23 #include "ios/net/cookies/cookie_store_ios.h" |
24 #include "ios/net/crn_http_protocol_handler.h" | 24 #include "ios/net/crn_http_protocol_handler.h" |
| 25 #include "ios/net/empty_nsurlcache.h" |
25 #include "ios/net/request_tracker.h" | 26 #include "ios/net/request_tracker.h" |
26 #include "ios/web/public/user_agent.h" | 27 #include "ios/web/public/user_agent.h" |
27 #include "net/base/net_errors.h" | 28 #include "net/base/net_errors.h" |
28 #include "net/base/network_change_notifier.h" | 29 #include "net/base/network_change_notifier.h" |
29 #include "net/base/sdch_manager.h" | 30 #include "net/base/sdch_manager.h" |
30 #include "net/cert/cert_verifier.h" | 31 #include "net/cert/cert_verifier.h" |
31 #include "net/cert_net/nss_ocsp.h" | 32 #include "net/cert_net/nss_ocsp.h" |
32 #include "net/disk_cache/disk_cache.h" | 33 #include "net/disk_cache/disk_cache.h" |
33 #include "net/http/http_auth_handler_factory.h" | 34 #include "net/http/http_auth_handler_factory.h" |
34 #include "net/http/http_cache.h" | 35 #include "net/http/http_cache.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 net::SetURLRequestContextForNSSHttpIO(nullptr); | 294 net::SetURLRequestContextForNSSHttpIO(nullptr); |
294 } | 295 } |
295 | 296 |
296 net::URLRequestContextGetter* CrNetEnvironment::GetMainContextGetter() { | 297 net::URLRequestContextGetter* CrNetEnvironment::GetMainContextGetter() { |
297 return main_context_getter_.get(); | 298 return main_context_getter_.get(); |
298 } | 299 } |
299 | 300 |
300 void CrNetEnvironment::SetHTTPProtocolHandlerRegistered(bool registered) { | 301 void CrNetEnvironment::SetHTTPProtocolHandlerRegistered(bool registered) { |
301 if (registered) { | 302 if (registered) { |
302 // Disable the default cache. | 303 // Disable the default cache. |
303 [NSURLCache setSharedURLCache:nil]; | 304 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]]; |
304 // Register the chrome http protocol handler to replace the default one. | 305 // Register the chrome http protocol handler to replace the default one. |
305 BOOL success = [NSURLProtocol registerClass:[CRNHTTPProtocolHandler class]]; | 306 BOOL success = [NSURLProtocol registerClass:[CRNHTTPProtocolHandler class]]; |
306 DCHECK(success); | 307 DCHECK(success); |
307 } else { | 308 } else { |
308 // Set up an empty default cache, with default size. | 309 // Set up an empty default cache, with default size. |
309 // TODO(droger): If the NSURLCache is to be used, its size should most | 310 // TODO(droger): If the NSURLCache is to be used, its size should most |
310 // likely be changed. On an iPod2 with iOS4, the default size is 512k. | 311 // likely be changed. On an iPod2 with iOS4, the default size is 512k. |
311 [NSURLCache setSharedURLCache:[[[NSURLCache alloc] init] autorelease]]; | 312 [NSURLCache setSharedURLCache:[[[NSURLCache alloc] init] autorelease]]; |
312 [NSURLProtocol unregisterClass:[CRNHTTPProtocolHandler class]]; | 313 [NSURLProtocol unregisterClass:[CRNHTTPProtocolHandler class]]; |
313 } | 314 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 if (backend) | 467 if (backend) |
467 backend->DoomAllEntries(client_callback); | 468 backend->DoomAllEntries(client_callback); |
468 }); | 469 }); |
469 int rc = cache->GetBackend(&backend, doom_callback); | 470 int rc = cache->GetBackend(&backend, doom_callback); |
470 if (rc != net::ERR_IO_PENDING) { | 471 if (rc != net::ERR_IO_PENDING) { |
471 // GetBackend doesn't call the callback if it completes synchronously, so | 472 // GetBackend doesn't call the callback if it completes synchronously, so |
472 // call it directly here. | 473 // call it directly here. |
473 doom_callback.Run(rc); | 474 doom_callback.Run(rc); |
474 } | 475 } |
475 } | 476 } |
OLD | NEW |