diff options
91 files changed, 142 insertions, 158 deletions
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc index de8e414..5ce6911 100644 --- a/base/command_line_unittest.cc +++ b/base/command_line_unittest.cc @@ -109,9 +109,9 @@ TEST(CommandLineTest, EmptyString) { EXPECT_TRUE(cl.GetProgram().empty()); #elif defined(OS_POSIX) CommandLine cl(0, NULL); - EXPECT_EQ(0U, cl.argv().size()); + EXPECT_TRUE(cl.argv().empty()); #endif - EXPECT_EQ(0U, cl.args().size()); + EXPECT_TRUE(cl.args().empty()); } // Test methods for appending switches to a command line. diff --git a/base/file_path.cc b/base/file_path.cc index 32217f2..29ec7a80 100644 --- a/base/file_path.cc +++ b/base/file_path.cc @@ -249,9 +249,8 @@ bool FilePath::AppendRelativePath(const FilePath& child, GetComponents(&parent_components); child.GetComponents(&child_components); - if (parent_components.size() >= child_components.size()) - return false; - if (parent_components.empty()) + if (parent_components.empty() || + parent_components.size() >= child_components.size()) return false; std::vector<StringType>::const_iterator parent_comp = diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index cf93c05..90c0f96 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -400,7 +400,7 @@ char** AlterEnvironment(const environment_vector& changes, } // if !found, then we have a new element to add. - if (!found && j->second.size() > 0) { + if (!found && !j->second.empty()) { count++; size += j->first.size() + 1 /* '=' */ + j->second.size() + 1 /* NUL */; } diff --git a/base/string_util.cc b/base/string_util.cc index 4af3ed9..af96d91 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -804,7 +804,8 @@ size_t Tokenize(const base::StringPiece& str, template<typename STR> static STR JoinStringT(const std::vector<STR>& parts, typename STR::value_type sep) { - if (parts.empty()) return STR(); + if (parts.empty()) + return STR(); STR result(parts[0]); typename std::vector<STR>::const_iterator iter = parts.begin(); diff --git a/chrome/browser/accessibility/browser_accessibility_win.cc b/chrome/browser/accessibility/browser_accessibility_win.cc index b5bf894..050cea0 100644 --- a/chrome/browser/accessibility/browser_accessibility_win.cc +++ b/chrome/browser/accessibility/browser_accessibility_win.cc @@ -66,8 +66,9 @@ HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { return S_OK; } -STDMETHODIMP BrowserAccessibilityWin::accHitTest( - LONG x_left, LONG y_top, VARIANT* child) { +STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, + LONG y_top, + VARIANT* child) { if (!instance_active_) return E_FAIL; @@ -136,12 +137,12 @@ STDMETHODIMP BrowserAccessibilityWin::accNavigate( // These directions are not implemented, matching Mozilla and IE. return E_NOTIMPL; case NAVDIR_FIRSTCHILD: - if (target->children_.size() > 0) - result = target->children_[0]; + if (!target->children_.empty()) + result = target->children_.front(); break; case NAVDIR_LASTCHILD: - if (target->children_.size() > 0) - result = target->children_[target->children_.size() - 1]; + if (!target->children_.empty()) + result = target->children_.back(); break; case NAVDIR_NEXT: result = target->GetNextSibling(); @@ -162,7 +163,7 @@ STDMETHODIMP BrowserAccessibilityWin::accNavigate( } STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, - IDispatch** disp_child) { + IDispatch** disp_child) { if (!instance_active_) return E_FAIL; @@ -191,7 +192,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { } STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, - BSTR* def_action) { + BSTR* def_action) { if (!instance_active_) return E_FAIL; @@ -207,7 +208,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, } STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, - BSTR* desc) { + BSTR* desc) { if (!instance_active_) return E_FAIL; @@ -258,7 +259,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { } STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, - BSTR* acc_key) { + BSTR* acc_key) { if (!instance_active_) return E_FAIL; @@ -304,7 +305,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { // This happens if we're the root of the tree; // return the IAccessible for the window. parent = manager_->toBrowserAccessibilityManagerWin()-> - GetParentWindowIAccessible(); + GetParentWindowIAccessible(); } parent->AddRef(); @@ -335,7 +336,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accRole( } STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, - VARIANT* state) { + VARIANT* state) { if (!instance_active_) return E_FAIL; diff --git a/chrome/browser/autocomplete/autocomplete_match.cc b/chrome/browser/autocomplete/autocomplete_match.cc index f05892e..e19f156 100644 --- a/chrome/browser/autocomplete/autocomplete_match.cc +++ b/chrome/browser/autocomplete/autocomplete_match.cc @@ -166,7 +166,7 @@ void AutocompleteMatch::ValidateClassifications( } // The classifications should always cover the whole string. - DCHECK(classifications.size() > 0) << "No classification for text"; + DCHECK(!classifications.empty()) << "No classification for text"; DCHECK(classifications[0].offset == 0) << "Classification misses beginning"; if (classifications.size() == 1) return; diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc index 44d24e8d..91c3078 100644 --- a/chrome/browser/autocomplete/history_contents_provider.cc +++ b/chrome/browser/autocomplete/history_contents_provider.cc @@ -113,7 +113,7 @@ void HistoryContentsProvider::Start(const AutocompleteInput& input, return; } - if (results_.size() != 0) { + if (!results_.empty()) { // Clear the results. We swap in an empty one as the easy way to clear it. history::QueryResults empty_results; results_.Swap(&empty_results); diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 7afc0d0..bbbebf2 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -636,7 +636,7 @@ void ExtensionTestResultNotificationObserver::MaybeSendResult() { if (!automation_) return; - if (results_.size() > 0) { + if (!results_.empty()) { // This release method should return the automation's current // reply message, or NULL if there is no current one. If it is not // NULL, we are stating that we will handle this reply message. diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc index 52145bd..32dba74 100644 --- a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc +++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc @@ -269,7 +269,7 @@ bool BookmarkContextMenuController::IsCommandIdEnabled(int command_id) const { case IDC_COPY: case IDC_CUT: - return selection_.size() > 0 && !is_root_node; + return !selection_.empty() && !is_root_node; case IDC_PASTE: // Paste to selection from the Bookmark Bar, to parent_ everywhere else diff --git a/chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.mm b/chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.mm index bfb6a7a..76fc372 100644 --- a/chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.mm +++ b/chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.mm @@ -224,9 +224,9 @@ void WriteToClipboardPrivate( const std::vector<BookmarkNodeData::Element>& elements, NSPasteboard* pb, FilePath::StringType profile_path) { - if (elements.empty()) { + if (elements.empty()) return; - } + NSArray* types = [NSArray arrayWithObjects:kBookmarkDictionaryListPboardType, kWebURLsWithTitlesPboardType, NSStringPboardType, diff --git a/chrome/browser/chromeos/login/wizard_accessibility_handler.cc b/chrome/browser/chromeos/login/wizard_accessibility_handler.cc index 16bb99b..539b0bd 100644 --- a/chrome/browser/chromeos/login/wizard_accessibility_handler.cc +++ b/chrome/browser/chromeos/login/wizard_accessibility_handler.cc @@ -430,13 +430,13 @@ void WizardAccessibilityHandler::DescribeTextContentsChanged( new_indices[prefix_char_len], new_indices[new_suffix_char_start] - new_indices[prefix_char_len]); - if (inserted.size() > 0 && deleted.size() > 0) { + if (!inserted.empty() && !deleted.empty()) { // Replace one substring with another, speak inserted text. AppendUtterance(inserted, out_spoken_description); - } else if (inserted.size() > 0) { + } else if (!inserted.empty()) { // Speak inserted text. AppendUtterance(inserted, out_spoken_description); - } else if (deleted.size() > 0) { + } else if (!deleted.empty()) { // Speak deleted text. AppendUtterance(deleted, out_spoken_description); } diff --git a/chrome/browser/debugger/devtools_remote_listen_socket.cc b/chrome/browser/debugger/devtools_remote_listen_socket.cc index 6e2a2ae..19234e5 100644 --- a/chrome/browser/debugger/devtools_remote_listen_socket.cc +++ b/chrome/browser/debugger/devtools_remote_listen_socket.cc @@ -164,7 +164,7 @@ void DevToolsRemoteListenSocket::DispatchField() { } break; case HEADERS: { - if (protocol_field_.size() > 0) { // not end-of-headers + if (!protocol_field_.empty()) { // not end-of-headers std::string::size_type colon_pos = protocol_field_.find_first_of(":"); if (colon_pos == std::string::npos) { // TODO(apavlov): handle the error (malformed header) diff --git a/chrome/browser/debugger/extension_ports_remote_service.cc b/chrome/browser/debugger/extension_ports_remote_service.cc index 1f8247b..711e3f8 100644 --- a/chrome/browser/debugger/extension_ports_remote_service.cc +++ b/chrome/browser/debugger/extension_ports_remote_service.cc @@ -174,7 +174,7 @@ void ExtensionPortsRemoteService::HandleMessage( } int destination = -1; - if (destinationString.size() != 0) + if (!destinationString.empty()) base::StringToInt(destinationString, &destination); if (command == kConnect) { diff --git a/chrome/browser/debugger/inspectable_tab_proxy.cc b/chrome/browser/debugger/inspectable_tab_proxy.cc index 499b39a..0f31b0a 100644 --- a/chrome/browser/debugger/inspectable_tab_proxy.cc +++ b/chrome/browser/debugger/inspectable_tab_proxy.cc @@ -105,7 +105,7 @@ DevToolsClientHost* InspectableTabProxy::NewClientHost( } void InspectableTabProxy::OnRemoteDebuggerDetached() { - while (id_to_client_host_map_.size() > 0) { + while (!id_to_client_host_map_.empty()) { IdToClientHostMap::iterator it = id_to_client_host_map_.begin(); it->second->debugger_remote_service()->DetachFromTab( base::IntToString(it->first), NULL); diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 180c768..292362e 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -114,8 +114,8 @@ bool IsShellIntegratedExtension(const string16& extension) { // See <http://www.juniper.net/security/auto/vulnerabilities/vuln2612.html>. // That vulnerability report is not exactly on point, but files become magical // if their end in a CLSID. Here we block extensions that look like CLSIDs. - if (extension_lower.size() > 0 && extension_lower.at(0) == L'{' && - extension_lower.at(extension_lower.length() - 1) == L'}') + if (!extension_lower.empty() && extension_lower[0] == L'{' && + extension_lower[extension_lower.length() - 1] == L'}') return true; return false; diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index c15f77f..c4ab498 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -121,7 +121,7 @@ bool ManifestFetchData::AddExtension(std::string id, std::string version, // Check against our max url size, exempting the first extension added. int new_size = full_url_.possibly_invalid_spec().size() + extra.size(); - if (extension_ids_.size() > 0 && new_size > kExtensionsManifestMaxURLSize) { + if (!extension_ids_.empty() && new_size > kExtensionsManifestMaxURLSize) { UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 1); return false; } @@ -690,7 +690,7 @@ void ExtensionUpdater::OnCRXFetchComplete(const GURL& url, current_extension_fetch_ = ExtensionFetch(); // If there are any pending downloads left, start one. - if (extensions_pending_.size() > 0) { + if (!extensions_pending_.empty()) { ExtensionFetch next = extensions_pending_.front(); extensions_pending_.pop_front(); FetchUpdatedExtension(next.id, next.url, next.package_hash, next.version); diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc index 74de7f7..92b9ebb 100644 --- a/chrome/browser/extensions/extension_updater_unittest.cc +++ b/chrome/browser/extensions/extension_updater_unittest.cc @@ -278,7 +278,7 @@ static void ExtractParameters(const std::string& params, for (size_t i = 0; i < pairs.size(); i++) { std::vector<std::string> key_val; base::SplitString(pairs[i], '=', &key_val); - if (key_val.size() > 0) { + if (!key_val.empty()) { std::string key = key_val[0]; EXPECT_TRUE(result->find(key) == result->end()); (*result)[key] = (key_val.size() == 2) ? key_val[1] : ""; diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index 80c753f..5888100 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -916,7 +916,7 @@ scoped_refptr<ExternalTabContainer> ExternalTabContainer::RemovePendingTab( void ExternalTabContainer::SetEnableExtensionAutomation( const std::vector<std::string>& functions_enabled) { - if (functions_enabled.size() > 0) { + if (!functions_enabled.empty()) { if (!tab_contents_.get()) { NOTREACHED() << "Being invoked via tab so should have TabContents"; return; diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc index b5ad05b..ac0ea32 100644 --- a/chrome/browser/gpu_process_host_ui_shim.cc +++ b/chrome/browser/gpu_process_host_ui_shim.cc @@ -416,7 +416,7 @@ void GpuProcessHostUIShim::OnChannelEstablished( // Currently if any of the GPU features are blacklisted, we don't establish a // GPU channel. - if (channel_handle.name.size() != 0 && + if (!channel_handle.name.empty() && gpu_data_manager_->GetGpuFeatureFlags().flags() != 0) { Send(new GpuMsg_CloseChannel(channel_handle)); EstablishChannelError(callback.release(), @@ -433,7 +433,7 @@ void GpuProcessHostUIShim::OnChannelEstablished( void GpuProcessHostUIShim::OnSynchronizeReply() { // Guard against race conditions in abrupt GPU process termination. - if (synchronize_requests_.size() > 0) { + if (!synchronize_requests_.empty()) { linked_ptr<SynchronizeCallback> callback(synchronize_requests_.front()); synchronize_requests_.pop(); callback->Run(); @@ -441,7 +441,7 @@ void GpuProcessHostUIShim::OnSynchronizeReply() { } void GpuProcessHostUIShim::OnCommandBufferCreated(const int32 route_id) { - if (create_command_buffer_requests_.size() > 0) { + if (!create_command_buffer_requests_.empty()) { linked_ptr<CreateCommandBufferCallback> callback = create_command_buffer_requests_.front(); create_command_buffer_requests_.pop(); diff --git a/chrome/browser/history/history_publisher_win.cc b/chrome/browser/history/history_publisher_win.cc index 4aeb333..f54be58 100644 --- a/chrome/browser/history/history_publisher_win.cc +++ b/chrome/browser/history/history_publisher_win.cc @@ -105,7 +105,7 @@ bool HistoryPublisher::ReadRegisteredIndexersFromRegistry() { kRegKeyRegisteredIndexersInfo, &indexers_); AddRegisteredIndexers(HKEY_LOCAL_MACHINE, kRegKeyRegisteredIndexersInfo, &indexers_); - return indexers_.size() > 0; + return !indexers_.empty(); } void HistoryPublisher::PublishDataToIndexers(const PageData& page_data) diff --git a/chrome/browser/history/history_types.cc b/chrome/browser/history/history_types.cc index 65b1935..9f56ff0 100644 --- a/chrome/browser/history/history_types.cc +++ b/chrome/browser/history/history_types.cc @@ -174,7 +174,7 @@ const size_t* QueryResults::MatchesForURL(const GURL& url, // All entries in the map should have at least one index, otherwise it // shouldn't be in the map. - DCHECK(found->second->size() > 0); + DCHECK(!found->second->empty()); if (num_matches) *num_matches = found->second->size(); return &found->second->front(); diff --git a/chrome/browser/history/query_parser.cc b/chrome/browser/history/query_parser.cc index 1037b6c..a5447f6 100644 --- a/chrome/browser/history/query_parser.cc +++ b/chrome/browser/history/query_parser.cc @@ -245,7 +245,7 @@ QueryParser::QueryParser() { // static bool QueryParser::IsWordLongEnoughForPrefixSearch(const string16& word) { - DCHECK(word.size() > 0); + DCHECK(!word.empty()); size_t minimum_length = 3; // We intentionally exclude Hangul Jamos (both Conjoining and compatibility) // because they 'behave like' Latin letters. Moreover, we should diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index bf68af0..31ea3a3 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -205,7 +205,7 @@ void Firefox2Importer::ImportBookmarksFile( post_data.empty() && CanImportURL(GURL(url)) && default_urls.find(url) == default_urls.end()) { - if (toolbar_folder > path.size() && path.size() > 0) { + if (toolbar_folder > path.size() && !path.empty()) { NOTREACHED(); // error in parsing. break; } diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index abdce9c..d051967 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -532,7 +532,7 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info, // C:\Users\Foo\Favorites\Links\Bar\Baz.url -> "Links\Bar" FilePath::StringType relative_string = shortcut.DirName().value().substr(favorites_path_len); - if (relative_string.size() > 0 && FilePath::IsSeparator(relative_string[0])) + if (!relative_string.empty() && FilePath::IsSeparator(relative_string[0])) relative_string = relative_string.substr(1); FilePath relative_path(relative_string); @@ -547,7 +547,7 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info, // Flatten the bookmarks in Link folder onto bookmark toolbar. Otherwise, // put it into "Other bookmarks". if (import_to_bookmark_bar() && - (entry.path.size() > 0 && entry.path[0] == info.links_folder)) { + (!entry.path.empty() && entry.path[0] == info.links_folder)) { entry.in_toolbar = true; entry.path.erase(entry.path.begin()); toolbar_bookmarks.push_back(entry); diff --git a/chrome/browser/password_manager/password_store_mac.cc b/chrome/browser/password_manager/password_store_mac.cc index f53d1de..b5a4b0f 100644 --- a/chrome/browser/password_manager/password_store_mac.cc +++ b/chrome/browser/password_manager/password_store_mac.cc @@ -516,7 +516,7 @@ bool MacKeychainPasswordFormAdapter::HasPasswordsMergeableWithForm( keychain_->Free(*i); } - return matches.size() != 0; + return !matches.empty(); } std::vector<PasswordForm*> diff --git a/chrome/browser/plugin_exceptions_table_model_unittest.cc b/chrome/browser/plugin_exceptions_table_model_unittest.cc index cdfd537..ac14c86b 100644 --- a/chrome/browser/plugin_exceptions_table_model_unittest.cc +++ b/chrome/browser/plugin_exceptions_table_model_unittest.cc @@ -137,7 +137,7 @@ class PluginExceptionsTableModelTest : public testing::Test { last_plugin = it->plugin_id; } } - if (row_counts.size() > 0) + if (!row_counts.empty()) EXPECT_EQ(count, row_counts[last_plugin]); } diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index dcc6c89..f857c70 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -62,7 +62,7 @@ PrerenderManager::PrerenderManager(Profile* profile) } PrerenderManager::~PrerenderManager() { - while (prerender_list_.size() > 0) { + while (!prerender_list_.empty()) { PrerenderContentsData data = prerender_list_.front(); prerender_list_.pop_front(); data.contents_->set_final_status(FINAL_STATUS_MANAGER_SHUTDOWN); @@ -108,7 +108,7 @@ bool PrerenderManager::AddPreload(const GURL& url, } void PrerenderManager::DeleteOldEntries() { - while (prerender_list_.size() > 0) { + while (!prerender_list_.empty()) { PrerenderContentsData data = prerender_list_.front(); if (IsPrerenderElementFresh(data.start_time_)) return; diff --git a/chrome/browser/renderer_host/web_cache_manager.cc b/chrome/browser/renderer_host/web_cache_manager.cc index a555207..d422c33 100644 --- a/chrome/browser/renderer_host/web_cache_manager.cc +++ b/chrome/browser/renderer_host/web_cache_manager.cc @@ -232,7 +232,7 @@ bool WebCacheManager::AttemptTactic( // The inactive renderers get one share of the extra memory to be divided // among themselves. size_t inactive_extra = 0; - if (inactive_renderers_.size() > 0) { + if (!inactive_renderers_.empty()) { ++shares; inactive_extra = total_extra / shares; } diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc index bff4026..81d57de 100644 --- a/chrome/browser/sync/engine/syncapi.cc +++ b/chrome/browser/sync/engine/syncapi.cc @@ -2458,7 +2458,7 @@ void SyncManager::SyncInternal::OnSyncEngineEvent( // If passwords are enabled, they're automatically considered encrypted. if (enabled_types.count(syncable::PASSWORDS) > 0) encrypted_types.insert(syncable::PASSWORDS); - if (encrypted_types.size() > 0) { + if (!encrypted_types.empty()) { Cryptographer* cryptographer = GetUserShare()->dir_manager->cryptographer(); if (!cryptographer->is_ready() && !cryptographer->has_pending_keys()) { diff --git a/chrome/browser/sync/glue/data_type_manager_impl.cc b/chrome/browser/sync/glue/data_type_manager_impl.cc index 2d06f80..bb89c6e 100644 --- a/chrome/browser/sync/glue/data_type_manager_impl.cc +++ b/chrome/browser/sync/glue/data_type_manager_impl.cc @@ -226,7 +226,7 @@ void DataTypeManagerImpl::DownloadReady() { void DataTypeManagerImpl::StartNextType() { // If there are any data types left to start, start the one at the // front of the list. - if (needs_start_.size() > 0) { + if (!needs_start_.empty()) { current_dtc_ = needs_start_[0]; VLOG(1) << "Starting " << current_dtc_->name(); current_dtc_->Start( diff --git a/chrome/browser/sync/glue/data_type_manager_impl2.cc b/chrome/browser/sync/glue/data_type_manager_impl2.cc index b4276d1..af816fb 100644 --- a/chrome/browser/sync/glue/data_type_manager_impl2.cc +++ b/chrome/browser/sync/glue/data_type_manager_impl2.cc @@ -186,7 +186,7 @@ void DataTypeManagerImpl2::DownloadReady() { void DataTypeManagerImpl2::StartNextType() { // If there are any data types left to start, start the one at the // front of the list. - if (needs_start_.size() > 0) { + if (!needs_start_.empty()) { current_dtc_ = needs_start_[0]; VLOG(1) << "Starting " << current_dtc_->name(); current_dtc_->Start( diff --git a/chrome/browser/sync/glue/foreign_session_tracker.cc b/chrome/browser/sync/glue/foreign_session_tracker.cc index 6db5c9c..e9bc9c6 100644 --- a/chrome/browser/sync/glue/foreign_session_tracker.cc +++ b/chrome/browser/sync/glue/foreign_session_tracker.cc @@ -23,17 +23,14 @@ bool ForeignSessionTracker::LookupAllForeignSessions( foreign_session_map_.begin(); i != foreign_session_map_.end(); ++i) { // Only include sessions with open tabs. ForeignSession* foreign_session = i->second; - if (foreign_session->windows.size() > 0 && + if (!foreign_session->windows.empty() && !SessionModelAssociator::SessionWindowHasNoTabsToSync( *foreign_session->windows[0])) { sessions->push_back(foreign_session); } } - if (sessions->size() > 0) - return true; - else - return false; + return !sessions->empty(); } bool ForeignSessionTracker::LookupSessionWindows( diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index b085d58..3815541 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -433,7 +433,7 @@ void ProfileSyncService::CreateBackend() { } bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { - return encrypted_types_.size() > 0; + return !encrypted_types_.empty(); } void ProfileSyncService::StartUp() { diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc index 14a404e..5226715 100644 --- a/chrome/browser/sync/profile_sync_service_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_unittest.cc @@ -271,7 +271,7 @@ class FakeServerChange { // of the changelist. void SetModified(int64 id) { // Coalesce multi-property edits. - if (changes_.size() > 0 && changes_.back().id == id && + if (!changes_.empty() && changes_.back().id == id && changes_.back().action == sync_api::SyncManager::ChangeRecord::ACTION_UPDATE) return; diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 19cb00e..372c703 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -715,7 +715,7 @@ void RenderViewContextMenu::AppendEditableItems() { menu_model_.AddItem(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i), params_.dictionary_suggestions[i]); } - if (params_.dictionary_suggestions.size() > 0) + if (!params_.dictionary_suggestions.empty()) menu_model_.AddSeparator(); // If word is misspelled, give option for "Add to dictionary" diff --git a/chrome/browser/ui/cocoa/clear_browsing_data_controller.mm b/chrome/browser/ui/cocoa/clear_browsing_data_controller.mm index 9251763..ae57e26 100644 --- a/chrome/browser/ui/cocoa/clear_browsing_data_controller.mm +++ b/chrome/browser/ui/cocoa/clear_browsing_data_controller.mm @@ -83,9 +83,8 @@ static base::LazyInstance<ProfileControllerMap> g_profile_controller_map( if (it == map->end()) { // Since we don't currently support multiple profiles, this class // has not been tested against this case. - if (map->size() != 0) { + if (!map->empty()) return nil; - } ClearBrowsingDataController* controller = [[self alloc] initWithProfile:profile]; diff --git a/chrome/browser/ui/cocoa/cocoa_test_helper.mm b/chrome/browser/ui/cocoa/cocoa_test_helper.mm index b4c68d9..de9c040 100644 --- a/chrome/browser/ui/cocoa/cocoa_test_helper.mm +++ b/chrome/browser/ui/cocoa/cocoa_test_helper.mm @@ -111,7 +111,7 @@ void CocoaTest::TearDown() { // started. std::set<NSWindow*> windows_left(WindowsLeft()); - while (windows_left.size() > 0) { + while (!windows_left.empty()) { // Cover delayed actions by spinning the loop at least once after // this timeout. const NSTimeInterval kCloseTimeoutSeconds = diff --git a/chrome/browser/ui/cocoa/task_manager_mac.mm b/chrome/browser/ui/cocoa/task_manager_mac.mm index 45fcea6..9ad68e3 100644 --- a/chrome/browser/ui/cocoa/task_manager_mac.mm +++ b/chrome/browser/ui/cocoa/task_manager_mac.mm @@ -161,7 +161,7 @@ class SortHelper { // Use the model indices to get the new view indices of the selection, and // set selection to that. This assumes that no rows were added or removed // (in that case, the selection is cleared before -reloadData is called). - if (modelSelection.size() > 0) + if (!modelSelection.empty()) DCHECK_EQ([tableView_ numberOfRows], model_->ResourceCount()); NSMutableIndexSet* indexSet = [NSMutableIndexSet indexSet]; for (size_t i = 0; i < modelSelection.size(); ++i) diff --git a/chrome/browser/ui/gtk/dialogs_gtk.cc b/chrome/browser/ui/gtk/dialogs_gtk.cc index 5c18ddb..10d9d57 100644 --- a/chrome/browser/ui/gtk/dialogs_gtk.cc +++ b/chrome/browser/ui/gtk/dialogs_gtk.cc @@ -299,7 +299,7 @@ void SelectFileDialogImpl::AddFilters(GtkFileChooser* chooser) { // Add the *.* filter, but only if we have added other filters (otherwise it // is implied). - if (file_types_.include_all_files && file_types_.extensions.size() > 0) { + if (file_types_.include_all_files && !file_types_.extensions.empty()) { GtkFileFilter* filter = gtk_file_filter_new(); gtk_file_filter_add_pattern(filter, "*"); gtk_file_filter_set_name(filter, diff --git a/chrome/browser/ui/gtk/options/passwords_exceptions_page_gtk.cc b/chrome/browser/ui/gtk/options/passwords_exceptions_page_gtk.cc index 2d21122..13d77f2 100644 --- a/chrome/browser/ui/gtk/options/passwords_exceptions_page_gtk.cc +++ b/chrome/browser/ui/gtk/options/passwords_exceptions_page_gtk.cc @@ -122,7 +122,7 @@ void PasswordsExceptionsPageGtk::SetExceptionList( COL_SITE, UTF16ToUTF8(net::FormatUrl(result[i]->origin, languages)).c_str(), -1); } - gtk_widget_set_sensitive(remove_all_button_, result.size() > 0); + gtk_widget_set_sensitive(remove_all_button_, !result.empty()); } void PasswordsExceptionsPageGtk::OnRemoveButtonClicked(GtkWidget* widget) { @@ -149,7 +149,7 @@ void PasswordsExceptionsPageGtk::OnRemoveButtonClicked(GtkWidget* widget) { delete exception_list_[index]; exception_list_.erase(exception_list_.begin() + index); - gtk_widget_set_sensitive(remove_all_button_, exception_list_.size() > 0); + gtk_widget_set_sensitive(remove_all_button_, !exception_list_.empty()); } void PasswordsExceptionsPageGtk::OnRemoveAllButtonClicked(GtkWidget* widget) { diff --git a/chrome/browser/ui/gtk/options/passwords_page_gtk.cc b/chrome/browser/ui/gtk/options/passwords_page_gtk.cc index 6eb3b0b..e26cea0 100644 --- a/chrome/browser/ui/gtk/options/passwords_page_gtk.cc +++ b/chrome/browser/ui/gtk/options/passwords_page_gtk.cc @@ -165,7 +165,7 @@ void PasswordsPageGtk::SetPasswordList( UTF16ToUTF8(net::FormatUrl(result[i]->origin, languages)).c_str(), COL_USERNAME, UTF16ToUTF8(result[i]->username_value).c_str(), -1); } - gtk_widget_set_sensitive(remove_all_button_, result.size() > 0); + gtk_widget_set_sensitive(remove_all_button_, !result.empty()); } void PasswordsPageGtk::HidePassword() { @@ -222,7 +222,7 @@ void PasswordsPageGtk::OnRemoveButtonClicked(GtkWidget* widget) { delete password_list_[index]; password_list_.erase(password_list_.begin() + index); - gtk_widget_set_sensitive(remove_all_button_, password_list_.size() > 0); + gtk_widget_set_sensitive(remove_all_button_, !password_list_.empty()); } void PasswordsPageGtk::OnRemoveAllButtonClicked(GtkWidget* widget) { diff --git a/chrome/browser/ui/gtk/rounded_window.cc b/chrome/browser/ui/gtk/rounded_window.cc index 3f8b6e4..79e38e7 100644 --- a/chrome/browser/ui/gtk/rounded_window.cc +++ b/chrome/browser/ui/gtk/rounded_window.cc @@ -232,7 +232,7 @@ gboolean OnRoundedWindowExpose(GtkWidget* widget, // If we want to have borders everywhere, we need to draw a polygon instead // of a set of lines. gdk_draw_polygon(drawable, gc, FALSE, &points[0], points.size()); - } else if (points.size() > 0) { + } else if (!points.empty()) { gdk_draw_lines(drawable, gc, &points[0], points.size()); } diff --git a/chrome/browser/ui/toolbar/encoding_menu_controller_unittest.cc b/chrome/browser/ui/toolbar/encoding_menu_controller_unittest.cc index 13fa63c..00a42b1 100644 --- a/chrome/browser/ui/toolbar/encoding_menu_controller_unittest.cc +++ b/chrome/browser/ui/toolbar/encoding_menu_controller_unittest.cc @@ -52,7 +52,7 @@ TEST_F(EncodingMenuControllerTest, ListEncodingMenuItems) { controller.GetEncodingMenuItems(&profile_en, &english_items); // Make sure there are items in the lists. - ASSERT_TRUE(english_items.size() > 0); + ASSERT_FALSE(english_items.empty()); // Make sure that autodetect is the first item on both menus ASSERT_EQ(english_items[0].first, IDC_ENCODING_AUTO_DETECT); } diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc index 1a5eadb..84bc69d 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_views.cc @@ -256,7 +256,7 @@ bool BookmarkContextMenuControllerViews::IsCommandEnabled(int id) const { case IDC_COPY: case IDC_CUT: - return selection_.size() > 0 && !is_root_node; + return !selection_.empty() && !is_root_node; case IDC_PASTE: // Paste to selection from the Bookmark Bar, to parent_ everywhere else diff --git a/chrome/browser/ui/views/download_shelf_view.cc b/chrome/browser/ui/views/download_shelf_view.cc index 04c713d..b37804f 100644 --- a/chrome/browser/ui/views/download_shelf_view.cc +++ b/chrome/browser/ui/views/download_shelf_view.cc @@ -211,7 +211,7 @@ gfx::Size DownloadShelfView::GetPreferredSize() { AdjustSize(close_button_, &prefsize); AdjustSize(show_all_view_, &prefsize); // Add one download view to the preferred size. - if (download_views_.size() > 0) { + if (!download_views_.empty()) { AdjustSize(*download_views_.begin(), &prefsize); prefsize.Enlarge(kDownloadPadding, 0); } diff --git a/chrome/browser/ui/webui/bug_report_ui.cc b/chrome/browser/ui/webui/bug_report_ui.cc index 82ced3a..1b459bf 100644 --- a/chrome/browser/ui/webui/bug_report_ui.cc +++ b/chrome/browser/ui/webui/bug_report_ui.cc @@ -633,9 +633,8 @@ void BugReportHandler::HandleSendReport(const ListValue* list_value) { // Get the image to send in the report. std::vector<unsigned char> image; - if (screenshot_path.size() > 0) { + if (!screenshot_path.empty()) image = screenshot_source_->GetScreenshot(screenshot_path); - } #if defined(OS_CHROMEOS) if (++i == list_value->end()) { diff --git a/chrome/browser/ui/window_snapshot/window_snapshot_mac.mm b/chrome/browser/ui/window_snapshot/window_snapshot_mac.mm index d3f7c50..5c3253f 100644 --- a/chrome/browser/ui/window_snapshot/window_snapshot_mac.mm +++ b/chrome/browser/ui/window_snapshot/window_snapshot_mac.mm @@ -35,7 +35,7 @@ gfx::Rect GrabWindowSnapshot(gfx::NativeWindow window, return gfx::Rect(); png_representation->assign(buf, buf + length); - DCHECK(png_representation->size() > 0); + DCHECK(!png_representation->empty()); return gfx::Rect(static_cast<int>([rep pixelsWide]), static_cast<int>([rep pixelsHigh])); diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index ac635fa..35f4d49 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -948,7 +948,7 @@ void WebDataService::RemoveFormElementsAddedBetweenImpl( if (db_->RemoveFormElementsAddedBetween(request->GetArgument1(), request->GetArgument2(), &changes)) { - if (changes.size() > 0) { + if (!changes.empty()) { request->SetResult( new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes)); diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index d9d19ae..0e7827b 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -91,7 +91,7 @@ bool CompareAutofillEntries(const AutofillEntry& a, const AutofillEntry& b) { timestamps2.erase(*it); } - return timestamps2.size() != 0U; + return !timestamps2.empty(); } void AutoFillProfile31FromStatement(const sql::Statement& s, diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index eecf6a9..c979d24 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -349,7 +349,7 @@ bool Extension::IsElevatedHostList( old_hosts_set.begin(), old_hosts_set.end(), std::inserter(new_hosts_only, new_hosts_only.begin())); - return new_hosts_only.size() > 0; + return !new_hosts_only.empty(); } // static @@ -1434,7 +1434,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, return false; } - if (icon_path.size() > 0 && icon_path[0] == '/') + if (!icon_path.empty() && icon_path[0] == '/') icon_path = icon_path.substr(1); if (icon_path.empty()) { @@ -2318,7 +2318,7 @@ bool Extension::HasEffectiveAccessToAllHosts() const { } bool Extension::HasFullPermissions() const { - return plugins().size() > 0; + return !plugins().empty(); } bool Extension::ShowConfigureContextMenus() const { diff --git a/chrome/common/extensions/extension_icon_set.cc b/chrome/common/extensions/extension_icon_set.cc index fc1ac58..9b47c7d 100644 --- a/chrome/common/extensions/extension_icon_set.cc +++ b/chrome/common/extensions/extension_icon_set.cc @@ -15,7 +15,7 @@ void ExtensionIconSet::Clear() { } void ExtensionIconSet::Add(int size, const std::string& path) { - CHECK(path.size() > 0 && path[0] != '/'); + CHECK(!path.empty() && path[0] != '/'); map_[size] = path; } diff --git a/chrome/common/extensions/update_manifest.cc b/chrome/common/extensions/update_manifest.cc index 4e1cdd5..8970aa5 100644 --- a/chrome/common/extensions/update_manifest.cc +++ b/chrome/common/extensions/update_manifest.cc @@ -242,7 +242,7 @@ bool UpdateManifest::Parse(const std::string& manifest_xml) { // Parse the first <daystart> if it's present. std::vector<xmlNode*> daystarts = GetChildren(root, gupdate_ns, "daystart"); - if (daystarts.size() > 0) { + if (!daystarts.empty()) { xmlNode* first = daystarts[0]; std::string elapsed_seconds = GetAttribute(first, "elapsed_seconds"); int parsed_elapsed = kNoDaystart; diff --git a/chrome/common/extensions/user_script.cc b/chrome/common/extensions/user_script.cc index f71de5c..b66dee94 100644 --- a/chrome/common/extensions/user_script.cc +++ b/chrome/common/extensions/user_script.cc @@ -79,17 +79,17 @@ void UserScript::add_url_pattern(const URLPattern& pattern) { void UserScript::clear_url_patterns() { url_patterns_.clear(); } bool UserScript::MatchesUrl(const GURL& url) const { - if (url_patterns_.size() > 0) { + if (!url_patterns_.empty()) { if (!UrlMatchesPatterns(&url_patterns_, url)) return false; } - if (globs_.size() > 0) { + if (!globs_.empty()) { if (!UrlMatchesGlobs(&globs_, url)) return false; } - if (exclude_globs_.size() > 0) { + if (!exclude_globs_.empty()) { if (UrlMatchesGlobs(&exclude_globs_, url)) return false; } diff --git a/chrome/common/unix_domain_socket_posix.cc b/chrome/common/unix_domain_socket_posix.cc index 7621b7e..6bd387b 100644 --- a/chrome/common/unix_domain_socket_posix.cc +++ b/chrome/common/unix_domain_socket_posix.cc @@ -127,7 +127,7 @@ ssize_t UnixDomainSocket::SendRecvMsg(int fd, if (reply_len == -1) return -1; - if ((fd_vector.size() > 0 && result_fd == NULL) || fd_vector.size() > 1) { + if ((!fd_vector.empty() && result_fd == NULL) || fd_vector.size() > 1) { for (std::vector<int>::const_iterator i = fd_vector.begin(); i != fd_vector.end(); ++i) { close(*i); @@ -138,13 +138,8 @@ ssize_t UnixDomainSocket::SendRecvMsg(int fd, return -1; } - if (result_fd) { - if (fd_vector.empty()) { - *result_fd = -1; - } else { - *result_fd = fd_vector[0]; - } - } + if (result_fd) + *result_fd = fd_vector.empty() ? -1 : fd_vector[0]; return reply_len; } diff --git a/chrome/common/web_apps_unittest.cc b/chrome/common/web_apps_unittest.cc index fc8b121..de332ac 100644 --- a/chrome/common/web_apps_unittest.cc +++ b/chrome/common/web_apps_unittest.cc @@ -178,7 +178,7 @@ TEST(WebAppInfo, ParseIconSizes) { if (result) { ASSERT_EQ(data[i].is_any, is_any); ASSERT_EQ(data[i].expected_size_count, sizes.size()); - if (sizes.size() > 0) { + if (!sizes.empty()) { ASSERT_EQ(data[i].width1, sizes[0].width()); ASSERT_EQ(data[i].height1, sizes[0].height()); } diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index d1eeaf1..31771cd 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -1083,7 +1083,7 @@ void RenderThread::OnGpuChannelEstablished( const GPUInfo& gpu_info) { gpu_channel_->set_gpu_info(gpu_info); - if (channel_handle.name.size() != 0) { + if (!channel_handle.name.empty()) { // Connect to the GPU process if a channel name was received. gpu_channel_->Connect(channel_handle, renderer_process_for_gpu); } else { diff --git a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc index 52f8440..dfcfad9 100644 --- a/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc +++ b/chrome/renderer/webgraphicscontext3d_command_buffer_impl.cc @@ -631,7 +631,7 @@ WebGraphicsContext3DCommandBufferImpl::getContextAttributes() { } WGC3Denum WebGraphicsContext3DCommandBufferImpl::getError() { - if (synthetic_errors_.size() > 0) { + if (!synthetic_errors_.empty()) { std::vector<WGC3Denum>::iterator iter = synthetic_errors_.begin(); WGC3Denum err = *iter; synthetic_errors_.erase(iter); diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index bc65843..340b81a 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -1341,7 +1341,7 @@ void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) { rect.y() * stride + 4 * rect.x(); // The two bitmaps are flipped relative to each other. int dest_starting_row = plugin_rect_.height() - rect.y() - 1; - DCHECK(backing_store_.size() > 0); + DCHECK(!backing_store_.empty()); uint8* target_data = &(backing_store_[0]) + dest_starting_row * stride + 4 * rect.x(); for (int row = 0; row < rect.height(); ++row) { diff --git a/chrome/renderer/webworker_base.h b/chrome/renderer/webworker_base.h index d8814ca..1acdb8f 100644 --- a/chrome/renderer/webworker_base.h +++ b/chrome/renderer/webworker_base.h @@ -53,7 +53,7 @@ class WebWorkerBase : public IPC::Channel::Listener { bool Send(IPC::Message*); // Returns true if there are queued messages. - bool HasQueuedMessages() { return queued_messages_.size() != 0; } + bool HasQueuedMessages() { return !queued_messages_.empty(); } // Sends any messages currently in the queue. void SendQueuedMessages(); diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index bed39d3..e4c1161 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -291,7 +291,7 @@ class PageLoadTest : public UITest { bool do_log = log_file.is_open() && (!log_only_error || metrics.result != NAVIGATION_SUCCESS || - new_crash_dumps.size() > 0); + !new_crash_dumps.empty()); if (do_log) { log_file << url_string; switch (metrics.result) { diff --git a/chrome/test/url_fetch_test/url_fetch_test.cc b/chrome/test/url_fetch_test/url_fetch_test.cc index 5f1607c..d9f028b 100644 --- a/chrome/test/url_fetch_test/url_fetch_test.cc +++ b/chrome/test/url_fetch_test/url_fetch_test.cc @@ -177,13 +177,13 @@ TEST_F(UrlFetchTest, UrlFetch) { // Write out the cookie if requested FilePath cookie_output_path = cmd_line->GetSwitchValuePath("wait_cookie_output"); - if (cookie_output_path.value().size() > 0) { + if (!cookie_output_path.value().empty()) { ASSERT_TRUE(WriteValueToFile(result.cookie_value, cookie_output_path)); } // Write out the JS Variable if requested FilePath jsvar_output_path = cmd_line->GetSwitchValuePath("jsvar_output"); - if (jsvar_output_path.value().size() > 0) { + if (!jsvar_output_path.value().empty()) { ASSERT_TRUE(WriteValueToFile(result.javascript_variable, jsvar_output_path)); } diff --git a/chrome/tools/crash_service/crash_service.cc b/chrome/tools/crash_service/crash_service.cc index e672880..ed31107 100644 --- a/chrome/tools/crash_service/crash_service.cc +++ b/chrome/tools/crash_service/crash_service.cc @@ -40,7 +40,7 @@ bool CustomInfoToMap(const google_breakpad::ClientInfo* client_info, (*map)[L"rept"] = reporter_tag; - return (map->size() > 0); + return !map->empty(); } bool WriteCustomInfoToFile(const std::wstring& dump_path, const CrashMap& map) { diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc index 9b397d9..fd44081 100644 --- a/chrome_frame/chrome_frame_automation.cc +++ b/chrome_frame/chrome_frame_automation.cc @@ -1010,9 +1010,8 @@ void ChromeFrameAutomationClient::SetEnableExtensionAutomation( // automation, only to set it. Also, we want to avoid resetting extension // automation that some other automation client has set up. Therefore only // send the message if we are going to enable automation of some functions. - if (functions_enabled.size() > 0) { + if (!functions_enabled.empty()) tab_->SetEnableExtensionAutomation(functions_enabled); - } } // Invoked in launch background thread. diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index 0e2d5de..af2fdbf 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -1599,7 +1599,7 @@ void RenderViewHost::OnAccessibilityNotifications( if (view()) view()->OnAccessibilityNotifications(params); - if (params.size() > 0) { + if (!params.empty()) { for (unsigned i = 0; i < params.size(); i++) { const ViewHostMsg_AccessibilityNotification_Params& param = params[i]; diff --git a/courgette/adjustment_method.cc b/courgette/adjustment_method.cc index 5e9e6d2..7913f8c 100644 --- a/courgette/adjustment_method.cc +++ b/courgette/adjustment_method.cc @@ -149,7 +149,7 @@ struct Node { std::list<Node*> edges_in_frequency_order; bool in_queue_; - bool Extended() const { return edges_.size() > 0; } + bool Extended() const { return !edges_.empty(); } uint32 Weight() const { return edges_in_frequency_order.front()->count_; diff --git a/courgette/encoded_program.cc b/courgette/encoded_program.cc index 8439d31..5169c16 100644 --- a/courgette/encoded_program.cc +++ b/courgette/encoded_program.cc @@ -195,7 +195,7 @@ void EncodedProgram::AddCopy(uint32 count, const void* bytes) { // For compression of files with large differences this makes a small (4%) // improvement in size. For files with small differences this degrades the // compressed size by 1.3% - if (ops_.size() > 0) { + if (!ops_.empty()) { if (ops_.back() == COPY1) { ops_.back() = COPY; copy_counts_.push_back(1); diff --git a/jingle/notifier/communicator/connection_settings.cc b/jingle/notifier/communicator/connection_settings.cc index ec374cc..d4b764c 100644 --- a/jingle/notifier/communicator/connection_settings.cc +++ b/jingle/notifier/communicator/connection_settings.cc @@ -78,7 +78,7 @@ void ConnectionSettingsList::AddPermutations(const std::string& hostname, } // Add this list to the instance list - while (list_temp.size() != 0) { + while (!list_temp.empty()) { list_.push_back(list_temp[0]); list_temp.pop_front(); } diff --git a/media/base/composite_filter.cc b/media/base/composite_filter.cc index 41eb31c..7d26035 100644 --- a/media/base/composite_filter.cc +++ b/media/base/composite_filter.cc @@ -234,7 +234,7 @@ void CompositeFilter::StartSerialCallSequence() { DCHECK_EQ(message_loop_, MessageLoop::current()); error_ = PIPELINE_OK; - if (filters_.size() > 0) { + if (!filters_.empty()) { sequence_index_ = 0; CallFilter(filters_[sequence_index_], NewThreadSafeCallback(&CompositeFilter::SerialCallback)); @@ -248,7 +248,7 @@ void CompositeFilter::StartParallelCallSequence() { DCHECK_EQ(message_loop_, MessageLoop::current()); error_ = PIPELINE_OK; - if (filters_.size() > 0) { + if (!filters_.empty()) { sequence_index_ = 0; for (size_t i = 0; i < filters_.size(); i++) { CallFilter(filters_[i], @@ -340,7 +340,7 @@ void CompositeFilter::SerialCallback() { return; } - if (filters_.size() > 0) + if (!filters_.empty()) sequence_index_++; if (sequence_index_ == filters_.size()) { @@ -360,7 +360,7 @@ void CompositeFilter::SerialCallback() { void CompositeFilter::ParallelCallback() { DCHECK_EQ(message_loop_, MessageLoop::current()); - if (filters_.size() > 0) + if (!filters_.empty()) sequence_index_++; if (sequence_index_ == filters_.size()) { diff --git a/net/base/cookie_monster.cc b/net/base/cookie_monster.cc index 05e7355..b856f8a 100644 --- a/net/base/cookie_monster.cc +++ b/net/base/cookie_monster.cc @@ -1579,7 +1579,7 @@ CookieMonster::ParsedCookie::ParsedCookie(const std::string& cookie_line) } ParseTokenValuePairs(cookie_line); - if (pairs_.size() > 0) { + if (!pairs_.empty()) { is_valid_ = true; SetupAttributes(); } diff --git a/net/base/dnssec_chain_verifier.cc b/net/base/dnssec_chain_verifier.cc index 6e68365..c79efa8 100644 --- a/net/base/dnssec_chain_verifier.cc +++ b/net/base/dnssec_chain_verifier.cc @@ -732,12 +732,9 @@ DNSSECChainVerifier::Error DNSSECChainVerifier::ReadDSSet( } digest_types[i] = digest_type; - if (digest.size() > 0) { + lookahead[i] = digest.empty(); + if (!digest.empty()) (*rrdatas)[i] = digest; - lookahead[i] = false; - } else { - lookahead[i] = true; - } } base::StringPiece next_entry_key; diff --git a/net/base/x509_cert_types_mac.cc b/net/base/x509_cert_types_mac.cc index c672863..a45dc71 100644 --- a/net/base/x509_cert_types_mac.cc +++ b/net/base/x509_cert_types_mac.cc @@ -150,7 +150,7 @@ void SetSingle(const std::vector<std::string>& values, std::string* single_value) { // We don't expect to have more than one CN, L, S, and C. LOG_IF(WARNING, values.size() > 1) << "Didn't expect multiple values"; - if (values.size() > 0) + if (!values.empty()) *single_value = values[0]; } diff --git a/net/base/x509_certificate_mac.cc b/net/base/x509_certificate_mac.cc index f9023fd..839e91e 100644 --- a/net/base/x509_certificate_mac.cc +++ b/net/base/x509_certificate_mac.cc @@ -1128,7 +1128,7 @@ bool X509Certificate::GetSSLClientCertificates( // Make sure the issuer matches valid_issuers, if given. // But an explicit cert preference overrides this. if (!is_preferred && - valid_issuers.size() > 0 && + !valid_issuers.empty() && !cert->IsIssuedBy(valid_issuers)) continue; diff --git a/net/base/x509_certificate_win.cc b/net/base/x509_certificate_win.cc index fed56e3..98e3367 100644 --- a/net/base/x509_certificate_win.cc +++ b/net/base/x509_certificate_win.cc @@ -405,7 +405,7 @@ void ParsePrincipal(const std::string& description, for (int i = 0; i < arraysize(single_value_lists); ++i) { int length = static_cast<int>(single_value_lists[i]->size()); DCHECK(single_value_lists[i]->size() <= 1); - if (single_value_lists[i]->size() > 0) + if (!single_value_lists[i]->empty()) *(single_values[i]) = (*(single_value_lists[i]))[0]; } } diff --git a/net/http/http_util.cc b/net/http/http_util.cc index 0f28c83..fed74b6 100644 --- a/net/http/http_util.cc +++ b/net/http/http_util.cc @@ -281,7 +281,7 @@ bool HttpUtil::ParseRangeHeader(const std::string& ranges_specifier, return false; ranges->push_back(range); } - return ranges->size() > 0; + return !ranges->empty(); } // static diff --git a/net/socket/ssl_host_info.cc b/net/socket/ssl_host_info.cc index 5131949c..9d631bb 100644 --- a/net/socket/ssl_host_info.cc +++ b/net/socket/ssl_host_info.cc @@ -115,7 +115,7 @@ bool SSLHostInfo::ParseInner(const std::string& data) { state->npn_status = static_cast<SSLClientSocket::NextProtoStatus>(status); } - if (state->certs.size() > 0) { + if (!state->certs.empty()) { std::vector<base::StringPiece> der_certs(state->certs.size()); for (size_t i = 0; i < state->certs.size(); i++) der_certs[i] = state->certs[i]; diff --git a/net/tools/flip_server/balsa_headers.h b/net/tools/flip_server/balsa_headers.h index f2b7612..f06545d 100644 --- a/net/tools/flip_server/balsa_headers.h +++ b/net/tools/flip_server/balsa_headers.h @@ -816,7 +816,7 @@ class BalsaHeaders { const base::StringPiece& value) { // if the key is empty, we don't want to write the rest because it // will not be a well-formed header line. - if (key.size() > 0) { + if (!key.empty()) { buffer->Write(key.data(), key.size()); buffer->Write(": ", 2); buffer->Write(value.data(), value.size()); diff --git a/net/tools/flip_server/output_ordering.cc b/net/tools/flip_server/output_ordering.cc index 409ec0a..f5fb4cf 100644 --- a/net/tools/flip_server/output_ordering.cc +++ b/net/tools/flip_server/output_ordering.cc @@ -95,7 +95,7 @@ void OutputOrdering::AddToOutputOrder(const MemCacheIter& mci) { double think_time_in_s = server_think_time_in_s_; std::string x_server_latency = mci.file_data->headers->GetHeader("X-Server-Latency").as_string(); - if (x_server_latency.size() != 0) { + if (!x_server_latency.empty()) { char* endp; double tmp_think_time_in_s = strtod(x_server_latency.c_str(), &endp); if (endp != x_server_latency.c_str() + x_server_latency.size()) { diff --git a/net/url_request/url_request_job_tracker.cc b/net/url_request/url_request_job_tracker.cc index 49472d9..632d0a3 100644 --- a/net/url_request/url_request_job_tracker.cc +++ b/net/url_request/url_request_job_tracker.cc @@ -17,7 +17,7 @@ URLRequestJobTracker::URLRequestJobTracker() { } URLRequestJobTracker::~URLRequestJobTracker() { - DLOG_IF(WARNING, active_jobs_.size() != 0) << + DLOG_IF(WARNING, !active_jobs_.empty()) << "Leaking " << active_jobs_.size() << " URLRequestJob object(s), this " "could be because the URLRequest forgot to free it (bad), or if the " "program was terminated while a request was active (normal)."; diff --git a/net/url_request/url_request_throttler_entry.cc b/net/url_request/url_request_throttler_entry.cc index 6db76c3..033787b 100644 --- a/net/url_request/url_request_throttler_entry.cc +++ b/net/url_request/url_request_throttler_entry.cc @@ -74,7 +74,7 @@ bool URLRequestThrottlerEntry::IsEntryOutdated() const { // If there are send events in the sliding window period, we still need this // entry. - if (send_log_.size() > 0 && + if (!send_log_.empty() && send_log_.back() + sliding_window_period_ > now) { return false; } diff --git a/net/websockets/websocket_handshake_handler.cc b/net/websockets/websocket_handshake_handler.cc index 734b93e..68b0445 100644 --- a/net/websockets/websocket_handshake_handler.cc +++ b/net/websockets/websocket_handshake_handler.cc @@ -174,14 +174,14 @@ size_t WebSocketHandshakeRequestHandler::original_length() const { void WebSocketHandshakeRequestHandler::AppendHeaderIfMissing( const std::string& name, const std::string& value) { - DCHECK(headers_.size() > 0); + DCHECK(!headers_.empty()); HttpUtil::AppendHeaderIfMissing(name.c_str(), value, &headers_); } void WebSocketHandshakeRequestHandler::RemoveHeaders( const char* const headers_to_remove[], size_t headers_to_remove_len) { - DCHECK(headers_.size() > 0); + DCHECK(!headers_.empty()); headers_ = FilterHeaders( headers_, headers_to_remove, headers_to_remove_len); } @@ -267,8 +267,8 @@ bool WebSocketHandshakeRequestHandler::GetRequestHeaderBlock( } std::string WebSocketHandshakeRequestHandler::GetRawRequest() { - DCHECK(status_line_.size() > 0); - DCHECK(headers_.size() > 0); + DCHECK(!status_line_.empty()); + DCHECK(!headers_.empty()); DCHECK_EQ(kRequestKey3Size, key3_.size()); std::string raw_request = status_line_ + headers_ + "\r\n" + key3_; raw_length_ = raw_request.size(); @@ -290,8 +290,8 @@ size_t WebSocketHandshakeResponseHandler::ParseRawResponse( const char* data, int length) { DCHECK_GT(length, 0); if (HasResponse()) { - DCHECK(status_line_.size() > 0); - DCHECK(headers_.size() > 0); + DCHECK(!status_line_.empty()); + DCHECK(!headers_.empty()); DCHECK_EQ(kResponseKeySize, key_.size()); return 0; } @@ -397,8 +397,8 @@ void WebSocketHandshakeResponseHandler::GetHeaders( size_t headers_to_get_len, std::vector<std::string>* values) { DCHECK(HasResponse()); - DCHECK(status_line_.size() > 0); - DCHECK(headers_.size() > 0); + DCHECK(!status_line_.empty()); + DCHECK(!headers_.empty()); DCHECK_EQ(kResponseKeySize, key_.size()); FetchHeaders(headers_, headers_to_get, headers_to_get_len, values); @@ -408,8 +408,8 @@ void WebSocketHandshakeResponseHandler::RemoveHeaders( const char* const headers_to_remove[], size_t headers_to_remove_len) { DCHECK(HasResponse()); - DCHECK(status_line_.size() > 0); - DCHECK(headers_.size() > 0); + DCHECK(!status_line_.empty()); + DCHECK(!headers_.empty()); DCHECK_EQ(kResponseKeySize, key_.size()); headers_ = FilterHeaders(headers_, headers_to_remove, headers_to_remove_len); @@ -423,7 +423,7 @@ std::string WebSocketHandshakeResponseHandler::GetRawResponse() const { std::string WebSocketHandshakeResponseHandler::GetResponse() { DCHECK(HasResponse()); - DCHECK(status_line_.size() > 0); + DCHECK(!status_line_.empty()); // headers_ might be empty for wrong response from server. DCHECK_EQ(kResponseKeySize, key_.size()); diff --git a/net/websockets/websocket_job.cc b/net/websockets/websocket_job.cc index 44c944d..8379523 100644 --- a/net/websockets/websocket_job.cc +++ b/net/websockets/websocket_job.cc @@ -234,7 +234,7 @@ void WebSocketJob::OnReceivedData( receive_frame_handler_->GetCurrentBufferSize()); receive_frame_handler_->ReleaseCurrentBuffer(); } - if (delegate_ && received_data.size() > 0) + if (delegate_ && !received_data.empty()) delegate_->OnReceivedData( socket, received_data.data(), received_data.size()); } diff --git a/ppapi/proxy/serialized_var.cc b/ppapi/proxy/serialized_var.cc index e68c681..71c0eed 100644 --- a/ppapi/proxy/serialized_var.cc +++ b/ppapi/proxy/serialized_var.cc @@ -403,7 +403,7 @@ PP_Var* SerializedVarVectorReceiveInput::Get(Dispatcher* dispatcher, } *array_size = static_cast<uint32_t>(serialized_.size()); - return deserialized_.size() > 0 ? &deserialized_[0] : NULL; + return deserialized_.empty() ? NULL : &deserialized_[0]; } // SerializedVarReturnValue ---------------------------------------------------- diff --git a/remoting/base/compound_buffer.cc b/remoting/base/compound_buffer.cc index a766abe..049ad8e 100644 --- a/remoting/base/compound_buffer.cc +++ b/remoting/base/compound_buffer.cc @@ -99,11 +99,11 @@ void CompoundBuffer::CropFront(int bytes) { } total_bytes_ -= bytes; - while (chunks_.size() > 0 && chunks_.front().size <= bytes) { + while (!chunks_.empty() && chunks_.front().size <= bytes) { bytes -= chunks_.front().size; chunks_.pop_front(); } - if (chunks_.size() > 0 && bytes > 0) { + if (!chunks_.empty() && bytes > 0) { chunks_.front().start += bytes; chunks_.front().size -= bytes; DCHECK_GT(chunks_.front().size, 0); @@ -121,11 +121,11 @@ void CompoundBuffer::CropBack(int bytes) { } total_bytes_ -= bytes; - while (chunks_.size() > 0 && chunks_.back().size <= bytes) { + while (!chunks_.empty() && chunks_.back().size <= bytes) { bytes -= chunks_.back().size; chunks_.pop_back(); } - if (chunks_.size() > 0 && bytes > 0) { + if (!chunks_.empty() && bytes > 0) { chunks_.back().size -= bytes; DCHECK_GT(chunks_.back().size, 0); bytes = 0; diff --git a/remoting/base/tracer.cc b/remoting/base/tracer.cc index a534deb..ba359d4 100644 --- a/remoting/base/tracer.cc +++ b/remoting/base/tracer.cc @@ -76,7 +76,7 @@ class OutputLogger { wake_.Wait(); } // Check again since we might have woken for a stop signal. - if (buffers_.size() != 0) { + if (!buffers_.empty()) { buffer = buffers_.back(); buffers_.pop_back(); } diff --git a/remoting/jingle_glue/jingle_thread.cc b/remoting/jingle_glue/jingle_thread.cc index b8bc428..9dc3915 100644 --- a/remoting/jingle_glue/jingle_thread.cc +++ b/remoting/jingle_glue/jingle_thread.cc @@ -163,7 +163,7 @@ void JingleThread::OnMessage(talk_base::Message* msg) { // Stop the thread only if there are no more messages left in the queue, // otherwise post another task to try again later. - if (msgq_.size() > 0 || fPeekKeep_) { + if (!msgq_.empty() || fPeekKeep_) { Post(this, kStopMessageId); } else { MessageQueue::Quit(); diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc index da09579..e694090 100644 --- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc +++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc @@ -310,7 +310,7 @@ void NativeTabbedPaneWin::CreateNativeControl() { NativeControlCreated(tab_control); // Add tabs that are already added if any. - if (tab_views_.size() > 0) { + if (!tab_views_.empty()) { InitializeTabs(); if (selected_index_ >= 0) DoSelectTabAt(selected_index_, false); diff --git a/views/view.cc b/views/view.cc index 58c50f7..5643e80 100644 --- a/views/view.cc +++ b/views/view.cc @@ -555,10 +555,7 @@ void View::GetViewsWithGroup(int group_id, std::vector<View*>* out) { View* View::GetSelectedViewForGroup(int group_id) { std::vector<View*> views; GetWidget()->GetRootView()->GetViewsWithGroup(group_id, &views); - if (views.size() > 0) - return views[0]; - else - return NULL; + return views.empty() ? NULL : views[0]; } // Coordinate conversion ------------------------------------------------------- diff --git a/views/view_text_utils.cc b/views/view_text_utils.cc index 0a3fc33..d221e19 100644 --- a/views/view_text_utils.cc +++ b/views/view_text_utils.cc @@ -142,7 +142,7 @@ void DrawTextStartingFrom(gfx::Canvas* canvas, canvas->DrawStringInt(word, font, text_color, x, y, w, font.GetHeight(), flags); - if (word.size() > 0 && word[word.size() - 1] == '\x0a') { + if (!word.empty() && word[word.size() - 1] == '\x0a') { // When we come across '\n', we move to the beginning of the next line. position->set_width(0); position->Enlarge(0, font.GetHeight()); diff --git a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc index 6f9d803..835611b 100644 --- a/webkit/gpu/webgraphicscontext3d_in_process_impl.cc +++ b/webkit/gpu/webgraphicscontext3d_in_process_impl.cc @@ -1012,7 +1012,7 @@ WebGraphicsContext3D::Attributes WebGraphicsContext3DInProcessImpl:: WGC3Denum WebGraphicsContext3DInProcessImpl::getError() { DCHECK(synthetic_errors_list_.size() == synthetic_errors_set_.size()); - if (synthetic_errors_set_.size() > 0) { + if (!synthetic_errors_set_.empty()) { WGC3Denum error = synthetic_errors_list_.front(); synthetic_errors_list_.pop_front(); synthetic_errors_set_.erase(error); diff --git a/webkit/plugins/npapi/plugin_lib_mac.mm b/webkit/plugins/npapi/plugin_lib_mac.mm index f80e8f2..c703b2c 100644 --- a/webkit/plugins/npapi/plugin_lib_mac.mm +++ b/webkit/plugins/npapi/plugin_lib_mac.mm @@ -219,7 +219,7 @@ bool ReadSTRPluginInfo(const FilePath& filename, CFBundleRef bundle, info->path = filename; if (plugin_vers) info->version = base::SysNSStringToUTF16(plugin_vers); - if (have_plugin_descs && plugin_descs.size() > 0) + if (have_plugin_descs && !plugin_descs.empty()) info->desc = UTF8ToUTF16(plugin_descs[0]); else info->desc = UTF8ToUTF16(filename.BaseName().value()); diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 7cb00df..3feef80 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -241,7 +241,7 @@ int main(int argc, char* argv[]) { starting_url = net::FilePathToFileURL(path); const std::vector<CommandLine::StringType>& args = parsed_command_line.args(); - if (args.size() > 0) { + if (!args.empty()) { GURL url(args[0]); if (url.is_valid()) { starting_url = url; |