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

Side by Side Diff: ios/chrome/browser/snapshots/snapshot_cache.mm

Issue 2561133002: Moves include of objc_property_releaser out of a header. (Closed)
Patch Set: fix_compile Created 4 years 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 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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/mac/bind_objc_block.h" 15 #include "base/mac/bind_objc_block.h"
16 #include "base/mac/objc_property_releaser.h"
16 #include "base/mac/scoped_cftyperef.h" 17 #include "base/mac/scoped_cftyperef.h"
18 #include "base/mac/scoped_nsobject.h"
17 #include "base/strings/sys_string_conversions.h" 19 #include "base/strings/sys_string_conversions.h"
18 #include "base/task_runner_util.h" 20 #include "base/task_runner_util.h"
19 #include "base/threading/thread_restrictions.h" 21 #include "base/threading/thread_restrictions.h"
20 #include "ios/chrome/browser/experimental_flags.h" 22 #include "ios/chrome/browser/experimental_flags.h"
23 #import "ios/chrome/browser/snapshots/lru_cache.h"
21 #import "ios/chrome/browser/snapshots/snapshot_cache_internal.h" 24 #import "ios/chrome/browser/snapshots/snapshot_cache_internal.h"
22 #include "ios/chrome/browser/ui/ui_util.h" 25 #include "ios/chrome/browser/ui/ui_util.h"
23 #import "ios/chrome/browser/ui/uikit_ui_util.h" 26 #import "ios/chrome/browser/ui/uikit_ui_util.h"
24 #include "ios/web/public/web_thread.h" 27 #include "ios/web/public/web_thread.h"
25 28
26 @interface SnapshotCache () 29 @interface SnapshotCache ()
27 // Returns the directory where the thumbnails are saved. 30 // Returns the directory where the thumbnails are saved.
28 + (base::FilePath)cacheDirectory; 31 + (base::FilePath)cacheDirectory;
29 // Returns the directory where the thumbnails were stored in M28 and earlier. 32 // Returns the directory where the thumbnails were stored in M28 and earlier.
30 - (base::FilePath)oldCacheDirectory; 33 - (base::FilePath)oldCacheDirectory;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if (!colorImage) 125 if (!colorImage)
123 colorImage.reset([ReadImageFromDisk(colorPath) retain]); 126 colorImage.reset([ReadImageFromDisk(colorPath) retain]);
124 if (!colorImage) 127 if (!colorImage)
125 return; 128 return;
126 base::scoped_nsobject<UIImage> greyImage([GreyImage(colorImage) retain]); 129 base::scoped_nsobject<UIImage> greyImage([GreyImage(colorImage) retain]);
127 WriteImageToDisk(greyImage, greyPath); 130 WriteImageToDisk(greyImage, greyPath);
128 } 131 }
129 132
130 } // anonymous namespace 133 } // anonymous namespace
131 134
132 @implementation SnapshotCache 135 @implementation SnapshotCache {
136 // Dictionary to hold color snapshots in memory. n.b. Color snapshots are not
137 // kept in memory on tablets.
138 base::scoped_nsobject<NSMutableDictionary> imageDictionary_;
139
140 // Cache to hold color snapshots in memory. n.b. Color snapshots are not
141 // kept in memory on tablets. It is used in place of the imageDictionary_ when
142 // the LRU cache snapshot experiment is enabled.
143 base::scoped_nsobject<LRUCache> lruCache_;
144
145 // Temporary dictionary to hold grey snapshots for tablet side swipe. This
146 // will be nil before -createGreyCache is called and after -removeGreyCache
147 // is called.
148 base::scoped_nsobject<NSMutableDictionary> greyImageDictionary_;
149 NSSet* pinnedIDs_;
150
151 // Session ID of most recent pending grey snapshot request.
152 base::scoped_nsobject<NSString> mostRecentGreySessionId_;
153 // Block used by pending request for a grey snapshot.
154 base::scoped_nsprotocol<GreyBlock> mostRecentGreyBlock_;
155
156 // Session ID and correspoinding UIImage for the snapshot that will likely
157 // be requested to be saved to disk when the application is backgrounded.
158 base::scoped_nsobject<NSString> backgroundingImageSessionId_;
159 base::scoped_nsobject<UIImage> backgroundingColorImage_;
160
161 base::mac::ObjCPropertyReleaser propertyReleaser_SnapshotCache_;
162 }
133 163
134 @synthesize pinnedIDs = pinnedIDs_; 164 @synthesize pinnedIDs = pinnedIDs_;
135 165
136 + (SnapshotCache*)sharedInstance { 166 + (SnapshotCache*)sharedInstance {
137 static SnapshotCache* instance = [[SnapshotCache alloc] init]; 167 static SnapshotCache* instance = [[SnapshotCache alloc] init];
138 return instance; 168 return instance;
139 } 169 }
140 170
141 - (id)init { 171 - (id)init {
142 if ((self = [super init])) { 172 if ((self = [super init])) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 602
573 - (BOOL)hasGreyImageInMemory:(NSString*)sessionID { 603 - (BOOL)hasGreyImageInMemory:(NSString*)sessionID {
574 return [greyImageDictionary_ objectForKey:sessionID] != nil; 604 return [greyImageDictionary_ objectForKey:sessionID] != nil;
575 } 605 }
576 606
577 - (NSUInteger)lruCacheMaxSize { 607 - (NSUInteger)lruCacheMaxSize {
578 return [lruCache_ maxCacheSize]; 608 return [lruCache_ maxCacheSize];
579 } 609 }
580 610
581 @end 611 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/snapshots/snapshot_cache.h ('k') | ios/chrome/browser/snapshots/snapshot_cache_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698