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

Side by Side Diff: ios/chrome/browser/tabs/web_state_list.mm

Issue 2640093004: WebStateList is an array of web::WebState* wrappers. (Closed)
Patch Set: Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/tabs/web_state_list.h"
6
7 #if !defined(__has_feature) || !__has_feature(objc_arc)
8 #error "This file requires ARC support."
9 #endif
10
11 @implementation WebStateList {
12 NSMutableArray<id<WebStateHandle>>* _list;
13 }
14
15 #pragma mark - Lifecycle
16
17 - (instancetype)init {
18 if ((self = [super init])) {
19 _list = [[NSMutableArray alloc] init];
20 }
21 return self;
22 }
23
24 #pragma mark - NSFastEnumeration
25
26 - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState*)state
27 objects:(id __unsafe_unretained*)buffer
28 count:(NSUInteger)len {
29 return [_list countByEnumeratingWithState:state objects:buffer count:len];
30 }
31
32 #pragma mark - Properties
33
34 - (NSUInteger)count {
35 return [_list count];
marq (ping after 24h) 2017/01/19 13:37:46 nit: _list.count
sdefresne 2017/01/20 14:42:09 Done.
36 }
37
38 - (id<WebStateHandle>)firstWebState {
39 return [_list firstObject];
marq (ping after 24h) 2017/01/19 13:37:46 nit: _list.firstObject
sdefresne 2017/01/20 14:42:09 Done.
40 }
41
42 #pragma mark - Public methods, mutation
43
44 - (void)addWebState:(id<WebStateHandle>)webState {
45 [_list addObject:webState];
46 }
47
48 - (void)insertWebState:(id<WebStateHandle>)webState atIndex:(NSUInteger)index {
49 [_list insertObject:webState atIndex:index];
50 }
51
52 - (void)replaceWebStateAtIndex:(NSUInteger)index
53 withWebState:(id<WebStateHandle>)webState {
54 [_list replaceObjectAtIndex:index withObject:webState];
55 }
56
57 - (void)removeWebState:(id<WebStateHandle>)webState {
58 [_list removeObject:webState];
59 }
60
61 #pragma mark - Public methods, queries
62
63 - (BOOL)containsWebState:(id<WebStateHandle>)webSate {
64 return [_list containsObject:webSate];
65 }
66
67 - (id<WebStateHandle>)webStateAtIndex:(NSUInteger)index {
marq (ping after 24h) 2017/01/19 14:35:11 Do we want to guard against range exceptions by re
sdefresne 2017/01/20 14:42:09 I've added a DCHECK, WDYT?
marq (ping after 24h) 2017/01/20 14:49:17 Doesn't that just trade one exception for another?
68 return [_list objectAtIndex:index];
69 }
70
71 - (NSUInteger)indexOfWebState:(id<WebStateHandle>)webState {
72 return [_list indexOfObject:webState];
73 }
74
75 #pragma mark - Public methods, deprecated
76
77 - (NSArray*)allWebStates {
78 return [_list copy];
79 }
80
81 @end
OLDNEW
« ios/chrome/browser/tabs/web_state_list.h ('K') | « ios/chrome/browser/tabs/web_state_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698