| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/base/load_log.h" |
| 6 |
| 7 namespace net { |
| 8 |
| 9 LoadLog::LoadLog() { |
| 10 } |
| 11 |
| 12 // static |
| 13 const char* LoadLog::EventTypeToString(EventType event) { |
| 14 switch (event) { |
| 15 #define EVENT_TYPE(label) case TYPE_ ## label: return #label; |
| 16 #include "net/base/load_log_event_type_list.h" |
| 17 #undef EVENT_TYPE |
| 18 } |
| 19 return NULL; |
| 20 } |
| 21 |
| 22 void LoadLog::Add(base::TimeTicks t, EventType event, EventPhase phase) { |
| 23 // Minor optimization. TODO(eroman): use StackVector instead. |
| 24 if (events_.empty()) |
| 25 events_.reserve(kMaxNumEntries / 2); |
| 26 |
| 27 // Enforce a bound of kMaxNumEntries -- when we reach it, make it so the |
| 28 // final entry in the list is |TYPE_LOG_TRUNCATED|. |
| 29 |
| 30 if (events_.size() + 1 == kMaxNumEntries) |
| 31 events_.push_back(Event(t, TYPE_LOG_TRUNCATED, PHASE_NONE)); |
| 32 |
| 33 if (events_.size() < kMaxNumEntries) |
| 34 events_.push_back(Event(t, event, phase)); |
| 35 } |
| 36 |
| 37 } // namespace net |
| OLD | NEW |