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

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

Issue 1355063004: Template methods on Timer classes instead of the classes themselves. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: timer: fixcaller Created 5 years, 2 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 "net/http/http_server_properties_manager.h" 5 #include "net/http/http_server_properties_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 scoped_refptr<base::SequencedTaskRunner> network_task_runner) 79 scoped_refptr<base::SequencedTaskRunner> network_task_runner)
80 : pref_task_runner_(base::ThreadTaskRunnerHandle::Get()), 80 : pref_task_runner_(base::ThreadTaskRunnerHandle::Get()),
81 pref_service_(pref_service), 81 pref_service_(pref_service),
82 setting_prefs_(false), 82 setting_prefs_(false),
83 path_(pref_path), 83 path_(pref_path),
84 network_task_runner_(network_task_runner) { 84 network_task_runner_(network_task_runner) {
85 DCHECK(pref_service); 85 DCHECK(pref_service);
86 pref_weak_ptr_factory_.reset( 86 pref_weak_ptr_factory_.reset(
87 new base::WeakPtrFactory<HttpServerPropertiesManager>(this)); 87 new base::WeakPtrFactory<HttpServerPropertiesManager>(this));
88 pref_weak_ptr_ = pref_weak_ptr_factory_->GetWeakPtr(); 88 pref_weak_ptr_ = pref_weak_ptr_factory_->GetWeakPtr();
89 pref_cache_update_timer_.reset( 89 pref_cache_update_timer_.reset(new base::OneShotTimer);
90 new base::OneShotTimer<HttpServerPropertiesManager>);
91 pref_change_registrar_.Init(pref_service_); 90 pref_change_registrar_.Init(pref_service_);
92 pref_change_registrar_.Add( 91 pref_change_registrar_.Add(
93 path_, 92 path_,
94 base::Bind(&HttpServerPropertiesManager::OnHttpServerPropertiesChanged, 93 base::Bind(&HttpServerPropertiesManager::OnHttpServerPropertiesChanged,
95 base::Unretained(this))); 94 base::Unretained(this)));
96 } 95 }
97 96
98 HttpServerPropertiesManager::~HttpServerPropertiesManager() { 97 HttpServerPropertiesManager::~HttpServerPropertiesManager() {
99 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 98 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
100 network_weak_ptr_factory_.reset(); 99 network_weak_ptr_factory_.reset();
101 } 100 }
102 101
103 void HttpServerPropertiesManager::InitializeOnNetworkThread() { 102 void HttpServerPropertiesManager::InitializeOnNetworkThread() {
104 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 103 DCHECK(network_task_runner_->RunsTasksOnCurrentThread());
105 network_weak_ptr_factory_.reset( 104 network_weak_ptr_factory_.reset(
106 new base::WeakPtrFactory<HttpServerPropertiesManager>(this)); 105 new base::WeakPtrFactory<HttpServerPropertiesManager>(this));
107 http_server_properties_impl_.reset(new HttpServerPropertiesImpl()); 106 http_server_properties_impl_.reset(new HttpServerPropertiesImpl());
108 107
109 network_prefs_update_timer_.reset( 108 network_prefs_update_timer_.reset(new base::OneShotTimer);
110 new base::OneShotTimer<HttpServerPropertiesManager>);
111 109
112 pref_task_runner_->PostTask( 110 pref_task_runner_->PostTask(
113 FROM_HERE, 111 FROM_HERE,
114 base::Bind(&HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread, 112 base::Bind(&HttpServerPropertiesManager::UpdateCacheFromPrefsOnPrefThread,
115 pref_weak_ptr_)); 113 pref_weak_ptr_));
116 } 114 }
117 115
118 void HttpServerPropertiesManager::ShutdownOnPrefThread() { 116 void HttpServerPropertiesManager::ShutdownOnPrefThread() {
119 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 117 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
120 // Cancel any pending updates, and stop listening for pref change updates. 118 // Cancel any pending updates, and stop listening for pref change updates.
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 server_network_stats_dict); 1060 server_network_stats_dict);
1063 } 1061 }
1064 1062
1065 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() { 1063 void HttpServerPropertiesManager::OnHttpServerPropertiesChanged() {
1066 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread()); 1064 DCHECK(pref_task_runner_->RunsTasksOnCurrentThread());
1067 if (!setting_prefs_) 1065 if (!setting_prefs_)
1068 ScheduleUpdateCacheOnPrefThread(); 1066 ScheduleUpdateCacheOnPrefThread();
1069 } 1067 }
1070 1068
1071 } // namespace net 1069 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_manager.h ('k') | net/proxy/dhcp_proxy_script_adapter_fetcher_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698