diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-01 00:46:33 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-01 00:46:33 +0000 |
commit | d643172a8573e7e75f325bec2125de8071bfd0fc (patch) | |
tree | 16d43bab4652624b87e1e7acfbecb63310a6e736 | |
parent | f5e7e8e162433ab6e8223c8b3da4feb64abddc33 (diff) | |
download | chromium_src-d643172a8573e7e75f325bec2125de8071bfd0fc.zip chromium_src-d643172a8573e7e75f325bec2125de8071bfd0fc.tar.gz chromium_src-d643172a8573e7e75f325bec2125de8071bfd0fc.tar.bz2 |
Reduce number of unnamed-type-template-args violations (mostly when passing values to DCHECK(), ASSERT_EQ(), etc.), generally by naming previously-anonymous enums. We've decided not to eliminate the warning entirely because doing so is only possible with tons of ugly static_cast<>()s in Mac code.
BUG=92247
TEST=Compiles
Review URL: http://codereview.chromium.org/7605019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99086 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base_paths.h | 2 | ||||
-rw-r--r-- | build/common.gypi | 12 | ||||
-rw-r--r-- | chrome/browser/chromeos/status/clock_menu_button.cc | 2 | ||||
-rw-r--r-- | chrome/browser/net/predictor.cc | 11 | ||||
-rw-r--r-- | chrome/browser/net/predictor.h | 2 | ||||
-rw-r--r-- | chrome/browser/net/predictor_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/password_manager/native_backend_gnome_x_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/common/chrome_notification_types.h | 2 | ||||
-rw-r--r-- | content/browser/geolocation/mock_location_provider.h | 2 | ||||
-rw-r--r-- | content/common/content_notification_types.h | 2 | ||||
-rw-r--r-- | content/common/media/media_stream_options.cc | 3 | ||||
-rw-r--r-- | content/common/media/media_stream_options.h | 4 | ||||
-rw-r--r-- | content/common/page_transition_types.h | 2 | ||||
-rw-r--r-- | ipc/ipc_channel_posix_unittest.cc | 22 | ||||
-rw-r--r-- | net/base/x509_cert_types_mac.cc | 12 | ||||
-rw-r--r-- | net/http/http_stream_parser.h | 6 | ||||
-rw-r--r-- | net/proxy/proxy_config.cc | 2 | ||||
-rw-r--r-- | net/proxy/proxy_config.h | 4 | ||||
-rw-r--r-- | net/proxy/proxy_info.cc | 2 | ||||
-rw-r--r-- | net/proxy/proxy_service.cc | 6 |
20 files changed, 52 insertions, 56 deletions
diff --git a/base/base_paths.h b/base/base_paths.h index f724c3f..708d8e8 100644 --- a/base/base_paths.h +++ b/base/base_paths.h @@ -19,7 +19,7 @@ namespace base { -enum { +enum BasePathKey { PATH_START = 0, DIR_CURRENT, // current directory diff --git a/build/common.gypi b/build/common.gypi index ea01182..b6f7fe8 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -1548,9 +1548,11 @@ '-Wno-unused-function', # Don't die on dtoa code that uses a char as an array index. '-Wno-char-subscripts', - # Survive EXPECT_EQ(unnamed_enum, unsigned int) -- see - # http://code.google.com/p/googletest/source/detail?r=446 . - # TODO(thakis): Use -isystem instead (http://crbug.com/58751 ) + # Especially needed for gtest macros using enum values from Mac + # system headers. + # TODO(pkasting): In C++11 this is legal, so this should be + # removed when we change to that. (This is also why we don't + # bother fixing all these cases today.) '-Wno-unnamed-type-template-args', ], 'cflags!': [ @@ -1673,9 +1675,7 @@ '-Wno-char-subscripts', # Clang spots more unused functions. '-Wno-unused-function', - # Survive EXPECT_EQ(unnamed_enum, unsigned int) -- see - # http://code.google.com/p/googletest/source/detail?r=446 . - # TODO(thakis): Use -isystem instead (http://crbug.com/58751 ). + # See comments on this flag higher up in this file. '-Wno-unnamed-type-template-args', # TODO(thakis): Reenable once the one instance this warns on # is fixed. diff --git a/chrome/browser/chromeos/status/clock_menu_button.cc b/chrome/browser/chromeos/status/clock_menu_button.cc index 3b0384c..ac5b0b6 100644 --- a/chrome/browser/chromeos/status/clock_menu_button.cc +++ b/chrome/browser/chromeos/status/clock_menu_button.cc @@ -27,7 +27,7 @@ namespace { // views::MenuItemView item ids -enum { +enum ClockMenuItem { CLOCK_DISPLAY_ITEM, CLOCK_OPEN_OPTIONS_ITEM }; diff --git a/chrome/browser/net/predictor.cc b/chrome/browser/net/predictor.cc index ffc5e57..7a2320ce 100644 --- a/chrome/browser/net/predictor.cc +++ b/chrome/browser/net/predictor.cc @@ -29,10 +29,9 @@ using base::TimeDelta; namespace chrome_browser_net { // static +const int Predictor::kPredictorReferrerVersion = 2; const double Predictor::kPreconnectWorthyExpectedValue = 0.8; -// static const double Predictor::kDNSPreresolutionWorthyExpectedValue = 0.1; -// static const double Predictor::kDiscardableExpectedValue = 0.05; // The goal is of trimming is to to reduce the importance (number of expected // subresources needed) by a factor of 2 after about 24 hours of uptime. We will @@ -45,13 +44,9 @@ const double Predictor::kDiscardableExpectedValue = 0.05; // system that uses a higher trim ratio when the list is large. // static const double Predictor::kReferrerTrimRatio = 0.97153; - -// static const TimeDelta Predictor::kDurationBetweenTrimmings = TimeDelta::FromHours(1); -// static const TimeDelta Predictor::kDurationBetweenTrimmingIncrements = TimeDelta::FromSeconds(15); -// static const size_t Predictor::kUrlsTrimmedPerIncrement = 5u; class Predictor::LookupRequest { @@ -606,7 +601,7 @@ void Predictor::TrimReferrersNow() { void Predictor::SerializeReferrers(ListValue* referral_list) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); referral_list->Clear(); - referral_list->Append(new base::FundamentalValue(PREDICTOR_REFERRER_VERSION)); + referral_list->Append(new base::FundamentalValue(kPredictorReferrerVersion)); for (Referrers::const_iterator it = referrers_.begin(); it != referrers_.end(); ++it) { // Serialize the list of subresource names. @@ -626,7 +621,7 @@ void Predictor::DeserializeReferrers(const ListValue& referral_list) { int format_version = -1; if (referral_list.GetSize() > 0 && referral_list.GetInteger(0, &format_version) && - format_version == PREDICTOR_REFERRER_VERSION) { + format_version == kPredictorReferrerVersion) { for (size_t i = 1; i < referral_list.GetSize(); ++i) { ListValue* motivator; if (!referral_list.GetList(i, &motivator)) { diff --git a/chrome/browser/net/predictor.h b/chrome/browser/net/predictor.h index f1f0bcb..dcd8006 100644 --- a/chrome/browser/net/predictor.h +++ b/chrome/browser/net/predictor.h @@ -53,7 +53,7 @@ class Predictor : public base::RefCountedThreadSafe<Predictor> { public: // A version number for prefs that are saved. This should be incremented when // we change the format so that we discard old data. - enum { PREDICTOR_REFERRER_VERSION = 2 }; + static const int kPredictorReferrerVersion; // |max_concurrent| specifies how many concurrent (parallel) prefetches will // be performed. Host lookups will be issued through |host_resolver|. diff --git a/chrome/browser/net/predictor_unittest.cc b/chrome/browser/net/predictor_unittest.cc index 58aab26..70a39c9 100644 --- a/chrome/browser/net/predictor_unittest.cc +++ b/chrome/browser/net/predictor_unittest.cc @@ -263,12 +263,12 @@ TEST_F(PredictorTest, MassiveConcurrentLookupTest) { // Return a motivation_list if we can find one for the given motivating_host (or // NULL if a match is not found). -static ListValue* FindSerializationMotivation( - const GURL& motivation, const ListValue& referral_list) { +static ListValue* FindSerializationMotivation(const GURL& motivation, + const ListValue& referral_list) { CHECK_LT(0u, referral_list.GetSize()); // Room for version. int format_version = -1; CHECK(referral_list.GetInteger(0, &format_version)); - CHECK_EQ(Predictor::PREDICTOR_REFERRER_VERSION, format_version); + CHECK_EQ(Predictor::kPredictorReferrerVersion, format_version); ListValue* motivation_list(NULL); for (size_t i = 1; i < referral_list.GetSize(); ++i) { referral_list.GetList(i, &motivation_list); @@ -284,7 +284,7 @@ static ListValue* FindSerializationMotivation( static ListValue* NewEmptySerializationList() { base::ListValue* list = new base::ListValue; list->Append( - new base::FundamentalValue(Predictor::PREDICTOR_REFERRER_VERSION)); + new base::FundamentalValue(Predictor::kPredictorReferrerVersion)); return list; } diff --git a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc index 1c4dd99..dc7e4fd 100644 --- a/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc +++ b/chrome/browser/password_manager/native_backend_gnome_x_unittest.cc @@ -47,7 +47,7 @@ struct MockKeyringItem { : value_uint32 == x.value_uint32; } - enum { UINT32, STRING } type; + enum Type { UINT32, STRING } type; uint32_t value_uint32; std::string value_string; }; diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h index 53ea779..b213792 100644 --- a/chrome/common/chrome_notification_types.h +++ b/chrome/common/chrome_notification_types.h @@ -10,7 +10,7 @@ namespace chrome { -enum { +enum NotificationType { NOTIFICATION_CHROME_START = content::NOTIFICATION_CONTENT_END, // Browser-window ---------------------------------------------------------- diff --git a/content/browser/geolocation/mock_location_provider.h b/content/browser/geolocation/mock_location_provider.h index 4bfee4a..35d1d05 100644 --- a/content/browser/geolocation/mock_location_provider.h +++ b/content/browser/geolocation/mock_location_provider.h @@ -32,7 +32,7 @@ class MockLocationProvider : public LocationProviderBase { virtual void OnPermissionGranted(const GURL& requesting_frame); Geoposition position_; - enum { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_; + enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_; GURL permission_granted_url_; MockLocationProvider** self_ref_; diff --git a/content/common/content_notification_types.h b/content/common/content_notification_types.h index d0d5ee9..14e72f7 100644 --- a/content/common/content_notification_types.h +++ b/content/common/content_notification_types.h @@ -11,7 +11,7 @@ // namespace content { -enum { +enum NotificationType { NOTIFICATION_CONTENT_START = 0, // General ----------------------------------------------------------------- diff --git a/content/common/media/media_stream_options.cc b/content/common/media/media_stream_options.cc index f4f38dc..174461d 100644 --- a/content/common/media/media_stream_options.cc +++ b/content/common/media/media_stream_options.cc @@ -6,6 +6,9 @@ namespace media_stream { +// static +const int StreamDeviceInfo::kNoId = -1; + StreamDeviceInfo::StreamDeviceInfo() : stream_type(kNoService), in_use(false), diff --git a/content/common/media/media_stream_options.h b/content/common/media/media_stream_options.h index 7569fdc..de738e3 100644 --- a/content/common/media/media_stream_options.h +++ b/content/common/media/media_stream_options.h @@ -42,14 +42,14 @@ enum MediaStreamType { // StreamDeviceInfo describes information about a device. struct StreamDeviceInfo { + static const int kNoId; + StreamDeviceInfo(); StreamDeviceInfo(MediaStreamType service_param, const std::string& name_param, const std::string& device_param, bool opened); - enum { kNoId = -1 }; - // Describes the capture type. MediaStreamType stream_type; // Friendly name of the device. diff --git a/content/common/page_transition_types.h b/content/common/page_transition_types.h index d0c18d1..357b433 100644 --- a/content/common/page_transition_types.h +++ b/content/common/page_transition_types.h @@ -21,7 +21,7 @@ class PageTransition { // // A type is made of a core value and a set of qualifiers. A type has one // core value and 0 or or more qualifiers. - enum { + enum TypeEnum { // User got to this page by clicking a link on another page. LINK = 0, diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc index 9d9c70a..6f37ae6 100644 --- a/ipc/ipc_channel_posix_unittest.cc +++ b/ipc/ipc_channel_posix_unittest.cc @@ -23,9 +23,7 @@ namespace { -enum { - QUIT_MESSAGE = 47 -}; +static const uint32 kQuitMessage = 47; class IPCChannelPosixTestListener : public IPC::Channel::Listener { public: @@ -44,7 +42,7 @@ class IPCChannelPosixTestListener : public IPC::Channel::Listener { virtual ~IPCChannelPosixTestListener() {} virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { - EXPECT_EQ(message.type(), QUIT_MESSAGE); + EXPECT_EQ(message.type(), kQuitMessage); status_ = MESSAGE_RECEIVED; QuitRunLoop(); return true; @@ -88,7 +86,7 @@ class IPCChannelPosixTestListener : public IPC::Channel::Listener { // The current status of the listener. STATUS status_; // If |quit_only_on_message_| then the listener will only break out of - // the run loop when the QUIT_MESSAGE is received. + // the run loop when kQuitMessage is received. bool quit_only_on_message_; }; @@ -144,7 +142,7 @@ void IPCChannelPosixTest::SetUpSocket(IPC::ChannelHandle *handle, if (mode == IPC::Channel::MODE_NAMED_SERVER) { // Only one server at a time. Cleanup garbage if it exists. unlink(name.c_str()); - // Make sure the path we need exists. + // Make sure the path we need exists. FilePath path(name); FilePath dir_path = path.DirName(); ASSERT_TRUE(file_util::CreateDirectory(dir_path)); @@ -229,8 +227,8 @@ TEST_F(IPCChannelPosixTest, AdvancedConnected) { SpinRunLoop(TestTimeouts::action_max_timeout_ms()); ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status()); ASSERT_TRUE(channel.HasAcceptedConnection()); - IPC::Message* message = new IPC::Message(0, // routing_id - QUIT_MESSAGE, // message type + IPC::Message* message = new IPC::Message(0, // routing_id + kQuitMessage, // message type IPC::Message::PRIORITY_NORMAL); channel.Send(message); SpinRunLoop(TestTimeouts::action_timeout_ms()); @@ -268,8 +266,8 @@ TEST_F(IPCChannelPosixTest, ResetState) { SpinRunLoop(TestTimeouts::action_max_timeout_ms()); ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status()); ASSERT_TRUE(channel.HasAcceptedConnection()); - IPC::Message* message = new IPC::Message(0, // routing_id - QUIT_MESSAGE, // message type + IPC::Message* message = new IPC::Message(0, // routing_id + kQuitMessage, // message type IPC::Message::PRIORITY_NORMAL); channel.Send(message); SpinRunLoop(TestTimeouts::action_timeout_ms()); @@ -327,8 +325,8 @@ TEST_F(IPCChannelPosixTest, MultiConnection) { EXPECT_EQ(exit_code, 0); ASSERT_EQ(IPCChannelPosixTestListener::DENIED, listener.status()); ASSERT_TRUE(channel.HasAcceptedConnection()); - IPC::Message* message = new IPC::Message(0, // routing_id - QUIT_MESSAGE, // message type + IPC::Message* message = new IPC::Message(0, // routing_id + kQuitMessage, // message type IPC::Message::PRIORITY_NORMAL); channel.Send(message); SpinRunLoop(TestTimeouts::action_timeout_ms()); diff --git a/net/base/x509_cert_types_mac.cc b/net/base/x509_cert_types_mac.cc index a45dc71..8fb0d8d 100644 --- a/net/base/x509_cert_types_mac.cc +++ b/net/base/x509_cert_types_mac.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -36,11 +36,7 @@ const CSSM_OID* kOIDs[] = { // BER DistinguishedName structure. struct KeyValuePair { - CSSM_OID key; - int value_type; - CSSM_DATA value; - - enum { + enum ValueType { kTypeOther = 0, kTypePrintableString, kTypeIA5String, @@ -49,6 +45,10 @@ struct KeyValuePair { kTypeBMPString, kTypeUniversalString, }; + + CSSM_OID key; + ValueType value_type; + CSSM_DATA value; }; const SecAsn1Template kStringValueTemplate[] = { diff --git a/net/http/http_stream_parser.h b/net/http/http_stream_parser.h index 40a4a0a..8853728 100644 --- a/net/http/http_stream_parser.h +++ b/net/http/http_stream_parser.h @@ -94,16 +94,16 @@ class HttpStreamParser : public ChunkCallback { // The number of bytes by which the header buffer is grown when it reaches // capacity. - enum { kHeaderBufInitialSize = 4096 }; + static const int kHeaderBufInitialSize = 4 * 1024; // 4K // |kMaxHeaderBufSize| is the number of bytes that the response headers can // grow to. If the body start is not found within this range of the // response, the transaction will fail with ERR_RESPONSE_HEADERS_TOO_BIG. // Note: |kMaxHeaderBufSize| should be a multiple of |kHeaderBufInitialSize|. - enum { kMaxHeaderBufSize = 256 * 1024 }; // 256 kilobytes. + static const int kMaxHeaderBufSize = kHeaderBufInitialSize * 64; // 256K // The maximum sane buffer size. - enum { kMaxBufSize = 2 * 1024 * 1024 }; // 2 megabytes. + static const int kMaxBufSize = 2 * 1024 * 1024; // 2M // Handle callbacks. void OnIOComplete(int result); diff --git a/net/proxy/proxy_config.cc b/net/proxy/proxy_config.cc index 42589a9..d160fa4 100644 --- a/net/proxy/proxy_config.cc +++ b/net/proxy/proxy_config.cc @@ -159,7 +159,7 @@ ProxyServer* ProxyConfig::ProxyRules::MapUrlSchemeToProxyNoFallback( } ProxyConfig::ProxyConfig() - : auto_detect_(false), pac_mandatory_(false), id_(INVALID_ID) { + : auto_detect_(false), pac_mandatory_(false), id_(kInvalidConfigID) { } ProxyConfig::ProxyConfig(const ProxyConfig& config) diff --git a/net/proxy/proxy_config.h b/net/proxy/proxy_config.h index 0c353ce..f666e93 100644 --- a/net/proxy/proxy_config.h +++ b/net/proxy/proxy_config.h @@ -110,7 +110,7 @@ class NET_EXPORT ProxyConfig { typedef int ID; // Indicates an invalid proxy config. - enum { INVALID_ID = 0 }; + static const ID kInvalidConfigID = 0; ProxyConfig(); ProxyConfig(const ProxyConfig& config); @@ -120,7 +120,7 @@ class NET_EXPORT ProxyConfig { // Used to numerically identify this configuration. ID id() const { return id_; } void set_id(int id) { id_ = id; } - bool is_valid() const { return id_ != INVALID_ID; } + bool is_valid() const { return id_ != kInvalidConfigID; } // Returns true if the given config is equivalent to this config. bool Equals(const ProxyConfig& other) const; diff --git a/net/proxy/proxy_info.cc b/net/proxy/proxy_info.cc index 85d6cae..b7d40a0 100644 --- a/net/proxy/proxy_info.cc +++ b/net/proxy/proxy_info.cc @@ -8,7 +8,7 @@ namespace net { -ProxyInfo::ProxyInfo() : config_id_(ProxyConfig::INVALID_ID) { +ProxyInfo::ProxyInfo() : config_id_(ProxyConfig::kInvalidConfigID) { } ProxyInfo::~ProxyInfo() { diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index 643b9be..c8f3620 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -308,7 +308,7 @@ class ProxyService::PacRequest results_(results), url_(url), resolve_job_(NULL), - config_id_(ProxyConfig::INVALID_ID), + config_id_(ProxyConfig::kInvalidConfigID), net_log_(net_log) { DCHECK(user_callback); } @@ -375,7 +375,7 @@ class ProxyService::PacRequest // Reset the state associated with in-progress-resolve. resolve_job_ = NULL; - config_id_ = ProxyConfig::INVALID_ID; + config_id_ = ProxyConfig::kInvalidConfigID; return service_->DidFinishResolvingProxy(results_, result_code, net_log_); } @@ -599,7 +599,7 @@ int ProxyService::TryToCompleteSynchronously(const GURL& url, if (current_state_ != STATE_READY) return ERR_IO_PENDING; // Still initializing. - DCHECK_NE(config_.id(), ProxyConfig::INVALID_ID); + DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID); // If it was impossible to fetch or parse the PAC script, we cannot complete // the request here and bail out. |