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

Side by Side Diff: ios/crnet/crnet_environment.mm

Issue 1634653003: Abstract pref storage from net::SdchOwner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@net_prefs
Patch Set: Review comments Created 4 years, 11 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 "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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 DCHECK(base::MessageLoop::current() == network_io_thread_->message_loop()); 332 DCHECK(base::MessageLoop::current() == network_io_thread_->message_loop());
332 net::URLRequestContext* context = 333 net::URLRequestContext* context =
333 main_context_getter_->GetURLRequestContext(); 334 main_context_getter_->GetURLRequestContext();
334 335
335 if (!sdch_enabled_) { 336 if (!sdch_enabled_) {
336 DCHECK_EQ(static_cast<net::SdchManager*>(nullptr), context->sdch_manager()); 337 DCHECK_EQ(static_cast<net::SdchManager*>(nullptr), context->sdch_manager());
337 return; 338 return;
338 } 339 }
339 340
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(
343 new net::SdchOwner(scoped_ptr<net::SdchOwner::PrefStorage>(
344 new SdchOwnerPrefStorage(sdch_manager_.get())),
345 context));
342 if (!sdch_pref_store_filename_.empty()) { 346 if (!sdch_pref_store_filename_.empty()) {
343 base::FilePath path(sdch_pref_store_filename_); 347 base::FilePath path(sdch_pref_store_filename_);
344 pref_store_worker_pool_ = file_user_blocking_thread_->task_runner(); 348 pref_store_worker_pool_ = file_user_blocking_thread_->task_runner();
345 net_pref_store_ = new JsonPrefStore( 349 net_pref_store_ = new JsonPrefStore(
346 path, 350 path,
347 pref_store_worker_pool_.get(), 351 pref_store_worker_pool_.get(),
348 scoped_ptr<PrefFilter>()); 352 scoped_ptr<PrefFilter>());
349 net_pref_store_->ReadPrefsAsync(nullptr); 353 net_pref_store_->ReadPrefsAsync(nullptr);
350 sdch_owner_->EnablePersistentStorage(net_pref_store_.get()); 354 sdch_owner_->EnablePersistentStorage(net_pref_store_.get());
351 } 355 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 493
490 return user_agent_settings->GetUserAgent(); 494 return user_agent_settings->GetUserAgent();
491 } 495 }
492 496
493 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) { 497 void CrNetEnvironment::ClearCache(ClearCacheCallback callback) {
494 PostToNetworkThread( 498 PostToNetworkThread(
495 FROM_HERE, 499 FROM_HERE,
496 base::Bind(&net::ClearHttpCache, main_context_getter_, 500 base::Bind(&net::ClearHttpCache, main_context_getter_,
497 network_io_thread_->task_runner(), base::BindBlock(callback))); 501 network_io_thread_->task_runner(), base::BindBlock(callback)));
498 } 502 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698