diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-22 00:36:46 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-22 00:36:46 +0000 |
commit | 92056b95525a92217684e0b3df68cf371d77fd55 (patch) | |
tree | 0d50a952b902b3afda45064078e7b7316facba80 | |
parent | 950e1eb9ffe522a8acec921203182f5765461a2f (diff) | |
download | chromium_src-92056b95525a92217684e0b3df68cf371d77fd55.zip chromium_src-92056b95525a92217684e0b3df68cf371d77fd55.tar.gz chromium_src-92056b95525a92217684e0b3df68cf371d77fd55.tar.bz2 |
Address a TODO about not duplicating the name --> value mapping for NetLog::Source.
Review URL: http://codereview.chromium.org/2131024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47977 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/dom_ui/net_internals_ui.cc | 13 | ||||
-rw-r--r-- | net/base/net_log.h | 10 | ||||
-rw-r--r-- | net/base/net_log_source_type_list.h | 15 | ||||
-rw-r--r-- | net/net.gyp | 1 |
4 files changed, 23 insertions, 16 deletions
diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc index c9af90a..9c2611d 100644 --- a/chrome/browser/dom_ui/net_internals_ui.cc +++ b/chrome/browser/dom_ui/net_internals_ui.cc @@ -578,18 +578,13 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( // Tell the javascript about the relationship between source type enums and // their symbolic name. - // TODO(eroman): Don't duplicate the values, it will never stay up to date! { DictionaryValue* dict = new DictionaryValue(); - dict->SetInteger(L"NONE", net::NetLog::SOURCE_NONE); - dict->SetInteger(L"URL_REQUEST", net::NetLog::SOURCE_URL_REQUEST); - dict->SetInteger(L"SOCKET_STREAM", net::NetLog::SOURCE_SOCKET_STREAM); - dict->SetInteger(L"INIT_PROXY_RESOLVER", - net::NetLog::SOURCE_INIT_PROXY_RESOLVER); - dict->SetInteger(L"CONNECT_JOB", net::NetLog::SOURCE_CONNECT_JOB); - dict->SetInteger(L"SOCKET", net::NetLog::SOURCE_SOCKET); - dict->SetInteger(L"SPDY_SESSION", net::NetLog::SOURCE_SPDY_SESSION); + int i = 0; +#define SOURCE_TYPE(label) dict->SetInteger(ASCIIToWide(# label), i++); +#include "net/base/net_log_source_type_list.h" +#undef SOURCE_TYPE CallJavascriptFunction(L"g_browser.receivedLogSourceTypeConstants", dict); } diff --git a/net/base/net_log.h b/net/base/net_log.h index 02f0a4b..619b57b 100644 --- a/net/base/net_log.h +++ b/net/base/net_log.h @@ -53,13 +53,9 @@ class NetLog { // The "source" identifies the entity that generated the log message. enum SourceType { - SOURCE_NONE, - SOURCE_URL_REQUEST, - SOURCE_SOCKET_STREAM, - SOURCE_INIT_PROXY_RESOLVER, - SOURCE_CONNECT_JOB, - SOURCE_SOCKET, - SOURCE_SPDY_SESSION, +#define SOURCE_TYPE(label) SOURCE_ ## label, +#include "net/base/net_log_source_type_list.h" +#undef SOURCE_TYPE }; // Identifies the entity that generated this log. The |id| field should diff --git a/net/base/net_log_source_type_list.h b/net/base/net_log_source_type_list.h new file mode 100644 index 0000000..9d29826 --- /dev/null +++ b/net/base/net_log_source_type_list.h @@ -0,0 +1,15 @@ +// Copyright (c) 2010 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. + +// NOTE: No header guards are used, since this file is intended to be expanded +// directly within a block where the SOURCE_TYPE macro is defined. + +SOURCE_TYPE(NONE) +SOURCE_TYPE(URL_REQUEST) +SOURCE_TYPE(SOCKET_STREAM) +SOURCE_TYPE(INIT_PROXY_RESOLVER) +SOURCE_TYPE(CONNECT_JOB) +SOURCE_TYPE(SOCKET) +SOURCE_TYPE(SPDY_SESSION) + diff --git a/net/net.gyp b/net/net.gyp index 85daf0c..3a0dcb6 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -107,6 +107,7 @@ 'base/net_log.cc', 'base/net_log.h', 'base/net_log_event_type_list.h', + 'base/net_log_source_type_list.h', 'base/net_module.cc', 'base/net_module.h', 'base/net_util.cc', |