diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-04 20:44:39 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-04 20:44:39 +0000 |
commit | dfd534872c2c16bf2f2e559c53c2d3ccce6380d2 (patch) | |
tree | 58e4e5f1b81cedcd1d76f2f96dc28fc9a797db68 | |
parent | c1f2addd794ec16639d4003493cbd44e208be7c3 (diff) | |
download | chromium_src-dfd534872c2c16bf2f2e559c53c2d3ccce6380d2.zip chromium_src-dfd534872c2c16bf2f2e559c53c2d3ccce6380d2.tar.gz chromium_src-dfd534872c2c16bf2f2e559c53c2d3ccce6380d2.tar.bz2 |
Adds some logging in hopes of tracking down a crasher.
BUG=44642
TEST=none
Review URL: http://codereview.chromium.org/2629002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48970 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/view_ids.h | 4 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.cc | 22 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view.h | 4 |
3 files changed, 28 insertions, 2 deletions
diff --git a/chrome/browser/view_ids.h b/chrome/browser/view_ids.h index 74fb526..8e788dd 100644 --- a/chrome/browser/view_ids.h +++ b/chrome/browser/view_ids.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -49,6 +49,8 @@ enum ViewID { // The Bookmark Bar. VIEW_ID_BOOKMARK_BAR, VIEW_ID_OTHER_BOOKMARKS, + // Used for bookmarks/folders on the bookmark bar. + VIEW_ID_BOOKMARK_BAR_ELEMENT, // Find in page. VIEW_ID_FIND_IN_PAGE_TEXT_FIELD, diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 1846435d..9ca4ec5 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -19,6 +19,7 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_theme_provider.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/pref_service.h" @@ -916,6 +917,7 @@ MenuButton* BookmarkBarView::CreateOtherBookmarkedButton() { MenuButton* button = new BookmarkFolderButton( this, l10n_util::GetString(IDS_BOOMARK_BAR_OTHER_BOOKMARKED), this, false); + button->SetID(VIEW_ID_OTHER_BOOKMARKS); button->SetIcon(GetGroupIcon()); button->SetContextMenuController(this); button->set_tag(kOtherFolderButtonTag); @@ -984,12 +986,14 @@ void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model, int new_index) { BookmarkNodeRemovedImpl(model, old_parent, old_index); BookmarkNodeAddedImpl(model, new_parent, new_index); + CheckIntegrity(); } void BookmarkBarView::BookmarkNodeAdded(BookmarkModel* model, const BookmarkNode* parent, int index) { BookmarkNodeAddedImpl(model, parent, index); + CheckIntegrity(); } void BookmarkBarView::BookmarkNodeAddedImpl(BookmarkModel* model, @@ -1016,6 +1020,7 @@ void BookmarkBarView::BookmarkNodeRemoved(BookmarkModel* model, int old_index, const BookmarkNode* node) { BookmarkNodeRemovedImpl(model, parent, old_index); + CheckIntegrity(); } void BookmarkBarView::BookmarkNodeRemovedImpl(BookmarkModel* model, @@ -1042,6 +1047,7 @@ void BookmarkBarView::BookmarkNodeChanged(BookmarkModel* model, const BookmarkNode* node) { NotifyModelChanged(); BookmarkNodeChangedImpl(model, node); + CheckIntegrity(); } void BookmarkBarView::BookmarkNodeChangedImpl(BookmarkModel* model, @@ -1084,6 +1090,8 @@ void BookmarkBarView::BookmarkNodeChildrenReordered(BookmarkModel* model, Layout(); SchedulePaint(); + + CheckIntegrity(); } void BookmarkBarView::BookmarkNodeFavIconLoaded(BookmarkModel* model, @@ -1121,6 +1129,8 @@ int BookmarkBarView::GetDragOperations(View* sender, const gfx::Point& p) { return DragDropTypes::DRAG_NONE; } + CheckIntegrity(); + for (int i = 0; i < GetBookmarkButtonCount(); ++i) { if (sender == GetBookmarkButton(i)) { return bookmark_utils::BookmarkDragOperation( @@ -1276,7 +1286,7 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node, views::TextButton* button) { button->SetText(node->GetTitle()); button->SetAccessibleName(node->GetTitle()); - + button->SetID(VIEW_ID_BOOKMARK_BAR_ELEMENT); // We don't always have a theme provider (ui tests, for example). if (GetThemeProvider()) { button->SetEnabledColor(GetThemeProvider()->GetColor( @@ -1721,3 +1731,13 @@ views::TextButton* BookmarkBarView::CreateSyncErrorButton() { *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); return sync_error_button; } + +void BookmarkBarView::CheckIntegrity() { + // We better be on the ui thread. + CHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + + // And the number of views on the bookmark bar better match that of the model. + volatile int model_count = model_->GetBookmarkBarNode()->GetChildCount(); + volatile int view_count = GetBookmarkButtonCount(); + CHECK_EQ(model_count, view_count); +} diff --git a/chrome/browser/views/bookmark_bar_view.h b/chrome/browser/views/bookmark_bar_view.h index 9348944..1aa8d1b 100644 --- a/chrome/browser/views/bookmark_bar_view.h +++ b/chrome/browser/views/bookmark_bar_view.h @@ -429,6 +429,10 @@ class BookmarkBarView : public DetachableToolbarView, // Creates the sync error button and adds it as a child view. views::TextButton* CreateSyncErrorButton(); + // Asserts the number of bookmark buttons we have matches that of the model, + // as well as this being invoked on the ui thread. + void CheckIntegrity(); + NotificationRegistrar registrar_; Profile* profile_; |