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/log/net_log.h" | 5 #include "net/log/net_log.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/stl_util.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 std::unique_ptr<base::Value> NetLogBoolCallback( | 22 std::unique_ptr<base::Value> NetLogBoolCallback( |
22 const char* name, | 23 const char* name, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 UpdateIsCapturing(); | 169 UpdateIsCapturing(); |
169 } | 170 } |
170 | 171 |
171 void NetLog::UpdateIsCapturing() { | 172 void NetLog::UpdateIsCapturing() { |
172 lock_.AssertAcquired(); | 173 lock_.AssertAcquired(); |
173 base::subtle::NoBarrier_Store(&is_capturing_, observers_.size() ? 1 : 0); | 174 base::subtle::NoBarrier_Store(&is_capturing_, observers_.size() ? 1 : 0); |
174 } | 175 } |
175 | 176 |
176 bool NetLog::HasObserver(ThreadSafeObserver* observer) { | 177 bool NetLog::HasObserver(ThreadSafeObserver* observer) { |
177 lock_.AssertAcquired(); | 178 lock_.AssertAcquired(); |
178 auto it = std::find(observers_.begin(), observers_.end(), observer); | 179 return base::ContainsValue(observers_, observer); |
179 return it != observers_.end(); | |
180 } | 180 } |
181 | 181 |
182 // static | 182 // static |
183 std::string NetLog::TickCountToString(const base::TimeTicks& time) { | 183 std::string NetLog::TickCountToString(const base::TimeTicks& time) { |
184 int64_t delta_time = (time - base::TimeTicks()).InMilliseconds(); | 184 int64_t delta_time = (time - base::TimeTicks()).InMilliseconds(); |
185 return base::Int64ToString(delta_time); | 185 return base::Int64ToString(delta_time); |
186 } | 186 } |
187 | 187 |
188 // static | 188 // static |
189 const char* NetLog::EventTypeToString(NetLogEventType event) { | 189 const char* NetLog::EventTypeToString(NetLogEventType event) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 NetLogEntryData entry_data(type, source, phase, base::TimeTicks::Now(), | 291 NetLogEntryData entry_data(type, source, phase, base::TimeTicks::Now(), |
292 parameters_callback); | 292 parameters_callback); |
293 | 293 |
294 // Notify all of the log observers. | 294 // Notify all of the log observers. |
295 base::AutoLock lock(lock_); | 295 base::AutoLock lock(lock_); |
296 for (auto* observer : observers_) | 296 for (auto* observer : observers_) |
297 observer->OnAddEntryData(entry_data); | 297 observer->OnAddEntryData(entry_data); |
298 } | 298 } |
299 | 299 |
300 } // namespace net | 300 } // namespace net |
OLD | NEW |