Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Issue 1403003004: Revert of Update first download notification correctly if there are multiple notifications (Closed)

Created:
5 years, 2 months ago by benwells
Modified:
5 years, 2 months ago
Reviewers:
asanka, yoshiki
CC:
asanka, chromium-reviews, chrome-apps-syd-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Revert of Update first download notification correctly if there are multiple notifications (patchset #2 id:140001 of https://codereview.chromium.org/1389273004/ ) Reason for revert: This has caused memory errors on the ChromeOS memory bots. See http://build.chromium.org/p/chromium.memory/builders/Linux%20Chromium%20OS%20ASan%20LSan%20Tests%20%281%29/builds/5723 for an example build. Sample failure output: ==2253==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x7f0398815ca4 in operator==\u003Cstd::__1::allocator\u003Cchar> > buildtools/third_party/libc++/trunk/include/string:3812:9 #1 0x7f0398815ca4 in message_center::NotificationList::GetNotification(std::__1::basic_string\u003Cchar, std::__1::char_traits\u003Cchar>, std::__1::allocator\u003Cchar> > const&) ui/message_center/notification_list.cc:319:0 #2 0x7f0398815d85 in message_center::NotificationList::RemoveNotification(std::__1::basic_string\u003Cchar, std::__1::char_traits\u003Cchar>, std::__1::allocator\u003Cchar> > const&) ui/message_center/notification_list.cc:123:21 #3 0x7f03987f8691 in message_center::MessageCenterImpl::RemoveNotifications(bool, std::__1::vector\u003Cmessage_center::NotificationBlocker*, std::__1::allocator\u003Cmessage_center::NotificationBlocker*> > const&) ui/message_center/message_center_impl.cc:664:5 #4 0x7f03987f8115 in message_center::MessageCenterImpl::RemoveAllNotifications(bool) ui/message_center/message_center_impl.cc:646:3 #5 0x7f038daba090 in content::NotificationServiceImpl::Notify(int, content::NotificationSource const&, content::NotificationDetails const&) content/browser/notification_service_impl.cc:130:5 #6 0x7f0386830ee7 in chrome::NotifyAppTerminating() chrome/browser/lifetime/application_lifetime.cc:318:3 #7 0x7f038ac73bc2 in BrowserList::RemoveBrowser(Browser*) chrome/browser/ui/browser_list.cc:105:5 ..... Uninitialized value was created by a heap deallocation #0 0x7f0382c9edd2 in __interceptor_free ??:0:0 #1 0x7f038c16d632 in hb_buffer_destroy third_party/harfbuzz-ng/src/hb-buffer.cc:785:3 #2 0x7f038c127512 in gfx::RenderTextHarfBuzz::ShapeRunWithFont(std::__1::basic_string\u003Cunsigned short, base::string16_char_traits, std::__1::allocator\u003Cunsigned short> > const&, std::__1::basic_string\u003Cchar, std::__1::char_traits\u003Cchar>, std::__1::allocator\u003Cchar> > const&, gfx::FontRenderParams const&, gfx::internal::TextRunHarfBuzz*) ui/gfx/render_text_harfbuzz.cc:1511:3 #3 0x7f038c128417 in CompareFamily ui/gfx/render_text_harfbuzz.cc:1311:8 #4 0x7f038c128417 in gfx::RenderTextHarfBuzz::ShapeRun(std::__1::basic_string\u003Cunsigned short, base::string16_char_traits, std::__1::allocator\u003Cunsigned short> > const&, gfx::internal::TextRunHarfBuzz*) ui/gfx/render_text_harfbuzz.cc:1366:0 #5 0x7f038c113e9b in ShapeRunList ui/gfx/render_text_harfbuzz.cc:1326:5 #6 0x7f038c113e9b in gfx::RenderTextHarfBuzz::EnsureLayoutRunList() ui/gfx/render_text_harfbuzz.cc:1529:0 #7 0x7f038c11b493 in gfx::RenderTextHarfBuzz::EnsureLayout() ui/gfx/render_text_harfbuzz.cc:1058:3 #8 0x7f038c11505f in gfx::RenderTextHarfBuzz::GetStringSizeF() ui/gfx/render_text_harfbuzz.cc:789:3 #9 0x7f038c114ee1 in gfx::RenderTextHarfBuzz::GetStringSize() ui/gfx/render_text_harfbuzz.cc:784:24 #10 0x7f038a3c2e67 in views::Label::GetTextSize() const ui/views/controls/label.cc:522:12 #11 0x7f038a3c2674 in views::Label::GetPreferredSize() const ui/views/controls/label.cc:228:18 #12 0x7f038a449484 in MainAxisSizeForView ui/views/layout/box_layout.cc:251:16 #13 0x7f038a449484 in views::BoxLayout::Layout(views::View*) ui/views/layout/box_layout.cc:65:0 #14 0x7f038a4734ff in views::View::Layout() ui/views/view.cc:505:5 #15 0x7f039884b041 in message_center::NotificationView::CreateOrUpdateActionButtonViews(message_center::Notification const&) ui/message_center/views/notification_view.cc:748:7 ..... Original issue's description: > Update first download notification correctly if there are multiple notifications > > This patch fixes the issue on updating the first download notification by fixing the visibility check in DownloadItemNotification. This issue was the regression of https://crrev.com/49b2b0338e0eb698a24b045bf09603b853d7c4a7. > > BUG=541633 > TEST=trybot passes > > Committed: https://crrev.com/795243b38d321e1e9d1f32d814265461194d74b0 > Cr-Commit-Position: refs/heads/master@{#354177} TBR=asanka@chromium.org,yoshiki@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=541633

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -81 lines) Patch
M chrome/browser/download/notification/download_item_notification.h View 2 chunks +2 lines, -6 lines 0 comments Download
M chrome/browser/download/notification/download_item_notification.cc View 6 chunks +12 lines, -15 lines 0 comments Download
M chrome/browser/download/notification/download_item_notification_unittest.cc View 4 chunks +0 lines, -27 lines 0 comments Download
M chrome/browser/download/notification/download_notification_browsertest.cc View 2 chunks +0 lines, -16 lines 0 comments Download
M chrome/browser/download/notification/download_notification_manager.h View 2 chunks +0 lines, -10 lines 0 comments Download
M chrome/browser/download/notification/download_notification_manager.cc View 2 chunks +0 lines, -7 lines 0 comments Download

