| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_LOAD_LOG_H_ | 5 #ifndef NET_BASE_LOAD_LOG_H_ |
| 6 #define NET_BASE_LOAD_LOG_H_ | 6 #define NET_BASE_LOAD_LOG_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 static void AddStringLiteral(LoadLog* log, const char* literal) { | 135 static void AddStringLiteral(LoadLog* log, const char* literal) { |
| 136 if (log) | 136 if (log) |
| 137 log->Add(Entry(base::TimeTicks::Now(), literal)); | 137 log->Add(Entry(base::TimeTicks::Now(), literal)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 static void AddString(LoadLog* log, const std::string& string) { | 140 static void AddString(LoadLog* log, const std::string& string) { |
| 141 if (log) | 141 if (log) |
| 142 log->Add(Entry(base::TimeTicks::Now(), string)); | 142 log->Add(Entry(base::TimeTicks::Now(), string)); |
| 143 } | 143 } |
| 144 | 144 |
| 145 static void AddErrorCode(LoadLog* log, int error) { |
| 146 if (log) |
| 147 log->Add(Entry(base::TimeTicks::Now(), error)); |
| 148 } |
| 149 |
| 150 static bool IsUnbounded(const LoadLog* log) { |
| 151 return log && log->is_unbounded(); |
| 152 } |
| 153 |
| 145 // -------------------------------------------------------------------------- | 154 // -------------------------------------------------------------------------- |
| 146 | 155 |
| 147 // Returns the list of all entries in the log. | 156 // Returns the list of all entries in the log. |
| 148 const EntryList& entries() const { | 157 const EntryList& entries() const { |
| 149 return entries_; | 158 return entries_; |
| 150 } | 159 } |
| 151 | 160 |
| 152 // Returns the number of entries that were dropped from the log because the | 161 // Returns the number of entries that were dropped from the log because the |
| 153 // maximum size had been reached. | 162 // maximum size had been reached. |
| 154 size_t num_entries_truncated() const { | 163 size_t num_entries_truncated() const { |
| 155 return num_entries_truncated_; | 164 return num_entries_truncated_; |
| 156 } | 165 } |
| 157 | 166 |
| 158 // Returns the bound on the size of the log. | 167 // Returns the bound on the size of the log. |
| 159 size_t max_num_entries() const { | 168 size_t max_num_entries() const { |
| 160 return max_num_entries_; | 169 return max_num_entries_; |
| 161 } | 170 } |
| 162 | 171 |
| 172 bool is_unbounded() const { |
| 173 return max_num_entries_ == kUnbounded; |
| 174 } |
| 175 |
| 163 // Returns a C-String symbolic name for |event|. | 176 // Returns a C-String symbolic name for |event|. |
| 164 static const char* EventTypeToString(EventType event_type); | 177 static const char* EventTypeToString(EventType event_type); |
| 165 | 178 |
| 166 void Add(const Entry& entry); | 179 void Add(const Entry& entry); |
| 167 | 180 |
| 168 // Copies all entries from |log|, appending it to the end of |this|. | 181 // Copies all entries from |log|, appending it to the end of |this|. |
| 169 void Append(const LoadLog* log); | 182 void Append(const LoadLog* log); |
| 170 | 183 |
| 171 private: | 184 private: |
| 172 friend class base::RefCountedThreadSafe<LoadLog>; | 185 friend class base::RefCountedThreadSafe<LoadLog>; |
| 173 | 186 |
| 174 ~LoadLog() {} | 187 ~LoadLog() {} |
| 175 | 188 |
| 176 EntryList entries_; | 189 EntryList entries_; |
| 177 size_t num_entries_truncated_; | 190 size_t num_entries_truncated_; |
| 178 size_t max_num_entries_;; | 191 size_t max_num_entries_;; |
| 179 }; | 192 }; |
| 180 | 193 |
| 181 } // namespace net | 194 } // namespace net |
| 182 | 195 |
| 183 #endif // NET_BASE_LOAD_LOG_H_ | 196 #endif // NET_BASE_LOAD_LOG_H_ |
| OLD | NEW |