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

Side by Side Diff: chrome/browser/notifications/native_notification_display_service.cc

Issue 2749453002: Make GetDisplayedNotifications asynchronous. (Closed)
Patch Set: review Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/notifications/native_notification_display_service.h" 5 #include "chrome/browser/notifications/native_notification_display_service.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/nullable_string16.h" 8 #include "base/strings/nullable_string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/notifications/non_persistent_notification_handler.h" 10 #include "chrome/browser/notifications/non_persistent_notification_handler.h"
11 #include "chrome/browser/notifications/notification.h" 11 #include "chrome/browser/notifications/notification.h"
12 #include "chrome/browser/notifications/notification_delegate.h" 12 #include "chrome/browser/notifications/notification_delegate.h"
13 #include "chrome/browser/notifications/notification_handler.h" 13 #include "chrome/browser/notifications/notification_handler.h"
14 #include "chrome/browser/notifications/notification_platform_bridge.h" 14 #include "chrome/browser/notifications/notification_platform_bridge.h"
15 #include "chrome/browser/notifications/persistent_notification_handler.h" 15 #include "chrome/browser/notifications/persistent_notification_handler.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "content/public/browser/browser_thread.h"
17 18
18 namespace { 19 namespace {
19 20
20 std::string GetProfileId(Profile* profile) { 21 std::string GetProfileId(Profile* profile) {
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 std::string profile_id = 23 std::string profile_id =
23 base::WideToUTF8(profile->GetPath().BaseName().value()); 24 base::WideToUTF8(profile->GetPath().BaseName().value());
24 #elif defined(OS_POSIX) 25 #elif defined(OS_POSIX)
25 std::string profile_id = profile->GetPath().BaseName().value(); 26 std::string profile_id = profile->GetPath().BaseName().value();
26 #endif 27 #endif
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 NotificationHandler* handler = GetNotificationHandler(notification_type); 63 NotificationHandler* handler = GetNotificationHandler(notification_type);
63 notification_bridge_->Close(GetProfileId(profile_), notification_id); 64 notification_bridge_->Close(GetProfileId(profile_), notification_id);
64 65
65 // TODO(miguelg): Figure out something better here, passing an empty 66 // TODO(miguelg): Figure out something better here, passing an empty
66 // origin works because only non persistent notifications care about 67 // origin works because only non persistent notifications care about
67 // this method for JS generated close calls and they don't require 68 // this method for JS generated close calls and they don't require
68 // the origin. 69 // the origin.
69 handler->OnClose(profile_, "", notification_id, false /* by user */); 70 handler->OnClose(profile_, "", notification_id, false /* by user */);
70 } 71 }
71 72
72 bool NativeNotificationDisplayService::GetDisplayed( 73 void NativeNotificationDisplayService::GetDisplayed(
73 std::set<std::string>* notifications) const { 74 const DisplayedNotificationsCallback& callback) const {
74 return notification_bridge_->GetDisplayed( 75 return notification_bridge_->GetDisplayed(
75 GetProfileId(profile_), profile_->IsOffTheRecord(), notifications); 76 GetProfileId(profile_), profile_->IsOffTheRecord(), callback);
76 } 77 }
77 78
78 void NativeNotificationDisplayService::ProcessNotificationOperation( 79 void NativeNotificationDisplayService::ProcessNotificationOperation(
79 NotificationCommon::Operation operation, 80 NotificationCommon::Operation operation,
80 NotificationCommon::Type notification_type, 81 NotificationCommon::Type notification_type,
81 const std::string& origin, 82 const std::string& origin,
82 const std::string& notification_id, 83 const std::string& notification_id,
83 int action_index, 84 int action_index,
84 const base::NullableString16& reply) { 85 const base::NullableString16& reply) {
85 NotificationHandler* handler = GetNotificationHandler(notification_type); 86 NotificationHandler* handler = GetNotificationHandler(notification_type);
(...skipping 24 matching lines...) Expand all
110 notification_handlers_.erase(notification_type); 111 notification_handlers_.erase(notification_type);
111 } 112 }
112 113
113 NotificationHandler* NativeNotificationDisplayService::GetNotificationHandler( 114 NotificationHandler* NativeNotificationDisplayService::GetNotificationHandler(
114 NotificationCommon::Type notification_type) { 115 NotificationCommon::Type notification_type) {
115 DCHECK(notification_handlers_.find(notification_type) != 116 DCHECK(notification_handlers_.find(notification_type) !=
116 notification_handlers_.end()) 117 notification_handlers_.end())
117 << notification_type << " is not registered."; 118 << notification_type << " is not registered.";
118 return notification_handlers_[notification_type].get(); 119 return notification_handlers_[notification_type].get();
119 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698