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

Side by Side Diff: ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.mm

Issue 2922573002: [iOS Clean] Ignore compiler warnings for |-performSelector:withObject:|. (Closed)
Patch Set: added comment Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.h " 5 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.h "
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context.h" 8 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context.h"
9 9
10 #if !defined(__has_feature) || !__has_feature(objc_arc) 10 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support." 11 #error "This file requires ARC support."
12 #endif 12 #endif
13 13
14 namespace { 14 namespace {
15 // Typedef the block parameter for UIAlertAction for readability. 15 // Typedef the block parameter for UIAlertAction for readability.
16 typedef void (^AlertActionHandler)(UIAlertAction*); 16 typedef void (^AlertActionHandler)(UIAlertAction*);
17 // Sends |commands| to |dispatcher| using |context| as the menu context. 17 // Sends |commands| to |dispatcher| using |context| as the menu context.
18 void DispatchContextMenuCommands(const std::vector<SEL>& commands, 18 void DispatchContextMenuCommands(const std::vector<SEL>& commands,
19 id dispatcher, 19 id dispatcher,
20 ContextMenuContext* context) { 20 ContextMenuContext* context) {
21 DCHECK(dispatcher); 21 DCHECK(dispatcher);
22 DCHECK(context); 22 DCHECK(context);
23 // |-performSelector:withObject:| throws a warning in ARC because the compiler
24 // doesn't know how to handle the memory management of the returned values.
25 // Since all ContextMenuCommands return void, these warning can be ignored
26 // here.
27 #pragma clang diagnostic push
28 #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
23 for (SEL command : commands) { 29 for (SEL command : commands) {
24 IMP command_imp = [dispatcher methodForSelector:command]; 30 [dispatcher performSelector:command withObject:context];
25 DCHECK(command_imp);
26 command_imp(dispatcher, command, context);
27 } 31 }
32 #pragma clang diagnostic pop
28 } 33 }
29 } 34 }
30 35
31 @interface ContextMenuViewController () 36 @interface ContextMenuViewController ()
32 // The dispatcher passed on initialization. 37 // The dispatcher passed on initialization.
33 @property(nonatomic, readonly, weak) id<ContextMenuCommands> dispatcher; 38 @property(nonatomic, readonly, weak) id<ContextMenuCommands> dispatcher;
34 // The context passed on initialization. 39 // The context passed on initialization.
35 @property(nonatomic, strong) ContextMenuContext* context; 40 @property(nonatomic, strong) ContextMenuContext* context;
36 41
37 // Creates an UIAlertAction for |item| using |style| to manage the action's 42 // Creates an UIAlertAction for |item| using |style| to manage the action's
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 style:(UIAlertActionStyle)style { 90 style:(UIAlertActionStyle)style {
86 DCHECK(item); 91 DCHECK(item);
87 // Create a block that dispatches |item|'s ContextMenuCommands. 92 // Create a block that dispatches |item|'s ContextMenuCommands.
88 AlertActionHandler handler = ^(UIAlertAction* action) { 93 AlertActionHandler handler = ^(UIAlertAction* action) {
89 DispatchContextMenuCommands(item.commands, self.dispatcher, self.context); 94 DispatchContextMenuCommands(item.commands, self.dispatcher, self.context);
90 }; 95 };
91 return [UIAlertAction actionWithTitle:item.title style:style handler:handler]; 96 return [UIAlertAction actionWithTitle:item.title style:style handler:handler];
92 } 97 }
93 98
94 @end 99 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698