diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 19:59:36 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 19:59:36 +0000 |
commit | 60c4c41ce3ed1fa0697daf274233d84febf6233c (patch) | |
tree | 7b6bfe29f7b6526b4c63ce49ab7a7ffcd20d3bbf /net/base/load_log.h | |
parent | 3203c5e35bba5266fe1d149875c3a9815ee9c214 (diff) | |
download | chromium_src-60c4c41ce3ed1fa0697daf274233d84febf6233c.zip chromium_src-60c4c41ce3ed1fa0697daf274233d84febf6233c.tar.gz chromium_src-60c4c41ce3ed1fa0697daf274233d84febf6233c.tar.bz2 |
Improve the display of LoadLogs when truncation occurs.
Rather than drop all subsequent entries, we now preserve the final entry that was appended to the log.
This way, even if entries have been dropped, we can still infer what the total time was, and what the exit condition was.
Also makes LoadLog take the bound as a required parameter.
BUG=none
TEST=LoadLogUtilTest.DisplayOfTruncated
Review URL: http://codereview.chromium.org/363025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/load_log.h')
-rw-r--r-- | net/base/load_log.h | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/net/base/load_log.h b/net/base/load_log.h index 7ee5185..3f433ac 100644 --- a/net/base/load_log.h +++ b/net/base/load_log.h @@ -19,7 +19,6 @@ namespace net { // that it can be AddRef() / Release() across threads. class LoadLog : public base::RefCountedThreadSafe<LoadLog> { public: - enum EventType { #define EVENT_TYPE(label) TYPE_ ## label, #include "net/base/load_log_event_type_list.h" @@ -48,18 +47,20 @@ class LoadLog : public base::RefCountedThreadSafe<LoadLog> { EventPhase phase; }; - // The maximum size of |events_|. - enum { kMaxNumEntries = 40 }; - // Ordered set of events that were logged. // TODO(eroman): use a StackVector or array to avoid allocations. typedef std::vector<Event> EventList; - // Create a log, which can hold up to |kMaxNumEntries| Events. + // Value for max_num_entries to indicate the LoadLog has no size limit. + static const size_t kUnbounded = static_cast<size_t>(-1); + + // Creates a log, which can hold up to |max_num_entries| Events. + // If |max_num_entries| is |kUnbounded|, then the log can grow arbitrarily + // large. // - // If events are dropped because the log has grown too large, the final - // entry will be of type kLogTruncated. - LoadLog(); + // If events are dropped because the log has grown too large, the final entry + // will be overwritten. + explicit LoadLog(size_t max_num_entries); // -------------------------------------------------------------------------- @@ -93,6 +94,17 @@ class LoadLog : public base::RefCountedThreadSafe<LoadLog> { return events_; } + // Returns the number of entries that were dropped from the log because the + // maximum size had been reached. + size_t num_entries_truncated() const { + return num_entries_truncated_; + } + + // Returns the bound on the size of the log. + size_t max_num_entries() const { + return max_num_entries_; + } + // Returns a C-String symbolic name for |event|. static const char* EventTypeToString(EventType event); @@ -111,6 +123,8 @@ class LoadLog : public base::RefCountedThreadSafe<LoadLog> { ~LoadLog() {} EventList events_; + size_t num_entries_truncated_; + size_t max_num_entries_;; }; } // namespace net |