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/test_net_log.h" | 5 #include "net/log/test_net_log.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/synchronization/lock.h" | 8 #include "base/synchronization/lock.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void Clear() { | 43 void Clear() { |
44 base::AutoLock lock(lock_); | 44 base::AutoLock lock(lock_); |
45 entry_list_.clear(); | 45 entry_list_.clear(); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 // ThreadSafeObserver implementation: | 49 // ThreadSafeObserver implementation: |
50 void OnAddEntry(const NetLog::Entry& entry) override { | 50 void OnAddEntry(const NetLog::Entry& entry) override { |
51 // Using Dictionaries instead of Values makes checking values a little | 51 // Using Dictionaries instead of Values makes checking values a little |
52 // simpler. | 52 // simpler. |
53 base::DictionaryValue* param_dict = nullptr; | 53 scoped_ptr<base::DictionaryValue> param_dict = |
54 base::Value* param_value = entry.ParametersToValue(); | 54 base::DictionaryValue::From(entry.ParametersToValue()); |
55 if (param_value && !param_value->GetAsDictionary(¶m_dict)) | |
56 delete param_value; | |
57 | 55 |
58 // Only need to acquire the lock when accessing class variables. | 56 // Only need to acquire the lock when accessing class variables. |
59 base::AutoLock lock(lock_); | 57 base::AutoLock lock(lock_); |
60 entry_list_.push_back(TestNetLogEntry( | 58 entry_list_.push_back(TestNetLogEntry(entry.type(), base::TimeTicks::Now(), |
61 entry.type(), base::TimeTicks::Now(), entry.source(), entry.phase(), | 59 entry.source(), entry.phase(), |
62 scoped_ptr<base::DictionaryValue>(param_dict))); | 60 std::move(param_dict))); |
63 } | 61 } |
64 | 62 |
65 // Needs to be "mutable" to use it in GetEntries(). | 63 // Needs to be "mutable" to use it in GetEntries(). |
66 mutable base::Lock lock_; | 64 mutable base::Lock lock_; |
67 | 65 |
68 TestNetLogEntry::List entry_list_; | 66 TestNetLogEntry::List entry_list_; |
69 | 67 |
70 DISALLOW_COPY_AND_ASSIGN(Observer); | 68 DISALLOW_COPY_AND_ASSIGN(Observer); |
71 }; | 69 }; |
72 | 70 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 125 |
128 void BoundTestNetLog::Clear() { | 126 void BoundTestNetLog::Clear() { |
129 test_net_log_.Clear(); | 127 test_net_log_.Clear(); |
130 } | 128 } |
131 | 129 |
132 void BoundTestNetLog::SetCaptureMode(NetLogCaptureMode capture_mode) { | 130 void BoundTestNetLog::SetCaptureMode(NetLogCaptureMode capture_mode) { |
133 test_net_log_.SetCaptureMode(capture_mode); | 131 test_net_log_.SetCaptureMode(capture_mode); |
134 } | 132 } |
135 | 133 |
136 } // namespace net | 134 } // namespace net |
OLD | NEW |