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

Unified Diff: content/renderer/notification_permission_dispatcher.cc

Issue 1471833002: Stop using base::IDMap in the NotificationPermissionDispatcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/notification_permission_dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/notification_permission_dispatcher.cc
diff --git a/content/renderer/notification_permission_dispatcher.cc b/content/renderer/notification_permission_dispatcher.cc
index 90eef27cf7787f650bbbe87a4e7910ba8acad42a..13f0ca3b23713bc20ee15fe027369a3e8066c024 100644
--- a/content/renderer/notification_permission_dispatcher.cc
+++ b/content/renderer/notification_permission_dispatcher.cc
@@ -12,38 +12,38 @@
#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
#include "third_party/WebKit/public/web/modules/notifications/WebNotificationPermissionCallback.h"
+using blink::WebNotificationPermissionCallback;
+
namespace content {
NotificationPermissionDispatcher::NotificationPermissionDispatcher(
- RenderFrame* render_frame) : RenderFrameObserver(render_frame) {
-}
+ RenderFrame* render_frame)
+ : RenderFrameObserver(render_frame) {}
-NotificationPermissionDispatcher::~NotificationPermissionDispatcher() {
-}
+NotificationPermissionDispatcher::~NotificationPermissionDispatcher() {}
void NotificationPermissionDispatcher::RequestPermission(
const blink::WebSecurityOrigin& origin,
- blink::WebNotificationPermissionCallback* callback) {
+ WebNotificationPermissionCallback* callback) {
if (!permission_service_.get()) {
render_frame()->GetServiceRegistry()->ConnectToRemoteService(
mojo::GetProxy(&permission_service_));
}
- int request_id = pending_requests_.Add(callback);
+ scoped_ptr<WebNotificationPermissionCallback> owned_callback(callback);
+ // base::Unretained is safe here because the Mojo channel, with associated
+ // callbacks, will be deleted before the "this" instance is deleted.
permission_service_->RequestPermission(
- PERMISSION_NAME_NOTIFICATIONS,
- origin.toString().utf8(),
+ PERMISSION_NAME_NOTIFICATIONS, origin.toString().utf8(),
blink::WebUserGestureIndicator::isProcessingUserGesture(),
base::Bind(&NotificationPermissionDispatcher::OnPermissionRequestComplete,
- base::Unretained(this),
- request_id));
+ base::Unretained(this), base::Passed(owned_callback.Pass())));
}
void NotificationPermissionDispatcher::OnPermissionRequestComplete(
- int request_id, PermissionStatus status) {
- blink::WebNotificationPermissionCallback* callback =
- pending_requests_.Lookup(request_id);
+ scoped_ptr<WebNotificationPermissionCallback> callback,
+ PermissionStatus status) {
DCHECK(callback);
blink::WebNotificationPermission permission =
@@ -61,7 +61,6 @@ void NotificationPermissionDispatcher::OnPermissionRequestComplete(
}
callback->permissionRequestComplete(permission);
- pending_requests_.Remove(request_id);
}
} // namespace content
« no previous file with comments | « content/renderer/notification_permission_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698