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 <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/atomicops.h" | 12 #include "base/atomicops.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
16 #include "base/files/scoped_file.h" | 16 #include "base/files/scoped_file.h" |
17 #include "base/i18n/icu_util.h" | 17 #include "base/i18n/icu_util.h" |
18 #include "base/json/json_writer.h" | 18 #include "base/json/json_writer.h" |
19 #include "base/mac/bind_objc_block.h" | 19 #include "base/mac/bind_objc_block.h" |
20 #include "base/mac/foundation_util.h" | 20 #include "base/mac/foundation_util.h" |
21 #include "base/mac/scoped_block.h" | 21 #include "base/mac/scoped_block.h" |
22 #include "base/macros.h" | 22 #include "base/macros.h" |
23 #include "base/metrics/statistics_recorder.h" | 23 #include "base/metrics/statistics_recorder.h" |
24 #include "base/path_service.h" | 24 #include "base/path_service.h" |
25 #include "base/threading/worker_pool.h" | 25 #include "base/threading/worker_pool.h" |
26 #include "components/prefs/json_pref_store.h" | 26 #include "components/prefs/json_pref_store.h" |
27 #include "components/prefs/pref_filter.h" | 27 #include "components/prefs/pref_filter.h" |
28 #import "components/webp_transcode/webp_network_client_factory.h" | |
29 #include "crypto/nss_util.h" | 28 #include "crypto/nss_util.h" |
30 #include "ios/crnet/sdch_owner_pref_storage.h" | 29 #include "ios/crnet/sdch_owner_pref_storage.h" |
31 #include "ios/net/cookies/cookie_store_ios.h" | 30 #include "ios/net/cookies/cookie_store_ios.h" |
32 #include "ios/net/crn_http_protocol_handler.h" | 31 #include "ios/net/crn_http_protocol_handler.h" |
33 #include "ios/net/empty_nsurlcache.h" | 32 #include "ios/net/empty_nsurlcache.h" |
34 #include "ios/net/http_cache_helper.h" | 33 #include "ios/net/http_cache_helper.h" |
35 #include "ios/net/request_tracker.h" | 34 #include "ios/net/request_tracker.h" |
36 #include "ios/web/public/user_agent.h" | 35 #include "ios/web/public/user_agent.h" |
37 #include "net/base/net_errors.h" | 36 #include "net/base/net_errors.h" |
38 #include "net/base/network_change_notifier.h" | 37 #include "net/base/network_change_notifier.h" |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 sdch_owner_->EnablePersistentStorage( | 360 sdch_owner_->EnablePersistentStorage( |
362 scoped_ptr<net::SdchOwner::PrefStorage>( | 361 scoped_ptr<net::SdchOwner::PrefStorage>( |
363 new SdchOwnerPrefStorage(net_pref_store_.get()))); | 362 new SdchOwnerPrefStorage(net_pref_store_.get()))); |
364 } | 363 } |
365 context->set_sdch_manager(sdch_manager_.get()); | 364 context->set_sdch_manager(sdch_manager_.get()); |
366 } | 365 } |
367 | 366 |
368 void CrNetEnvironment::InitializeOnNetworkThread() { | 367 void CrNetEnvironment::InitializeOnNetworkThread() { |
369 DCHECK(base::MessageLoop::current() == network_io_thread_->message_loop()); | 368 DCHECK(base::MessageLoop::current() == network_io_thread_->message_loop()); |
370 | 369 |
371 // Register network clients. | |
372 net::RequestTracker::AddGlobalNetworkClientFactory( | |
373 [[[WebPNetworkClientFactory alloc] | |
374 initWithTaskRunner:file_user_blocking_thread_ | |
375 ->task_runner()] autorelease]); | |
376 | |
377 ConfigureSdchOnNetworkThread(); | 370 ConfigureSdchOnNetworkThread(); |
378 | 371 |
379 NSString* bundlePath = | 372 NSString* bundlePath = |
380 [[NSBundle mainBundle] pathForResource:@"crnet_resources" | 373 [[NSBundle mainBundle] pathForResource:@"crnet_resources" |
381 ofType:@"bundle"]; | 374 ofType:@"bundle"]; |
382 NSBundle* bundle = [NSBundle bundleWithPath:bundlePath]; | 375 NSBundle* bundle = [NSBundle bundleWithPath:bundlePath]; |
383 NSString* acceptableLanguages = NSLocalizedStringWithDefaultValue( | 376 NSString* acceptableLanguages = NSLocalizedStringWithDefaultValue( |
384 @"IDS_ACCEPT_LANGUAGES", | 377 @"IDS_ACCEPT_LANGUAGES", |
385 @"Localizable", | 378 @"Localizable", |
386 bundle, | 379 bundle, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 491 |
499 return user_agent_settings->GetUserAgent(); | 492 return user_agent_settings->GetUserAgent(); |
500 } | 493 } |
501 | 494 |
502 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { | 495 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { |
503 PostToNetworkThread( | 496 PostToNetworkThread( |
504 FROM_HERE, | 497 FROM_HERE, |
505 base::Bind(&net::ClearHttpCache, main_context_getter_, | 498 base::Bind(&net::ClearHttpCache, main_context_getter_, |
506 network_io_thread_->task_runner(), base::BindBlock(callback))); | 499 network_io_thread_->task_runner(), base::BindBlock(callback))); |
507 } | 500 } |
OLD | NEW |