diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 03:01:09 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 03:01:09 +0000 |
commit | 54e1377ea309c5d8ab318ee9691b46249d7441b6 (patch) | |
tree | 8471e44056027dff255ff5b22ba083a9482b41c3 /net/base/load_log.cc | |
parent | 672eca0fd191acd39c28430d1ed1f327594faff8 (diff) | |
download | chromium_src-54e1377ea309c5d8ab318ee9691b46249d7441b6.zip chromium_src-54e1377ea309c5d8ab318ee9691b46249d7441b6.tar.gz chromium_src-54e1377ea309c5d8ab318ee9691b46249d7441b6.tar.bz2 |
Implement LoadLog, and hook up HostResolverImpl to LoadLog.
The functionality in load_log_util.h is currently unused, but since it motivates the implementation of LoadLog, figured it should be included with this review.
Note that I decided against defining the loggable event types as LoadStates, since I wanted more flexibility in adding crazy stuff, and they really seem too implementation specific to be in LoadStates.
BUG=http://crbug.com/14478
TEST=net_unittests
Review URL: http://codereview.chromium.org/165404
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/load_log.cc')
-rw-r--r-- | net/base/load_log.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/net/base/load_log.cc b/net/base/load_log.cc new file mode 100644 index 0000000..120a58b --- /dev/null +++ b/net/base/load_log.cc @@ -0,0 +1,37 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/base/load_log.h" + +namespace net { + +LoadLog::LoadLog() { +} + +// static +const char* LoadLog::EventTypeToString(EventType event) { + switch (event) { +#define EVENT_TYPE(label) case TYPE_ ## label: return #label; +#include "net/base/load_log_event_type_list.h" +#undef EVENT_TYPE + } + return NULL; +} + +void LoadLog::Add(base::TimeTicks t, EventType event, EventPhase phase) { + // Minor optimization. TODO(eroman): use StackVector instead. + if (events_.empty()) + events_.reserve(kMaxNumEntries / 2); + + // Enforce a bound of kMaxNumEntries -- when we reach it, make it so the + // final entry in the list is |TYPE_LOG_TRUNCATED|. + + if (events_.size() + 1 == kMaxNumEntries) + events_.push_back(Event(t, TYPE_LOG_TRUNCATED, PHASE_NONE)); + + if (events_.size() < kMaxNumEntries) + events_.push_back(Event(t, event, phase)); +} + +} // namespace net |