| 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 #ifndef NET_BASE_CAPTURING_NET_LOG_H_ | 5 #ifndef NET_BASE_CAPTURING_NET_LOG_H_ |
| 6 #define NET_BASE_CAPTURING_NET_LOG_H_ | 6 #define NET_BASE_CAPTURING_NET_LOG_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 base::TimeTicks time; | 65 base::TimeTicks time; |
| 66 Source source; | 66 Source source; |
| 67 EventPhase phase; | 67 EventPhase phase; |
| 68 scoped_ptr<base::DictionaryValue> params; | 68 scoped_ptr<base::DictionaryValue> params; |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 // Ordered set of entries that were logged. | 71 // Ordered set of entries that were logged. |
| 72 typedef std::vector<CapturedEntry> CapturedEntryList; | 72 typedef std::vector<CapturedEntry> CapturedEntryList; |
| 73 | 73 |
| 74 CapturingNetLog(); | 74 CapturingNetLog(); |
| 75 virtual ~CapturingNetLog(); | 75 ~CapturingNetLog() override; |
| 76 | 76 |
| 77 void SetLogLevel(LogLevel log_level); | 77 void SetLogLevel(LogLevel log_level); |
| 78 | 78 |
| 79 // Below methods are forwarded to capturing_net_log_observer_. | 79 // Below methods are forwarded to capturing_net_log_observer_. |
| 80 void GetEntries(CapturedEntryList* entry_list) const; | 80 void GetEntries(CapturedEntryList* entry_list) const; |
| 81 void GetEntriesForSource(Source source, CapturedEntryList* entry_list) const; | 81 void GetEntriesForSource(Source source, CapturedEntryList* entry_list) const; |
| 82 size_t GetSize() const; | 82 size_t GetSize() const; |
| 83 void Clear(); | 83 void Clear(); |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 // Observer is an implementation of NetLog::ThreadSafeObserver | 86 // Observer is an implementation of NetLog::ThreadSafeObserver |
| 87 // that saves messages to a bounded buffer. It is intended for testing only, | 87 // that saves messages to a bounded buffer. It is intended for testing only, |
| 88 // and is part of the net_test_support project. | 88 // and is part of the net_test_support project. |
| 89 class Observer : public NetLog::ThreadSafeObserver { | 89 class Observer : public NetLog::ThreadSafeObserver { |
| 90 public: | 90 public: |
| 91 Observer(); | 91 Observer(); |
| 92 virtual ~Observer(); | 92 ~Observer() override; |
| 93 | 93 |
| 94 // Returns the list of all entries in the log. | 94 // Returns the list of all entries in the log. |
| 95 void GetEntries(CapturedEntryList* entry_list) const; | 95 void GetEntries(CapturedEntryList* entry_list) const; |
| 96 | 96 |
| 97 // Fills |entry_list| with all entries in the log from the specified Source. | 97 // Fills |entry_list| with all entries in the log from the specified Source. |
| 98 void GetEntriesForSource(Source source, | 98 void GetEntriesForSource(Source source, |
| 99 CapturedEntryList* entry_list) const; | 99 CapturedEntryList* entry_list) const; |
| 100 | 100 |
| 101 // Returns number of entries in the log. | 101 // Returns number of entries in the log. |
| 102 size_t GetSize() const; | 102 size_t GetSize() const; |
| 103 | 103 |
| 104 void Clear(); | 104 void Clear(); |
| 105 | 105 |
| 106 private: | 106 private: |
| 107 // ThreadSafeObserver implementation: | 107 // ThreadSafeObserver implementation: |
| 108 virtual void OnAddEntry(const Entry& entry) override; | 108 void OnAddEntry(const Entry& entry) override; |
| 109 | 109 |
| 110 // Needs to be "mutable" so can use it in GetEntries(). | 110 // Needs to be "mutable" so can use it in GetEntries(). |
| 111 mutable base::Lock lock_; | 111 mutable base::Lock lock_; |
| 112 | 112 |
| 113 CapturedEntryList captured_entries_; | 113 CapturedEntryList captured_entries_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(Observer); | 115 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 Observer capturing_net_log_observer_; | 118 Observer capturing_net_log_observer_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 private: | 152 private: |
| 153 CapturingNetLog capturing_net_log_; | 153 CapturingNetLog capturing_net_log_; |
| 154 const BoundNetLog net_log_; | 154 const BoundNetLog net_log_; |
| 155 | 155 |
| 156 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); | 156 DISALLOW_COPY_AND_ASSIGN(CapturingBoundNetLog); |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 } // namespace net | 159 } // namespace net |
| 160 | 160 |
| 161 #endif // NET_BASE_CAPTURING_NET_LOG_H_ | 161 #endif // NET_BASE_CAPTURING_NET_LOG_H_ |
| OLD | NEW |