Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/chrome/browser/snapshots/snapshot_cache.h" | 5 #import "ios/chrome/browser/snapshots/snapshot_cache.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include "base/critical_closure.h" | 9 #include "base/critical_closure.h" |
| 10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 if (lruCache_) { | 398 if (lruCache_) { |
| 399 backgroundingColorImage_.reset([[lruCache_ objectForKey:sessionID] retain]); | 399 backgroundingColorImage_.reset([[lruCache_ objectForKey:sessionID] retain]); |
| 400 } else { | 400 } else { |
| 401 backgroundingColorImage_.reset( | 401 backgroundingColorImage_.reset( |
| 402 [[imageDictionary_ objectForKey:sessionID] retain]); | 402 [[imageDictionary_ objectForKey:sessionID] retain]); |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 | 405 |
| 406 - (BOOL)inMemoryCacheIsEnabled { | 406 - (BOOL)inMemoryCacheIsEnabled { |
| 407 // In-memory cache on iPad is enabled only when the tab switcher is enabled. | 407 // In-memory cache on iPad is enabled only when the tab switcher is enabled. |
| 408 return !IsIPadIdiom() || experimental_flags::IsTabSwitcherEnabled(); | 408 return !IsIPadIdiom(); |
|
rohitrao (ping after 24h)
2017/02/01 18:34:34
It looks like the old implementation always return
jif
2017/02/03 12:55:50
It is! Thank you.
Done.
| |
| 409 } | 409 } |
| 410 | 410 |
| 411 - (BOOL)usesLRUCache { | 411 - (BOOL)usesLRUCache { |
| 412 // Always use the LRUCache when the tab switcher is enabled. | 412 // Always use the LRUCache when the tab switcher is enabled. |
| 413 return experimental_flags::IsTabSwitcherEnabled() || | 413 return experimental_flags::IsLRUSnapshotCacheEnabled(); |
|
rohitrao (ping after 24h)
2017/02/01 18:34:34
Same here.
jif
2017/02/03 12:55:51
Done.
| |
| 414 experimental_flags::IsLRUSnapshotCacheEnabled(); | |
| 415 } | 414 } |
| 416 | 415 |
| 417 - (void)handleLowMemory { | 416 - (void)handleLowMemory { |
| 418 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 417 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 419 base::scoped_nsobject<NSMutableDictionary> dictionary( | 418 base::scoped_nsobject<NSMutableDictionary> dictionary( |
| 420 [[NSMutableDictionary alloc] initWithCapacity:2]); | 419 [[NSMutableDictionary alloc] initWithCapacity:2]); |
| 421 for (NSString* sessionID in pinnedIDs_) { | 420 for (NSString* sessionID in pinnedIDs_) { |
| 422 UIImage* image = nil; | 421 UIImage* image = nil; |
| 423 if (lruCache_) | 422 if (lruCache_) |
| 424 image = [lruCache_ objectForKey:sessionID]; | 423 image = [lruCache_ objectForKey:sessionID]; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 | 601 |
| 603 - (BOOL)hasGreyImageInMemory:(NSString*)sessionID { | 602 - (BOOL)hasGreyImageInMemory:(NSString*)sessionID { |
| 604 return [greyImageDictionary_ objectForKey:sessionID] != nil; | 603 return [greyImageDictionary_ objectForKey:sessionID] != nil; |
| 605 } | 604 } |
| 606 | 605 |
| 607 - (NSUInteger)lruCacheMaxSize { | 606 - (NSUInteger)lruCacheMaxSize { |
| 608 return [lruCache_ maxCacheSize]; | 607 return [lruCache_ maxCacheSize]; |
| 609 } | 608 } |
| 610 | 609 |
| 611 @end | 610 @end |
| OLD | NEW |