OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/proxy/polling_proxy_config_service.h" | 5 #include "net/proxy/polling_proxy_config_service.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 if (!origin_loop_proxy_) | 115 if (!origin_loop_proxy_) |
116 return; // Was orphaned (parent has already been destroyed). | 116 return; // Was orphaned (parent has already been destroyed). |
117 | 117 |
118 DCHECK(origin_loop_proxy_->BelongsToCurrentThread()); | 118 DCHECK(origin_loop_proxy_->BelongsToCurrentThread()); |
119 | 119 |
120 if (!has_config_ || !last_config_.Equals(config)) { | 120 if (!has_config_ || !last_config_.Equals(config)) { |
121 // If the configuration has changed, notify the observers. | 121 // If the configuration has changed, notify the observers. |
122 has_config_ = true; | 122 has_config_ = true; |
123 last_config_ = config; | 123 last_config_ = config; |
124 FOR_EACH_OBSERVER(Observer, observers_, OnProxyConfigChanged(config)); | 124 FOR_EACH_OBSERVER(Observer, observers_, |
| 125 OnProxyConfigChanged(config, |
| 126 ProxyConfigService::CONFIG_VALID)); |
125 } | 127 } |
126 | 128 |
127 if (poll_task_queued_) | 129 if (poll_task_queued_) |
128 CheckForChangesNow(); | 130 CheckForChangesNow(); |
129 } | 131 } |
130 | 132 |
131 void LazyInitializeOriginLoop() { | 133 void LazyInitializeOriginLoop() { |
132 // TODO(eroman): Really this should be done in the constructor, but right | 134 // TODO(eroman): Really this should be done in the constructor, but right |
133 // now chrome is constructing the ProxyConfigService on the | 135 // now chrome is constructing the ProxyConfigService on the |
134 // UI thread so we can't cache the IO thread for the purpose | 136 // UI thread so we can't cache the IO thread for the purpose |
(...skipping 20 matching lines...) Expand all Loading... |
155 }; | 157 }; |
156 | 158 |
157 void PollingProxyConfigService::AddObserver(Observer* observer) { | 159 void PollingProxyConfigService::AddObserver(Observer* observer) { |
158 core_->AddObserver(observer); | 160 core_->AddObserver(observer); |
159 } | 161 } |
160 | 162 |
161 void PollingProxyConfigService::RemoveObserver(Observer* observer) { | 163 void PollingProxyConfigService::RemoveObserver(Observer* observer) { |
162 core_->RemoveObserver(observer); | 164 core_->RemoveObserver(observer); |
163 } | 165 } |
164 | 166 |
165 bool PollingProxyConfigService::GetLatestProxyConfig(ProxyConfig* config) { | 167 ProxyConfigService::ConfigAvailability |
166 return core_->GetLatestProxyConfig(config); | 168 PollingProxyConfigService::GetLatestProxyConfig(ProxyConfig* config) { |
| 169 return core_->GetLatestProxyConfig(config) ? CONFIG_VALID : CONFIG_PENDING; |
167 } | 170 } |
168 | 171 |
169 void PollingProxyConfigService::OnLazyPoll() { | 172 void PollingProxyConfigService::OnLazyPoll() { |
170 core_->OnLazyPoll(); | 173 core_->OnLazyPoll(); |
171 } | 174 } |
172 | 175 |
173 PollingProxyConfigService::PollingProxyConfigService( | 176 PollingProxyConfigService::PollingProxyConfigService( |
174 base::TimeDelta poll_interval, | 177 base::TimeDelta poll_interval, |
175 GetConfigFunction get_config_func) | 178 GetConfigFunction get_config_func) |
176 : core_(new Core(poll_interval, get_config_func)) { | 179 : core_(new Core(poll_interval, get_config_func)) { |
177 } | 180 } |
178 | 181 |
179 PollingProxyConfigService::~PollingProxyConfigService() { | 182 PollingProxyConfigService::~PollingProxyConfigService() { |
180 core_->Orphan(); | 183 core_->Orphan(); |
181 } | 184 } |
182 | 185 |
183 void PollingProxyConfigService::CheckForChangesNow() { | 186 void PollingProxyConfigService::CheckForChangesNow() { |
184 core_->CheckForChangesNow(); | 187 core_->CheckForChangesNow(); |
185 } | 188 } |
186 | 189 |
187 } // namespace net | 190 } // namespace net |
OLD | NEW |