diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 21:38:41 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 21:38:41 +0000 |
commit | 47a961eba1c75bf86b2dbdb9d39ac63101890328 (patch) | |
tree | b9608f5e5c45fb779f1264d96772069c37e31953 | |
parent | b7969209a311ca384eceacef7d67743f2ffd792d (diff) | |
download | chromium_src-47a961eba1c75bf86b2dbdb9d39ac63101890328.zip chromium_src-47a961eba1c75bf86b2dbdb9d39ac63101890328.tar.gz chromium_src-47a961eba1c75bf86b2dbdb9d39ac63101890328.tar.bz2 |
Changed used of ASSERT() to DCHECK().
Removed dead code.
Cleaned up some tests.
BUG=none
TEST=trybots
Review URL: http://codereview.chromium.org/2128001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47315 0039d316-1c4b-4281-b951-d872f2087c98
14 files changed, 70 insertions, 54 deletions
diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc index f47036a..895ab3c 100644 --- a/chrome/browser/sync/sync_setup_wizard_unittest.cc +++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "testing/gtest/include/gtest/gtest.h" +#include "chrome/browser/sync/sync_setup_wizard.h" #include "base/json/json_writer.h" #include "base/scoped_ptr.h" @@ -14,16 +14,16 @@ #include "chrome/browser/sync/profile_sync_factory_mock.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/sync_setup_flow.h" -#include "chrome/browser/sync/sync_setup_wizard.h" #include "chrome/common/pref_names.h" #include "chrome/test/browser_with_test_window_test.h" #include "chrome/test/testing_profile.h" #include "chrome/test/test_browser_window.h" +#include "testing/gtest/include/gtest/gtest.h" -static const char* kTestUser = "chrome.p13n.test@gmail.com"; -static const char* kTestPassword = "passwd"; -static const char* kTestCaptcha = "pizzamyheart"; -static const char* kTestCaptchaUrl = "http://pizzamyheart/"; +static const char kTestUser[] = "chrome.p13n.test@gmail.com"; +static const char kTestPassword[] = "passwd"; +static const char kTestCaptcha[] = "pizzamyheart"; +static const char kTestCaptchaUrl[] = "http://pizzamyheart/"; typedef GoogleServiceAuthError AuthError; diff --git a/chrome/common/net/notifier/base/async_dns_lookup.cc b/chrome/common/net/notifier/base/async_dns_lookup.cc index 21b7928..4cc254d 100644 --- a/chrome/common/net/notifier/base/async_dns_lookup.cc +++ b/chrome/common/net/notifier/base/async_dns_lookup.cc @@ -103,7 +103,7 @@ void AsyncDNSLookup::DoWork() { } void AsyncDNSLookup::OnMessage(talk_base::Message* message) { - ASSERT(message); + DCHECK(message); if (message->message_id == MSG_TIMEOUT) { OnTimeout(); } else { diff --git a/chrome/common/net/notifier/base/network_status_detector_task_mt.cc b/chrome/common/net/notifier/base/network_status_detector_task_mt.cc index 7f35a37..c45e1e1 100644 --- a/chrome/common/net/notifier/base/network_status_detector_task_mt.cc +++ b/chrome/common/net/notifier/base/network_status_detector_task_mt.cc @@ -4,6 +4,7 @@ #include "chrome/common/net/notifier/base/network_status_detector_task_mt.h" +#include "base/logging.h" #include "chrome/common/net/notifier/base/async_network_alive.h" #include "chrome/common/net/notifier/base/signal_thread_task.h" @@ -13,7 +14,7 @@ namespace notifier { void NetworkStatusDetectorTaskMT::OnNetworkAliveDone( AsyncNetworkAlive* network_alive) { - ASSERT(network_alive); + DCHECK(network_alive); SetNetworkAlive(network_alive->alive()); // If we got an error from detecting the network alive state, then stop // retrying the detection. @@ -41,7 +42,7 @@ void NetworkStatusDetectorTaskMT::StartAsyncDetection( NetworkStatusDetectorTask* NetworkStatusDetectorTask::Create( talk_base::Task* parent) { - ASSERT(parent); + DCHECK(parent); return new NetworkStatusDetectorTaskMT(parent); } diff --git a/chrome/common/net/notifier/base/signal_thread_task.h b/chrome/common/net/notifier/base/signal_thread_task.h index 46f203a..4e9b2c9 100644 --- a/chrome/common/net/notifier/base/signal_thread_task.h +++ b/chrome/common/net/notifier/base/signal_thread_task.h @@ -5,6 +5,7 @@ #ifndef CHROME_COMMON_NET_NOTIFIER_BASE_SIGNAL_THREAD_TASK_H_ #define CHROME_COMMON_NET_NOTIFIER_BASE_SIGNAL_THREAD_TASK_H_ +#include "base/logging.h" #include "talk/base/common.h" #include "talk/base/signalthread.h" #include "talk/base/sigslot.h" @@ -34,7 +35,7 @@ class SignalThreadTask : public talk_base::Task, } virtual int ProcessStart() { - ASSERT(GetState() == talk_base::Task::STATE_START); + DCHECK_EQ(GetState(), talk_base::Task::STATE_START); signal_thread_->SignalWorkDone.connect( this, &SignalThreadTask<T>::OnWorkDone); @@ -56,10 +57,12 @@ class SignalThreadTask : public talk_base::Task, private: // Takes ownership of signal_thread. void SetSignalThread(T** signal_thread) { - ASSERT(!signal_thread_ && signal_thread && *signal_thread); - // Verify that no one is listening to the signal thread for work done. - // They should be using this class instead. - ASSERT((*signal_thread)->SignalWorkDone.is_empty()); + DCHECK(!signal_thread_); + DCHECK(signal_thread); + DCHECK(*signal_thread); + // No one should be listening to the signal thread for work done. + // They should be using this class instead. Unfortunately, we + // can't verify this. signal_thread_ = *signal_thread; @@ -70,7 +73,7 @@ class SignalThreadTask : public talk_base::Task, } void OnWorkDone(talk_base::SignalThread* signal_thread) { - ASSERT(signal_thread == signal_thread_); + DCHECK_EQ(signal_thread, signal_thread_); finished_ = true; Wake(); } diff --git a/chrome/common/net/notifier/base/win/async_network_alive_win32.cc b/chrome/common/net/notifier/base/win/async_network_alive_win32.cc index f3978dd..d20f027 100644 --- a/chrome/common/net/notifier/base/win/async_network_alive_win32.cc +++ b/chrome/common/net/notifier/base/win/async_network_alive_win32.cc @@ -6,6 +6,7 @@ #include <winsock2.h> +#include "base/logging.h" #include "base/scoped_handle_win.h" #include "chrome/common/net/notifier/base/utils.h" #include "talk/base/common.h" @@ -39,7 +40,7 @@ class PlatformNetworkInfo { } bool IsAlive(bool* error) { - ASSERT(error); + DCHECK(error); *error = false; // If IsAlive was previously called, we need a new handle. @@ -82,7 +83,7 @@ class PlatformNetworkInfo { // get at least one connection, return "connected". alive = true; } else { - ASSERT(result == SOCKET_ERROR); + DCHECK_EQ(result, SOCKET_ERROR); result = ::WSAGetLastError(); if (result == WSA_E_NO_MORE || result == WSAENOMORE) { break; @@ -117,7 +118,7 @@ class PlatformNetworkInfo { talk_base::CritScope crit_scope(&crit_sect_); if (!ws_handle_) return false; - ASSERT(!event_handle_.IsValid()); + DCHECK(!event_handle_.IsValid()); event_handle_.Set(CreateEvent(NULL, FALSE, FALSE, NULL)); if (!event_handle_.IsValid()) { LOG(WARNING) << "failed to CreateEvent"; @@ -178,7 +179,7 @@ class PlatformNetworkInfo { result = ::WSAGetLastError(); LOG(INFO) << "WSACleanup 2"; ::WSACleanup(); - ASSERT(ws_handle_ == NULL); + DCHECK(!ws_handle_); ws_handle_ = NULL; return result; } diff --git a/chrome/common/net/notifier/base/win/time_win32.cc b/chrome/common/net/notifier/base/win/time_win32.cc index f839ff8..b93f01c 100644 --- a/chrome/common/net/notifier/base/win/time_win32.cc +++ b/chrome/common/net/notifier/base/win/time_win32.cc @@ -9,6 +9,7 @@ #include "chrome/common/net/notifier/base/time.h" +#include "base/logging.h" #include "chrome/common/net/notifier/base/utils.h" #include "talk/base/common.h" #include "talk/base/logging.h" @@ -21,14 +22,14 @@ time64 FileTimeToTime64(const FILETIME& file_time) { } void Time64ToFileTime(const time64& time, FILETIME* ft) { - ASSERT(ft); + DCHECK(ft); ft->dwHighDateTime = static_cast<DWORD>(time >> 32); ft->dwLowDateTime = static_cast<DWORD>(time & 0xffffffff); } void TmTimeToSystemTime(const struct tm& tm, SYSTEMTIME* sys_time) { - ASSERT(sys_time); + DCHECK(sys_time); SetZero(*sys_time); // tm's year is 1900 based, systemtime's year is absolute. @@ -43,7 +44,7 @@ void TmTimeToSystemTime(const struct tm& tm, SYSTEMTIME* sys_time) { } void SystemTimeToTmTime(const SYSTEMTIME& sys_time, struct tm* tm) { - ASSERT(tm); + DCHECK(tm); SetZero(*tm); // tm's year is 1900 based, systemtime's year is absolute. @@ -84,7 +85,7 @@ time64 TmToTime64(const struct tm& tm) { } bool Time64ToTm(time64 t, struct tm* tm) { - ASSERT(tm); + DCHECK(tm); FILETIME file_time; SetZero(file_time); diff --git a/chrome/common/net/notifier/communicator/login.cc b/chrome/common/net/notifier/communicator/login.cc index 0a8f12c..f8fb9b1 100644 --- a/chrome/common/net/notifier/communicator/login.cc +++ b/chrome/common/net/notifier/communicator/login.cc @@ -6,6 +6,8 @@ #include "chrome/common/net/notifier/communicator/login.h" +#include "base/logging.h" + #include "chrome/common/net/notifier/base/network_status_detector_task.h" #include "chrome/common/net/notifier/base/time.h" #include "chrome/common/net/notifier/base/timer.h" @@ -102,7 +104,7 @@ void Login::StartConnection() { // Override server/port with redirect values. talk_base::SocketAddress server_override; server_override.SetIP(redirect_server_, false); - ASSERT(redirect_port_ != 0); + DCHECK_NE(redirect_port_, 0); server_override.SetPort(redirect_port_); login_settings_->set_server_override(server_override); } else { @@ -183,7 +185,7 @@ void Login::OnClientStateChange(buzz::XmppEngine::State state) { break; default: - ASSERT(false); + DCHECK(false); break; } HandleClientStateChange(new_state); @@ -264,7 +266,7 @@ void Login::UseCurrentConnection() { } void Login::OnRedirect(const std::string& redirect_server, int redirect_port) { - ASSERT(redirect_port_ != 0); + DCHECK_NE(redirect_port_, 0); redirect_time_ns_ = GetCurrent100NSTime(); redirect_server_ = redirect_server; @@ -325,7 +327,7 @@ void Login::OnNetworkStateDetected(bool was_alive, bool is_alive) { // Our network connection just went down. Setup a timer to disconnect. // Don't disconnect immediately to avoid constant // connection/disconnection due to flaky network interfaces. - ASSERT(disconnect_timer_ == NULL); + DCHECK(!disconnect_timer_); disconnect_timer_ = new Timer(parent_, kDisconnectionDelaySecs, false); disconnect_timer_->SignalTimeout.connect(this, &Login::OnDisconnectTimeout); diff --git a/chrome/common/net/notifier/communicator/login_failure.cc b/chrome/common/net/notifier/communicator/login_failure.cc index 22c0652..aed32bf 100644 --- a/chrome/common/net/notifier/communicator/login_failure.cc +++ b/chrome/common/net/notifier/communicator/login_failure.cc @@ -4,6 +4,8 @@ #include "chrome/common/net/notifier/communicator/login_failure.h" +#include "base/logging.h" + namespace notifier { LoginFailure::LoginFailure(LoginError error) @@ -21,7 +23,7 @@ LoginFailure::LoginFailure(LoginError error, } buzz::XmppEngine::Error LoginFailure::xmpp_error() const { - ASSERT(error_ == XMPP_ERROR); + DCHECK_EQ(error_, XMPP_ERROR); return xmpp_error_; } diff --git a/chrome/common/net/notifier/communicator/login_settings.cc b/chrome/common/net/notifier/communicator/login_settings.cc index 06ea8e7..a546d5b 100644 --- a/chrome/common/net/notifier/communicator/login_settings.cc +++ b/chrome/common/net/notifier/communicator/login_settings.cc @@ -6,6 +6,7 @@ #include "chrome/common/net/notifier/communicator/login_settings.h" +#include "base/logging.h" #include "chrome/common/net/notifier/communicator/connection_options.h" #include "chrome/common/net/notifier/communicator/xmpp_connection_generator.h" #include "talk/base/common.h" @@ -29,8 +30,8 @@ LoginSettings::LoginSettings(const buzz::XmppClientSettings& user_settings, user_settings_(new buzz::XmppClientSettings(user_settings)), connection_options_(new ConnectionOptions(options)) { // Note: firewall may be NULL. - ASSERT(server_list != 0); - ASSERT(server_count > 0); + DCHECK(server_list); + DCHECK_GT(server_count, 0); for (int i = 0; i < server_count_; ++i) { server_list_[i] = server_list[i]; } diff --git a/chrome/common/net/notifier/communicator/mailbox.cc b/chrome/common/net/notifier/communicator/mailbox.cc index aaf8db8..86104bf 100644 --- a/chrome/common/net/notifier/communicator/mailbox.cc +++ b/chrome/common/net/notifier/communicator/mailbox.cc @@ -10,6 +10,7 @@ #include <stack> #include <vector> +#include "base/logging.h" #include "chrome/common/net/notifier/base/string.h" #include "chrome/common/net/notifier/base/utils.h" #include "chrome/common/net/notifier/communicator/xml_parse_helpers.h" @@ -235,7 +236,8 @@ bool MailBox::InitFromXml(const buzz::XmlElement* src) { highest_thread_id_ = 0; - const buzz::XmlElement* thread_element = src->FirstNamed(buzz::kQnMailThreadInfo); + const buzz::XmlElement* thread_element = + src->FirstNamed(buzz::kQnMailThreadInfo); while (thread_element) { MessageThread* thread = MessageThread::CreateFromXML(thread_element); if (thread) { @@ -534,7 +536,7 @@ class SenderFormatterList { case REMOVED_MESSAGE: default: - ASSERT(false); + LOG(DFATAL) << "invalid state: " << state_; return false; } @@ -654,7 +656,7 @@ std::string GetSenderHtml(const MailSenderList& sender_list, const std::string& me_address, int space) { // There has to be at least 9 spaces to show something reasonable. - ASSERT(space >= 10); + DCHECK_GE(space, 10); std::string count_html; if (message_count > 1) { std::string count(IntToString(message_count)); diff --git a/chrome/common/net/notifier/communicator/single_login_attempt.cc b/chrome/common/net/notifier/communicator/single_login_attempt.cc index 939a07b..6afb23b 100644 --- a/chrome/common/net/notifier/communicator/single_login_attempt.cc +++ b/chrome/common/net/notifier/communicator/single_login_attempt.cc @@ -36,8 +36,10 @@ static void GetClientErrorInformation( buzz::XmppEngine::Error* error, int* subcode, buzz::XmlElement** stream_error) { - ASSERT(client != NULL); - ASSERT(error && subcode && stream_error); + DCHECK(client); + DCHECK(error); + DCHECK(subcode); + DCHECK(stream_error); *error = client->GetError(subcode); @@ -138,7 +140,7 @@ SingleLoginAttempt::SingleLoginAttempt(talk_base::Task* parent, SingleLoginAttempt::~SingleLoginAttempt() { // If this assertion goes off, it means that "Stop()" didn't get called like // it should have been. - ASSERT(client_ == NULL); + DCHECK(!client_); } bool SingleLoginAttempt::auto_reconnect() const { @@ -146,12 +148,12 @@ bool SingleLoginAttempt::auto_reconnect() const { } const talk_base::ProxyInfo& SingleLoginAttempt::proxy() const { - ASSERT(connection_generator_.get()); + DCHECK(connection_generator_.get()); return connection_generator_->proxy(); } int SingleLoginAttempt::ProcessStart() { - ASSERT(GetState() == talk_base::Task::STATE_START); + DCHECK_EQ(GetState(), talk_base::Task::STATE_START); connection_generator_->StartGenerating(); // After being started, this class is callback driven and does signaling from @@ -209,13 +211,13 @@ void SingleLoginAttempt::OnAttemptedAllConnections( } void SingleLoginAttempt::UseNextConnection() { - ASSERT(connection_generator_.get() != NULL); + DCHECK(connection_generator_.get()); ClearClient(); connection_generator_->UseNextConnection(); } void SingleLoginAttempt::UseCurrentConnection() { - ASSERT(connection_generator_.get() != NULL); + DCHECK(connection_generator_.get()); ClearClient(); connection_generator_->UseCurrentConnection(); } @@ -349,7 +351,7 @@ void SingleLoginAttempt::DiagnoseConnectionError() { http_request->request().verb = talk_base::HV_GET; talk_base::ProxyInfo proxy; - ASSERT(connection_generator_.get() != NULL); + DCHECK(connection_generator_.get()); if (connection_generator_.get()) { proxy = connection_generator_->proxy(); } @@ -363,7 +365,7 @@ void SingleLoginAttempt::DiagnoseConnectionError() { } void SingleLoginAttempt::OnHttpTestDone(talk_base::SignalThread* thread) { - ASSERT(thread != NULL); + DCHECK(thread); talk_base::AsyncHttpRequest* request = static_cast<talk_base::AsyncHttpRequest*>(thread); @@ -457,7 +459,7 @@ void SingleLoginAttempt::ClearClient() { // If this assertion goes off, it means that the disconnect didn't occur // properly. See SingleLoginAttempt::OnClientStateChange, // case XmppEngine::STATE_CLOSED - ASSERT(client_ == NULL); + DCHECK(!client_); } } @@ -558,7 +560,7 @@ void SingleLoginAttempt::HandleConnectionError( } } - ASSERT(connection_generator_.get() != NULL); + DCHECK(connection_generator_.get()); if (!connection_generator_.get()) { return; } diff --git a/chrome/common/net/notifier/communicator/xmpp_connection_generator.cc b/chrome/common/net/notifier/communicator/xmpp_connection_generator.cc index ff4355c..39192de 100644 --- a/chrome/common/net/notifier/communicator/xmpp_connection_generator.cc +++ b/chrome/common/net/notifier/communicator/xmpp_connection_generator.cc @@ -104,8 +104,8 @@ void XmppConnectionGenerator::OnProxyDetect( talk_base::AutoDetectProxy* proxy_detect) { LOG(INFO) << "XmppConnectionGenerator::OnProxyDetect"; - ASSERT(settings_list_.get()); - ASSERT(proxy_detect); + DCHECK(settings_list_.get()); + DCHECK(proxy_detect); settings_list_->SetProxy(proxy_detect->proxy()); // Start iterating through the connections (which are generated on demand). diff --git a/chrome/common/net/notifier/communicator/xmpp_socket_adapter.cc b/chrome/common/net/notifier/communicator/xmpp_socket_adapter.cc index 281a6179..da44352 100644 --- a/chrome/common/net/notifier/communicator/xmpp_socket_adapter.cc +++ b/chrome/common/net/notifier/communicator/xmpp_socket_adapter.cc @@ -169,7 +169,7 @@ bool XmppSocketAdapter::Read(char* data, size_t len, size_t* len_read) { return false; } - ASSERT(socket_ != NULL); + DCHECK(socket_); if (IsOpen()) { int result = socket_->Recv(data, len); @@ -196,7 +196,7 @@ bool XmppSocketAdapter::Write(const char* data, size_t len) { return false; } - ASSERT(socket_ != NULL); + DCHECK(socket_); size_t sent = 0; @@ -287,8 +287,8 @@ void XmppSocketAdapter::OnConnectEvent(talk_base::AsyncSocket *socket) { } #endif // defined(FEATURE_ENABLE_SSL) } else { - LOG(INFO) << "XmppSocketAdapter::OnConnectEvent - state is " << state_; - ASSERT(false); + LOG(DFATAL) << "unexpected XmppSocketAdapter::OnConnectEvent state: " + << state_; } } @@ -319,7 +319,7 @@ bool XmppSocketAdapter::StartTls(const std::string& verify_host_name) { state_ = STATE_TLS_CONNECTING; - ASSERT(write_buffer_length_ == 0); + DCHECK_EQ(write_buffer_length_, 0U); talk_base::SSLAdapter* ssl_adapter = static_cast<talk_base::SSLAdapter*>(socket_); @@ -346,7 +346,7 @@ void XmppSocketAdapter::QueueWriteData(const char* data, size_t len) { new_capacity = new_capacity * 2; } char* new_buffer = new char[new_capacity]; - ASSERT(write_buffer_length_ <= 64000); + DCHECK_LE(write_buffer_length_, 64000U); memcpy(new_buffer, write_buffer_, write_buffer_length_); delete[] write_buffer_; write_buffer_ = new_buffer; @@ -359,7 +359,8 @@ void XmppSocketAdapter::QueueWriteData(const char* data, size_t len) { } void XmppSocketAdapter::FlushWriteQueue(Error* error, int* wsa_error) { - ASSERT(error && wsa_error); + DCHECK(error); + DCHECK(wsa_error); size_t flushed = 0; while (flushed < write_buffer_length_) { diff --git a/chrome/common/net/test_url_fetcher_factory.h b/chrome/common/net/test_url_fetcher_factory.h index 7e83f76..2e4ea45 100644 --- a/chrome/common/net/test_url_fetcher_factory.h +++ b/chrome/common/net/test_url_fetcher_factory.h @@ -25,7 +25,7 @@ // URLFetcher::set_factory(&factory); // // Do something that triggers creation of a URLFetcher. // TestURLFetcher* fetcher = factory.GetFetcherByID(expected_id); -// ASSERT(fetcher); +// DCHECK(fetcher); // // Notify delegate with whatever data you want. // fetcher->delegate()->OnURLFetchComplete(...); // // Make sure consumer of URLFetcher does the right thing. |