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

Side by Side Diff: content/browser/permissions/permission_service_impl.cc

Issue 2062333002: mojo::Callback -> base::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/permissions/permission_service_impl.h" 5 #include "content/browser/permissions/permission_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 NOTREACHED(); 46 NOTREACHED();
47 return PermissionType::NUM; 47 return PermissionType::NUM;
48 } 48 }
49 49
50 // This function allows the usage of the the multiple request map 50 // This function allows the usage of the the multiple request map
51 // with single requests. 51 // with single requests.
52 void PermissionRequestResponseCallbackWrapper( 52 void PermissionRequestResponseCallbackWrapper(
53 const mojo::Callback<void(PermissionStatus)>& callback, 53 const mojo::Callback<void(PermissionStatus)>& callback,
54 const mojo::Array<PermissionStatus>& vector) { 54 mojo::Array<PermissionStatus> vector) {
55 DCHECK_EQ(vector.size(), 1ul); 55 DCHECK_EQ(vector.size(), 1ul);
56 callback.Run(vector[0]); 56 callback.Run(vector[0]);
57 } 57 }
58 58
59 } // anonymous namespace 59 } // anonymous namespace
60 60
61 PermissionServiceImpl::PendingRequest::PendingRequest( 61 PermissionServiceImpl::PendingRequest::PendingRequest(
62 const PermissionsStatusCallback& callback, 62 const PermissionsStatusCallback& callback,
63 int request_count) 63 int request_count)
64 : callback(callback), 64 : callback(callback),
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (!pending_request) 209 if (!pending_request)
210 return; 210 return;
211 pending_request->id = id; 211 pending_request->id = id;
212 } 212 }
213 213
214 void PermissionServiceImpl::OnRequestPermissionsResponse( 214 void PermissionServiceImpl::OnRequestPermissionsResponse(
215 int pending_request_id, 215 int pending_request_id,
216 const std::vector<PermissionStatus>& result) { 216 const std::vector<PermissionStatus>& result) {
217 PendingRequest* request = pending_requests_.Lookup(pending_request_id); 217 PendingRequest* request = pending_requests_.Lookup(pending_request_id);
218 PermissionsStatusCallback callback(request->callback); 218 PermissionsStatusCallback callback(request->callback);
219 request->callback.reset(); 219 request->callback.Reset();
220 pending_requests_.Remove(pending_request_id); 220 pending_requests_.Remove(pending_request_id);
221 callback.Run(mojo::Array<PermissionStatus>::From(result)); 221 callback.Run(mojo::Array<PermissionStatus>::From(result));
222 } 222 }
223 223
224 void PermissionServiceImpl::CancelPendingOperations() { 224 void PermissionServiceImpl::CancelPendingOperations() {
225 DCHECK(context_->GetBrowserContext()); 225 DCHECK(context_->GetBrowserContext());
226 226
227 PermissionManager* permission_manager = 227 PermissionManager* permission_manager =
228 context_->GetBrowserContext()->GetPermissionManager(); 228 context_->GetBrowserContext()->GetPermissionManager();
229 if (!permission_manager) 229 if (!permission_manager)
230 return; 230 return;
231 231
232 // Cancel pending requests. 232 // Cancel pending requests.
233 for (RequestsMap::Iterator<PendingRequest> it(&pending_requests_); 233 for (RequestsMap::Iterator<PendingRequest> it(&pending_requests_);
234 !it.IsAtEnd(); it.Advance()) { 234 !it.IsAtEnd(); it.Advance()) {
235 permission_manager->CancelPermissionRequest( 235 permission_manager->CancelPermissionRequest(
236 it.GetCurrentValue()->id); 236 it.GetCurrentValue()->id);
237 } 237 }
238 pending_requests_.Clear(); 238 pending_requests_.Clear();
239 239
240 // Cancel pending subscriptions. 240 // Cancel pending subscriptions.
241 for (SubscriptionsMap::Iterator<PendingSubscription> 241 for (SubscriptionsMap::Iterator<PendingSubscription>
242 it(&pending_subscriptions_); !it.IsAtEnd(); it.Advance()) { 242 it(&pending_subscriptions_); !it.IsAtEnd(); it.Advance()) {
243 it.GetCurrentValue()->callback.Run(GetPermissionStatusFromType( 243 it.GetCurrentValue()->callback.Run(GetPermissionStatusFromType(
244 it.GetCurrentValue()->permission, it.GetCurrentValue()->origin)); 244 it.GetCurrentValue()->permission, it.GetCurrentValue()->origin));
245 it.GetCurrentValue()->callback.reset(); 245 it.GetCurrentValue()->callback.Reset();
246 permission_manager->UnsubscribePermissionStatusChange( 246 permission_manager->UnsubscribePermissionStatusChange(
247 it.GetCurrentValue()->id); 247 it.GetCurrentValue()->id);
248 } 248 }
249 pending_subscriptions_.Clear(); 249 pending_subscriptions_.Clear();
250 } 250 }
251 251
252 void PermissionServiceImpl::HasPermission( 252 void PermissionServiceImpl::HasPermission(
253 PermissionName permission, 253 PermissionName permission,
254 const mojo::String& origin, 254 const mojo::String& origin,
255 const PermissionStatusCallback& callback) { 255 const PermissionStatusCallback& callback) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 360
361 BrowserContext* browser_context = context_->GetBrowserContext(); 361 BrowserContext* browser_context = context_->GetBrowserContext();
362 DCHECK(browser_context); 362 DCHECK(browser_context);
363 if (browser_context->GetPermissionManager()) { 363 if (browser_context->GetPermissionManager()) {
364 browser_context->GetPermissionManager()->UnsubscribePermissionStatusChange( 364 browser_context->GetPermissionManager()->UnsubscribePermissionStatusChange(
365 subscription->id); 365 subscription->id);
366 } 366 }
367 367
368 PermissionStatusCallback callback = subscription->callback; 368 PermissionStatusCallback callback = subscription->callback;
369 369
370 subscription->callback.reset(); 370 subscription->callback.Reset();
371 pending_subscriptions_.Remove(pending_subscription_id); 371 pending_subscriptions_.Remove(pending_subscription_id);
372 372
373 callback.Run(status); 373 callback.Run(status);
374 } 374 }
375 375
376 } // namespace content 376 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/geolocation/geolocation_service_impl.cc ('k') | content/browser/presentation/presentation_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698