OLD | NEW |
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 #import "ios/web/public/crw_browsing_data_store.h" | 5 #import "ios/web/public/crw_browsing_data_store.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 } | 143 } |
144 | 144 |
145 #pragma mark - | 145 #pragma mark - |
146 #pragma mark NSObject Methods | 146 #pragma mark NSObject Methods |
147 | 147 |
148 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState { | 148 - (instancetype)initWithBrowserState:(web::BrowserState*)browserState { |
149 self = [super init]; | 149 self = [super init]; |
150 if (self) { | 150 if (self) { |
151 DCHECK([NSThread isMainThread]); | 151 DCHECK([NSThread isMainThread]); |
152 DCHECK(browserState); | 152 DCHECK(browserState); |
153 // TODO(shreyasv): Instantiate the necessary CRWBrowsingDataManagers that | |
154 // are encapsulated within this class. crbug.com/480654. | |
155 _browserState = browserState; | 153 _browserState = browserState; |
156 web::ActiveStateManager* activeStateManager = | 154 web::ActiveStateManager* activeStateManager = |
157 web::BrowserState::GetActiveStateManager(browserState); | 155 web::BrowserState::GetActiveStateManager(browserState); |
158 DCHECK(activeStateManager); | 156 DCHECK(activeStateManager); |
159 _mode = activeStateManager->IsActive() ? web::ACTIVE : web::INACTIVE; | 157 _mode = activeStateManager->IsActive() ? web::ACTIVE : web::INACTIVE; |
160 // TODO(shreyasv): If the creation of CRWBrowsingDataManagers turns out to | |
161 // be an expensive operations re-visit this with a lazy-evaluation approach. | |
162 base::scoped_nsobject<CRWCookieBrowsingDataManager> | 158 base::scoped_nsobject<CRWCookieBrowsingDataManager> |
163 cookieBrowsingDataManager([[CRWCookieBrowsingDataManager alloc] | 159 cookieBrowsingDataManager([[CRWCookieBrowsingDataManager alloc] |
164 initWithBrowserState:browserState]); | 160 initWithBrowserState:browserState]); |
165 _browsingDataTypeMap.reset([@{ | 161 _browsingDataTypeMap.reset([@{ |
166 @(web::BROWSING_DATA_TYPE_COOKIES) : cookieBrowsingDataManager, | 162 @(web::BROWSING_DATA_TYPE_COOKIES) : cookieBrowsingDataManager, |
167 } retain]); | 163 } retain]); |
168 } | 164 } |
169 return self; | 165 return self; |
170 } | 166 } |
171 | 167 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 226 } |
231 return ![_lastDispatchedOperation isFinished]; | 227 return ![_lastDispatchedOperation isFinished]; |
232 } | 228 } |
233 | 229 |
234 #pragma mark - | 230 #pragma mark - |
235 #pragma mark Public Methods | 231 #pragma mark Public Methods |
236 | 232 |
237 - (void)makeActiveWithCompletionHandler: | 233 - (void)makeActiveWithCompletionHandler: |
238 (void (^)(BOOL success))completionHandler { | 234 (void (^)(BOOL success))completionHandler { |
239 DCHECK([NSThread isMainThread]); | 235 DCHECK([NSThread isMainThread]); |
240 // TODO(shreyasv): Verify the preconditions for this method when | |
241 // web::WebViewCounter class is implemented. crbug.com/480507. | |
242 | 236 |
243 [self changeMode:web::ACTIVE completionHandler:completionHandler]; | 237 [self changeMode:web::ACTIVE completionHandler:completionHandler]; |
244 } | 238 } |
245 | 239 |
246 - (void)makeInactiveWithCompletionHandler: | 240 - (void)makeInactiveWithCompletionHandler: |
247 (void (^)(BOOL success))completionHandler { | 241 (void (^)(BOOL success))completionHandler { |
248 DCHECK([NSThread isMainThread]); | 242 DCHECK([NSThread isMainThread]); |
249 // TODO(shreyasv): Verify the preconditions for this method when | |
250 // web::WebViewCounter class is implemented. crbug.com/480507. | |
251 | 243 |
252 [self changeMode:web::INACTIVE completionHandler:completionHandler]; | 244 [self changeMode:web::INACTIVE completionHandler:completionHandler]; |
253 } | 245 } |
254 | 246 |
255 - (void)removeDataOfTypes:(web::BrowsingDataTypes)browsingDataTypes | 247 - (void)removeDataOfTypes:(web::BrowsingDataTypes)browsingDataTypes |
256 completionHandler:(ProceduralBlock)completionHandler { | 248 completionHandler:(ProceduralBlock)completionHandler { |
257 DCHECK([NSThread isMainThread]); | 249 DCHECK([NSThread isMainThread]); |
258 // TODO(shreyasv): Verify the preconditions for this method when | |
259 // web::WebViewCounter class is implemented. crbug.com/480507. | |
260 | 250 |
261 NSArray* browsingDataManagers = | 251 NSArray* browsingDataManagers = |
262 [self browsingDataManagersForBrowsingDataTypes:browsingDataTypes]; | 252 [self browsingDataManagersForBrowsingDataTypes:browsingDataTypes]; |
263 [self performOperationWithType:REMOVE | 253 [self performOperationWithType:REMOVE |
264 browsingDataManagers:browsingDataManagers | 254 browsingDataManagers:browsingDataManagers |
265 completionHandler:completionHandler]; | 255 completionHandler:completionHandler]; |
266 } | 256 } |
267 | 257 |
268 #pragma mark - | 258 #pragma mark - |
269 #pragma mark Private Properties | 259 #pragma mark Private Properties |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 DCHECK(queue); | 517 DCHECK(queue); |
528 | 518 |
529 if (_lastDispatchedOperation) { | 519 if (_lastDispatchedOperation) { |
530 [operation addDependency:_lastDispatchedOperation]; | 520 [operation addDependency:_lastDispatchedOperation]; |
531 } | 521 } |
532 _lastDispatchedOperation.reset([operation retain]); | 522 _lastDispatchedOperation.reset([operation retain]); |
533 [queue addOperation:operation]; | 523 [queue addOperation:operation]; |
534 } | 524 } |
535 | 525 |
536 @end | 526 @end |
OLD | NEW |