OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/profiler/scoped_tracker.h" |
12 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
13 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
14 #include "net/proxy/proxy_config.h" | 15 #include "net/proxy/proxy_config.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 // Reference-counted wrapper that does all the work (needs to be | 19 // Reference-counted wrapper that does all the work (needs to be |
19 // reference-counted since we post tasks between threads; may outlive | 20 // reference-counted since we post tasks between threads; may outlive |
20 // the parent PollingProxyConfigService). | 21 // the parent PollingProxyConfigService). |
21 class PollingProxyConfigService::Core | 22 class PollingProxyConfigService::Core |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 107 |
107 base::AutoLock l(lock_); | 108 base::AutoLock l(lock_); |
108 if (origin_loop_proxy_.get()) { | 109 if (origin_loop_proxy_.get()) { |
109 origin_loop_proxy_->PostTask( | 110 origin_loop_proxy_->PostTask( |
110 FROM_HERE, base::Bind(&Core::GetConfigCompleted, this, config)); | 111 FROM_HERE, base::Bind(&Core::GetConfigCompleted, this, config)); |
111 } | 112 } |
112 } | 113 } |
113 | 114 |
114 // Called after the worker thread has finished retrieving a configuration. | 115 // Called after the worker thread has finished retrieving a configuration. |
115 void GetConfigCompleted(const ProxyConfig& config) { | 116 void GetConfigCompleted(const ProxyConfig& config) { |
| 117 // TODO(pkasting): Remove ScopedTracker below once crbug.com/455942 is |
| 118 // fixed. |
| 119 tracked_objects::ScopedTracker tracking_profile( |
| 120 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 121 "455942 PollingProxyConfigService::Core::GetConfigCompleted")); |
116 DCHECK(poll_task_outstanding_); | 122 DCHECK(poll_task_outstanding_); |
117 poll_task_outstanding_ = false; | 123 poll_task_outstanding_ = false; |
118 | 124 |
119 if (!origin_loop_proxy_.get()) | 125 if (!origin_loop_proxy_.get()) |
120 return; // Was orphaned (parent has already been destroyed). | 126 return; // Was orphaned (parent has already been destroyed). |
121 | 127 |
122 DCHECK(origin_loop_proxy_->BelongsToCurrentThread()); | 128 DCHECK(origin_loop_proxy_->BelongsToCurrentThread()); |
123 | 129 |
124 if (!has_config_ || !last_config_.Equals(config)) { | 130 if (!has_config_ || !last_config_.Equals(config)) { |
125 // If the configuration has changed, notify the observers. | 131 // If the configuration has changed, notify the observers. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 191 |
186 PollingProxyConfigService::~PollingProxyConfigService() { | 192 PollingProxyConfigService::~PollingProxyConfigService() { |
187 core_->Orphan(); | 193 core_->Orphan(); |
188 } | 194 } |
189 | 195 |
190 void PollingProxyConfigService::CheckForChangesNow() { | 196 void PollingProxyConfigService::CheckForChangesNow() { |
191 core_->CheckForChangesNow(); | 197 core_->CheckForChangesNow(); |
192 } | 198 } |
193 | 199 |
194 } // namespace net | 200 } // namespace net |
OLD | NEW |