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

Unified Diff: content/browser/permissions/permission_service_impl.cc

Issue 1019173002: Update mojo sdk to rev 7214b7ec7d27563b2666afad86cf1c5895c56c18 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Keep permission service alive if embedder drops requests Created 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/permissions/permission_service_impl.cc
diff --git a/content/browser/permissions/permission_service_impl.cc b/content/browser/permissions/permission_service_impl.cc
index 940e7832695a83fba7c8b5c1207174df9bce8c44..2de48c4d8ce9c6327994479c4f16ababd75945be 100644
--- a/content/browser/permissions/permission_service_impl.cc
+++ b/content/browser/permissions/permission_service_impl.cc
@@ -30,10 +30,19 @@ PermissionType PermissionNameToPermissionType(PermissionName name) {
} // anonymous namespace
-PermissionServiceImpl::PendingRequest::PendingRequest(PermissionType permission,
- const GURL& origin)
+PermissionServiceImpl::PendingRequest::PendingRequest(
+ PermissionType permission,
+ const GURL& origin,
+ const mojo::Callback<void(PermissionStatus)>& callback)
: permission(permission),
- origin(origin) {
+ origin(origin),
+ callback(callback) {
+}
+
+PermissionServiceImpl::PendingRequest::~PendingRequest() {
+ if (!callback.is_null()) {
+ callback.Run(PERMISSION_STATUS_ASK);
+ }
}
PermissionServiceImpl::PermissionServiceImpl(PermissionServiceContext* context)
@@ -70,7 +79,7 @@ void PermissionServiceImpl::RequestPermission(
PermissionType permission_type = PermissionNameToPermissionType(permission);
int request_id = pending_requests_.Add(
- new PendingRequest(permission_type, GURL(origin)));
+ new PendingRequest(permission_type, GURL(origin), callback));
GetContentClient()->browser()->RequestPermission(
permission_type,
@@ -80,16 +89,16 @@ void PermissionServiceImpl::RequestPermission(
user_gesture, // TODO(mlamouri): should be removed (crbug.com/423770)
base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse,
weak_factory_.GetWeakPtr(),
- callback,
request_id));
}
void PermissionServiceImpl::OnRequestPermissionResponse(
- const mojo::Callback<void(PermissionStatus)>& callback,
int request_id,
PermissionStatus status) {
+ PendingRequest* request = pending_requests_.Lookup(request_id);
+ mojo::Callback<void(PermissionStatus)> callback(request->callback);
+ request->callback.reset();
pending_requests_.Remove(request_id);
-
callback.Run(status);
}
« no previous file with comments | « content/browser/permissions/permission_service_impl.h ('k') | content/browser/presentation/presentation_service_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698