0

Change other usages of .size() to .empty() when applicable.

BUG=carnitas
TEST=compiles

Review URL: http://codereview.chromium.org/6609008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76962 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
erg@google.com
2011-03-04 21:03:47 +00:00
parent 5bd8d1716b
commit 6775e40aeb
91 changed files with 142 additions and 158 deletions
base
chrome
browser
common
renderer
test
reliability
url_fetch_test
tools
crash_service
chrome_frame
content/browser/renderer_host
courgette
jingle/notifier/communicator
media/base
net
ppapi/proxy
remoting
views
webkit

@ -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.

@ -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 =

@ -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 */;
}

@ -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();

@ -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;

@ -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;

@ -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);

@ -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.

@ -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

@ -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,

@ -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);
}

@ -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)

@ -174,7 +174,7 @@ void ExtensionPortsRemoteService::HandleMessage(
}
int destination = -1;
if (destinationString.size() != 0)
if (!destinationString.empty())
base::StringToInt(destinationString, &destination);
if (command == kConnect) {

@ -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);

@ -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;

@ -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);

@ -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] : "";

@ -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;

@ -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();

@ -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)

@ -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();

@ -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

@ -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;
}

@ -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);

@ -516,7 +516,7 @@ bool MacKeychainPasswordFormAdapter::HasPasswordsMergeableWithForm(
keychain_->Free(*i);
}
return matches.size() != 0;
return !matches.empty();
}
std::vector<PasswordForm*>

@ -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]);
}

@ -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;

@ -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;
}

@ -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()) {

@ -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(

@ -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(

@ -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(

@ -433,7 +433,7 @@ void ProfileSyncService::CreateBackend() {
}
bool ProfileSyncService::IsEncryptedDatatypeEnabled() const {
return encrypted_types_.size() > 0;
return !encrypted_types_.empty();
}
void ProfileSyncService::StartUp() {

@ -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;

@ -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"

@ -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];

@ -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 =

@ -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)

@ -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,

@ -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) {

@ -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) {

@ -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());
}

@ -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);
}

@ -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

@ -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);
}

@ -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()) {

@ -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]));

@ -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));

@ -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,

@ -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 {

@ -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;
}

@ -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;

@ -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;
}

@ -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;
}

@ -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());
}

@ -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 {

@ -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);

@ -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) {

@ -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();

@ -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) {

@ -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));
}

@ -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) {

@ -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.

@ -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];

@ -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_;

@ -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);

@ -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();
}

@ -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()) {

@ -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();
}

@ -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;

@ -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];
}

@ -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;

@ -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];
}
}

@ -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

@ -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];

@ -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());

@ -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()) {

@ -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).";

@ -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;
}

@ -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());

@ -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());
}

@ -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 ----------------------------------------------------

@ -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;

@ -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();
}

@ -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();

@ -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);

@ -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 -------------------------------------------------------

@ -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());

@ -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);

@ -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());

@ -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;