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

Side by Side Diff: net/http/http_server_properties_manager.cc

Issue 2567893002: Pass pref_task_runner through HttpServerPropertiesManager's cxtor so that tests could inject a Test… (Closed)
Patch Set: add comments to HttpServerPropertiesManager Created 4 years 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 "net/http/http_server_properties_manager.h" 5 #include "net/http/http_server_properties_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 } // namespace 67 } // namespace
68 68
69 //////////////////////////////////////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////////////////
70 // HttpServerPropertiesManager 70 // HttpServerPropertiesManager
71 71
72 HttpServerPropertiesManager::PrefDelegate::~PrefDelegate() {} 72 HttpServerPropertiesManager::PrefDelegate::~PrefDelegate() {}
73 73
74 HttpServerPropertiesManager::HttpServerPropertiesManager( 74 HttpServerPropertiesManager::HttpServerPropertiesManager(
75 PrefDelegate* pref_delegate, 75 PrefDelegate* pref_delegate,
76 scoped_refptr<base::SingleThreadTaskRunner> pref_task_runner,
76 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) 77 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner)
77 : pref_task_runner_(base::ThreadTaskRunnerHandle::Get()), 78 : pref_task_runner_(pref_task_runner),
78 pref_delegate_(pref_delegate), 79 pref_delegate_(pref_delegate),
79 setting_prefs_(false), 80 setting_prefs_(false),
80 network_task_runner_(network_task_runner) { 81 network_task_runner_(network_task_runner) {
81 DCHECK(pref_delegate_); 82 DCHECK(pref_delegate_);
82 pref_weak_ptr_factory_.reset( 83 pref_weak_ptr_factory_.reset(
83 new base::WeakPtrFactory<HttpServerPropertiesManager>(this)); 84 new base::WeakPtrFactory<HttpServerPropertiesManager>(this));
84 pref_weak_ptr_ = pref_weak_ptr_factory_->GetWeakPtr(); 85 pref_weak_ptr_ = pref_weak_ptr_factory_->GetWeakPtr();
85 pref_cache_update_timer_.reset(new base::OneShotTimer); 86 pref_cache_update_timer_.reset(new base::OneShotTimer);
87 pref_cache_update_timer_->SetTaskRunner(pref_task_runner_);
86 pref_delegate_->StartListeningForUpdates( 88 pref_delegate_->StartListeningForUpdates(
87 base::Bind(&HttpServerPropertiesManager::OnHttpServerPropertiesChanged, 89 base::Bind(&HttpServerPropertiesManager::OnHttpServerPropertiesChanged,
88 base::Unretained(this))); 90 base::Unretained(this)));
89 } 91 }
90 92
91 HttpServerPropertiesManager::~HttpServerPropertiesManager() { 93 HttpServerPropertiesManager::~HttpServerPropertiesManager() {
92 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 94 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
93 network_weak_ptr_factory_.reset(); 95 network_weak_ptr_factory_.reset();
94 } 96 }
95 97
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 quic_servers_dict); 1117 quic_servers_dict);
1116 } 1118 }
1117 1119
1118 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 1120 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
1119 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 1121 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
1120 if (!setting_prefs_) 1122 if (!setting_prefs_)
1121 ScheduleUpdateCacheOnPrefThread(); 1123 ScheduleUpdateCacheOnPrefThread();
1122 } 1124 }
1123 1125
1124 } // namespace net 1126 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/http/http_server_properties_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698