Messages

Total messages: 5 (2 generated)
benwells
Created Revert of Update first download notification correctly if there are multiple notifications
5 years, 2 months ago (2015-10-15 06:04:07 UTC) #1
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1403003004/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1403003004/1
5 years, 2 months ago (2015-10-15 06:04:25 UTC) #2
commit-bot: I haz the power
5 years, 2 months ago (2015-10-15 06:04:57 UTC) #4
Failed to apply patch for
chrome/browser/download/notification/download_item_notification.cc:
While running git apply --index -3 -p1;
  error: patch failed:
chrome/browser/download/notification/download_item_notification.cc:331
  Falling back to three-way merge...
  Applied patch to
'chrome/browser/download/notification/download_item_notification.cc' with
conflicts.
  U chrome/browser/download/notification/download_item_notification.cc

Patch:       chrome/browser/download/notification/download_item_notification.cc
Index: chrome/browser/download/notification/download_item_notification.cc
diff --git a/chrome/browser/download/notification/download_item_notification.cc
b/chrome/browser/download/notification/download_item_notification.cc
index
41c1d8d7bbbf43de7ccb30c082e162b32acf2ec9..66b5d26ceaaab825b0a72dc4d23298d6851214e4
100644
--- a/chrome/browser/download/notification/download_item_notification.cc
+++ b/chrome/browser/download/notification/download_item_notification.cc
@@ -163,9 +163,7 @@
     content::DownloadItem* item,
     DownloadNotificationManagerForProfile* manager)
     : item_(item),
-      message_center_(manager->message_center()),
       weak_factory_(this) {
-
   // Creates the notification instance. |title|, |body| and |icon| will be
   // overridden by UpdateNotificationData() below.
   notification_.reset(new Notification(
@@ -201,6 +199,8 @@
 }
 
 void DownloadItemNotification::OnNotificationClose() {
+  visible_ = false;
+
   if (item_ && item_->IsDangerous() && !item_->IsDone()) {
     content::RecordAction(
         UserMetricsAction("DownloadNotification.Close_Dangerous"));
@@ -314,7 +314,7 @@
   // MessageCenter instance.
   // Note that: this calling has no side-effect even when the message center
   // is not opened.
-  message_center_->RemoveNotification(
+  g_browser_process->message_center()->RemoveNotification(
       notification_id_in_message_center, true /* by_user */);
 }
 
@@ -331,11 +331,13 @@
        (download_state == content::DownloadItem::INTERRUPTED &&
         previous_download_state_ != content::DownloadItem::INTERRUPTED));
 
-  if (IsNotificationVisible()) {
+  if (visible_) {
     UpdateNotificationData(popup ? UPDATE_AND_POPUP : UPDATE);
   } else {
-    if (show_next_ || popup)
+    if (show_next_ || popup) {
       UpdateNotificationData(ADD);
+      visible_ = true;
+    }
   }
 
   show_next_ = false;
@@ -427,7 +429,7 @@
     // immediately when the message center is visible.
     // See the comment in MessageCenterImpl::UpdateNotification() for detail.
     if (type == UPDATE_AND_POPUP &&
-        message_center_->IsMessageCenterVisible() &&
+        g_browser_process->message_center()->IsMessageCenterVisible() &&
         (item_->GetState() == content::DownloadItem::COMPLETE ||
          item_->GetState() == content::DownloadItem::INTERRUPTED)) {
       DCHECK_EQ(notification_->type(),
@@ -899,17 +901,12 @@
 bool DownloadItemNotification::IsNotificationVisible() const {
   const std::string& notification_id = watcher()->id();
   const ProfileID profile_id = NotificationUIManager::GetProfileID(profile());
-  if (!g_browser_process->notification_ui_manager())
-    return false;
-  const Notification* notification = g_browser_process->
-      notification_ui_manager()->FindById(notification_id, profile_id);
-  if (!notification)
-    return false;
-
-  const std::string notification_id_in_message_center = notification->id();
+  const std::string notification_id_in_message_center =
+      ProfileNotification::GetProfileNotificationId(notification_id,
+                                                    profile_id);
 
   message_center::NotificationList::Notifications visible_notifications =
-      message_center_->GetVisibleNotifications();
+      g_browser_process->message_center()->GetVisibleNotifications();
   for (const auto& notification : visible_notifications) {
     if (notification->id() == notification_id_in_message_center)
       return true;

Powered by Google App Engine
This is Rietveld 408576698