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

Side by Side Diff: chrome/browser/permissions/permission_manager.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Fix typo breaking a bunch of trybot builds, oops Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/permissions/permission_manager.h" 5 #include "chrome/browser/permissions/permission_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 293 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
294 if (permissions.empty()) { 294 if (permissions.empty()) {
295 callback.Run(std::vector<PermissionStatus>()); 295 callback.Run(std::vector<PermissionStatus>());
296 return kNoPendingOperation; 296 return kNoPendingOperation;
297 } 297 }
298 298
299 content::WebContents* web_contents = 299 content::WebContents* web_contents =
300 content::WebContents::FromRenderFrameHost(render_frame_host); 300 content::WebContents::FromRenderFrameHost(render_frame_host);
301 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); 301 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin();
302 302
303 PendingRequest* pending_request = new PendingRequest( 303 int request_id = pending_requests_.Add(
304 render_frame_host, permissions, callback); 304 base::MakeUnique<PendingRequest>(
305 int request_id = pending_requests_.Add(pending_request); 305 render_frame_host, permissions, callback));
306 306
307 const PermissionRequestID request(render_frame_host, request_id); 307 const PermissionRequestID request(render_frame_host, request_id);
308 308
309 for (size_t i = 0; i < permissions.size(); ++i) { 309 for (size_t i = 0; i < permissions.size(); ++i) {
310 const PermissionType permission = permissions[i]; 310 const PermissionType permission = permissions[i];
311 311
312 if (IsConstantPermission(permission) || 312 if (IsConstantPermission(permission) ||
313 !GetPermissionContext(permission)) { 313 !GetPermissionContext(permission)) {
314 // Track permission request usages even for constant permissions. 314 // Track permission request usages even for constant permissions.
315 PermissionUmaUtil::PermissionRequested(permission, requesting_origin, 315 PermissionUmaUtil::PermissionRequested(permission, requesting_origin,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 if (IsConstantPermission(permission)) { 437 if (IsConstantPermission(permission)) {
438 subscription->current_value = GetContentSettingForConstantPermission( 438 subscription->current_value = GetContentSettingForConstantPermission(
439 permission); 439 permission);
440 } else { 440 } else {
441 subscription->current_value = 441 subscription->current_value =
442 GetPermissionContext(permission) 442 GetPermissionContext(permission)
443 ->GetPermissionStatus(subscription->requesting_origin, 443 ->GetPermissionStatus(subscription->requesting_origin,
444 subscription->embedding_origin); 444 subscription->embedding_origin);
445 } 445 }
446 446
447 return subscriptions_.Add(subscription); 447 return subscriptions_.Add(std::unique_ptr<Subscription>(subscription));
danakj 2016/11/18 00:15:32 make the var a unique_ptr?
448 } 448 }
449 449
450 void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) { 450 void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) {
451 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 451 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
452 // Whether |subscription_id| is known will be checked by the Remove() call. 452 // Whether |subscription_id| is known will be checked by the Remove() call.
453 subscriptions_.Remove(subscription_id); 453 subscriptions_.Remove(subscription_id);
454 454
455 if (subscriptions_.IsEmpty()) 455 if (subscriptions_.IsEmpty())
456 HostContentSettingsMapFactory::GetForProfile(profile_) 456 HostContentSettingsMapFactory::GetForProfile(profile_)
457 ->RemoveObserver(this); 457 ->RemoveObserver(this);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // Add the callback to |callbacks| which will be run after the loop to 494 // Add the callback to |callbacks| which will be run after the loop to
495 // prevent re-entrance issues. 495 // prevent re-entrance issues.
496 callbacks.push_back( 496 callbacks.push_back(
497 base::Bind(subscription->callback, 497 base::Bind(subscription->callback,
498 ContentSettingToPermissionStatus(new_value))); 498 ContentSettingToPermissionStatus(new_value)));
499 } 499 }
500 500
501 for (const auto& callback : callbacks) 501 for (const auto& callback : callbacks)
502 callback.Run(); 502 callback.Run();
503 } 503 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698