summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-22 16:37:55 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-22 16:37:55 +0000
commit988394e21a592204a8ef1c85d544b021cb6e3de1 (patch)
tree694da44963dbf0edc7b29c078d2db5995bc46f59 /net
parent9ed2193c225c8fb9b77972911b6c2723e73d64ce (diff)
downloadchromium_src-988394e21a592204a8ef1c85d544b021cb6e3de1.zip
chromium_src-988394e21a592204a8ef1c85d544b021cb6e3de1.tar.gz
chromium_src-988394e21a592204a8ef1c85d544b021cb6e3de1.tar.bz2
Remove hard-coded source ids from net_log_source_type_list.h,
as they're not needed. R=eroman@chromium.org BUG=114611 Review URL: http://codereview.chromium.org/9317059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/net_log.cc34
-rw-r--r--net/base/net_log.h14
-rw-r--r--net/base/net_log_source_type_list.h38
3 files changed, 51 insertions, 35 deletions
diff --git a/net/base/net_log.cc b/net/base/net_log.cc
index 9460f74..26ecdee 100644
--- a/net/base/net_log.cc
+++ b/net/base/net_log.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -79,28 +79,40 @@ const char* NetLog::EventTypeToString(EventType event) {
#define EVENT_TYPE(label) case TYPE_ ## label: return #label;
#include "net/base/net_log_event_type_list.h"
#undef EVENT_TYPE
+ default:
+ NOTREACHED();
+ return NULL;
}
- return NULL;
}
// static
-std::vector<NetLog::EventType> NetLog::GetAllEventTypes() {
- std::vector<NetLog::EventType> types;
-#define EVENT_TYPE(label) types.push_back(TYPE_ ## label);
-#include "net/base/net_log_event_type_list.h"
-#undef EVENT_TYPE
- return types;
+base::Value* NetLog::GetEventTypesAsValue() {
+ DictionaryValue* dict = new DictionaryValue();
+ for (int i = 0; i < EVENT_COUNT; ++i) {
+ dict->SetInteger(EventTypeToString(static_cast<EventType>(i)), i);
+ }
+ return dict;
}
// static
const char* NetLog::SourceTypeToString(SourceType source) {
switch (source) {
-#define SOURCE_TYPE(label, id) case id: return #label;
+#define SOURCE_TYPE(label) case SOURCE_ ## label: return #label;
#include "net/base/net_log_source_type_list.h"
#undef SOURCE_TYPE
+ default:
+ NOTREACHED();
+ return NULL;
}
- NOTREACHED();
- return NULL;
+}
+
+// static
+base::Value* NetLog::GetSourceTypesAsValue() {
+ DictionaryValue* dict = new DictionaryValue();
+ for (int i = 0; i < SOURCE_COUNT; ++i) {
+ dict->SetInteger(SourceTypeToString(static_cast<SourceType>(i)), i);
+ }
+ return dict;
}
// static
diff --git a/net/base/net_log.h b/net/base/net_log.h
index d97c622..f2b4e76 100644
--- a/net/base/net_log.h
+++ b/net/base/net_log.h
@@ -7,7 +7,6 @@
#pragma once
#include <string>
-#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -36,6 +35,7 @@ class NET_EXPORT NetLog {
#define EVENT_TYPE(label) TYPE_ ## label,
#include "net/base/net_log_event_type_list.h"
#undef EVENT_TYPE
+ EVENT_COUNT
};
// The 'phase' of an event trace (whether it marks the beginning or end
@@ -48,9 +48,10 @@ class NET_EXPORT NetLog {
// The "source" identifies the entity that generated the log message.
enum SourceType {
-#define SOURCE_TYPE(label, value) SOURCE_ ## label = value,
+#define SOURCE_TYPE(label) SOURCE_ ## label,
#include "net/base/net_log_source_type_list.h"
#undef SOURCE_TYPE
+ SOURCE_COUNT
};
// Identifies the entity that generated this log. The |id| field should
@@ -187,12 +188,17 @@ class NET_EXPORT NetLog {
// Returns a C-String symbolic name for |event_type|.
static const char* EventTypeToString(EventType event_type);
- // Returns a list of all the available EventTypes.
- static std::vector<EventType> GetAllEventTypes();
+ // Returns a dictionary that maps event type symbolic names to their enum
+ // values. Caller takes ownership of the returned Value.
+ static base::Value* GetEventTypesAsValue();
// Returns a C-String symbolic name for |source_type|.
static const char* SourceTypeToString(SourceType source_type);
+ // Returns a dictionary that maps source type symbolic names to their enum
+ // values. Caller takes ownership of the returned Value.
+ static base::Value* GetSourceTypesAsValue();
+
// Returns a C-String symbolic name for |event_phase|.
static const char* EventPhaseToString(EventPhase event_phase);
diff --git a/net/base/net_log_source_type_list.h b/net/base/net_log_source_type_list.h
index ea550bc..810906b 100644
--- a/net/base/net_log_source_type_list.h
+++ b/net/base/net_log_source_type_list.h
@@ -6,25 +6,23 @@
// directly within a block where the SOURCE_TYPE macro is defined.
// Used for global events which don't correspond to a particular entity.
-SOURCE_TYPE(NONE, 0)
+SOURCE_TYPE(NONE)
-SOURCE_TYPE(URL_REQUEST, 1)
-SOURCE_TYPE(SOCKET_STREAM, 2)
-SOURCE_TYPE(PROXY_SCRIPT_DECIDER, 3)
-SOURCE_TYPE(CONNECT_JOB, 4)
-SOURCE_TYPE(SOCKET, 5)
-SOURCE_TYPE(SPDY_SESSION, 6)
-SOURCE_TYPE(HOST_RESOLVER_IMPL_REQUEST, 7)
-SOURCE_TYPE(HOST_RESOLVER_IMPL_JOB, 8)
-SOURCE_TYPE(DISK_CACHE_ENTRY, 9)
-SOURCE_TYPE(MEMORY_CACHE_ENTRY, 10)
-SOURCE_TYPE(HTTP_STREAM_JOB, 11)
-SOURCE_TYPE(EXPONENTIAL_BACKOFF_THROTTLING, 12)
-SOURCE_TYPE(UDP_SOCKET, 13)
-SOURCE_TYPE(CERT_VERIFIER_JOB, 14)
-SOURCE_TYPE(HTTP_PIPELINED_CONNECTION, 15)
-SOURCE_TYPE(DOWNLOAD, 16)
-SOURCE_TYPE(FILESTREAM, 17)
-
-SOURCE_TYPE(COUNT, 18) // Always keep this as the last entry.
+SOURCE_TYPE(URL_REQUEST)
+SOURCE_TYPE(SOCKET_STREAM)
+SOURCE_TYPE(PROXY_SCRIPT_DECIDER)
+SOURCE_TYPE(CONNECT_JOB)
+SOURCE_TYPE(SOCKET)
+SOURCE_TYPE(SPDY_SESSION)
+SOURCE_TYPE(HOST_RESOLVER_IMPL_REQUEST)
+SOURCE_TYPE(HOST_RESOLVER_IMPL_JOB)
+SOURCE_TYPE(DISK_CACHE_ENTRY)
+SOURCE_TYPE(MEMORY_CACHE_ENTRY)
+SOURCE_TYPE(HTTP_STREAM_JOB)
+SOURCE_TYPE(EXPONENTIAL_BACKOFF_THROTTLING)
+SOURCE_TYPE(UDP_SOCKET)
+SOURCE_TYPE(CERT_VERIFIER_JOB)
+SOURCE_TYPE(HTTP_PIPELINED_CONNECTION)
+SOURCE_TYPE(DOWNLOAD)
+SOURCE_TYPE(FILESTREAM)