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/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
16 #include "base/i18n/icu_util.h" | 16 #include "base/i18n/icu_util.h" |
17 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
18 #include "base/mac/bind_objc_block.h" | 18 #include "base/mac/bind_objc_block.h" |
19 #include "base/mac/foundation_util.h" | 19 #include "base/mac/foundation_util.h" |
20 #include "base/mac/scoped_block.h" | 20 #include "base/mac/scoped_block.h" |
21 #include "base/macros.h" | 21 #include "base/macros.h" |
22 #include "base/metrics/statistics_recorder.h" | 22 #include "base/metrics/statistics_recorder.h" |
23 #include "base/path_service.h" | 23 #include "base/path_service.h" |
24 #include "base/prefs/json_pref_store.h" | 24 #include "base/prefs/json_pref_store.h" |
25 #include "base/prefs/pref_filter.h" | 25 #include "base/prefs/pref_filter.h" |
26 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
27 #import "components/webp_transcode/webp_network_client_factory.h" | 27 #import "components/webp_transcode/webp_network_client_factory.h" |
28 #include "crypto/nss_util.h" | 28 #include "crypto/nss_util.h" |
| 29 #include "ios/crnet/sdch_owner_pref_storage.h" |
29 #include "ios/net/cookies/cookie_store_ios.h" | 30 #include "ios/net/cookies/cookie_store_ios.h" |
30 #include "ios/net/crn_http_protocol_handler.h" | 31 #include "ios/net/crn_http_protocol_handler.h" |
31 #include "ios/net/empty_nsurlcache.h" | 32 #include "ios/net/empty_nsurlcache.h" |
32 #include "ios/net/http_cache_helper.h" | 33 #include "ios/net/http_cache_helper.h" |
33 #include "ios/net/request_tracker.h" | 34 #include "ios/net/request_tracker.h" |
34 #include "ios/web/public/user_agent.h" | 35 #include "ios/web/public/user_agent.h" |
35 #include "net/base/net_errors.h" | 36 #include "net/base/net_errors.h" |
36 #include "net/base/network_change_notifier.h" | 37 #include "net/base/network_change_notifier.h" |
37 #include "net/base/sdch_manager.h" | 38 #include "net/base/sdch_manager.h" |
38 #include "net/cert/cert_verifier.h" | 39 #include "net/cert/cert_verifier.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 sdch_manager_.reset(new net::SdchManager()); | 341 sdch_manager_.reset(new net::SdchManager()); |
341 sdch_owner_.reset(new net::SdchOwner(sdch_manager_.get(), context)); | 342 sdch_owner_.reset(new net::SdchOwner(sdch_manager_.get(), context)); |
342 if (!sdch_pref_store_filename_.empty()) { | 343 if (!sdch_pref_store_filename_.empty()) { |
343 base::FilePath path(sdch_pref_store_filename_); | 344 base::FilePath path(sdch_pref_store_filename_); |
344 pref_store_worker_pool_ = file_user_blocking_thread_->task_runner(); | 345 pref_store_worker_pool_ = file_user_blocking_thread_->task_runner(); |
345 net_pref_store_ = new JsonPrefStore( | 346 net_pref_store_ = new JsonPrefStore( |
346 path, | 347 path, |
347 pref_store_worker_pool_.get(), | 348 pref_store_worker_pool_.get(), |
348 scoped_ptr<PrefFilter>()); | 349 scoped_ptr<PrefFilter>()); |
349 net_pref_store_->ReadPrefsAsync(nullptr); | 350 net_pref_store_->ReadPrefsAsync(nullptr); |
350 sdch_owner_->EnablePersistentStorage(net_pref_store_.get()); | 351 sdch_owner_->EnablePersistentStorage( |
| 352 scoped_ptr<net::SdchOwner::PrefStorage>( |
| 353 new SdchOwnerPrefStorage(net_pref_store_.get()))); |
351 } | 354 } |
352 context->set_sdch_manager(sdch_manager_.get()); | 355 context->set_sdch_manager(sdch_manager_.get()); |
353 } | 356 } |
354 | 357 |
355 void CrNetEnvironment::InitializeOnNetworkThread() { | 358 void CrNetEnvironment::InitializeOnNetworkThread() { |
356 DCHECK(base::MessageLoop::current() == network_io_thread_->message_loop()); | 359 DCHECK(base::MessageLoop::current() == network_io_thread_->message_loop()); |
357 | 360 |
358 // Register network clients. | 361 // Register network clients. |
359 net::RequestTracker::AddGlobalNetworkClientFactory( | 362 net::RequestTracker::AddGlobalNetworkClientFactory( |
360 [[[WebPNetworkClientFactory alloc] | 363 [[[WebPNetworkClientFactory alloc] |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 492 |
490 return user_agent_settings->GetUserAgent(); | 493 return user_agent_settings->GetUserAgent(); |
491 } | 494 } |
492 | 495 |
493 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { | 496 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { |
494 PostToNetworkThread( | 497 PostToNetworkThread( |
495 FROM_HERE, | 498 FROM_HERE, |
496 base::Bind(&net::ClearHttpCache, main_context_getter_, | 499 base::Bind(&net::ClearHttpCache, main_context_getter_, |
497 network_io_thread_->task_runner(), base::BindBlock(callback))); | 500 network_io_thread_->task_runner(), base::BindBlock(callback))); |
498 } | 501 } |
OLD | NEW |