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

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

Issue 2889553002: Revert of Use TaskScheduler instead of SequencedWorkerPool in snapshot_cache.mm. (Closed)
Patch Set: Created 3 years, 7 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 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_release_properties.h" 16 #include "base/mac/objc_release_properties.h"
17 #include "base/mac/scoped_cftyperef.h" 17 #include "base/mac/scoped_cftyperef.h"
18 #include "base/mac/scoped_nsobject.h" 18 #include "base/mac/scoped_nsobject.h"
19 #include "base/strings/sys_string_conversions.h" 19 #include "base/strings/sys_string_conversions.h"
20 #include "base/task_runner_util.h" 20 #include "base/task_runner_util.h"
21 #include "base/task_scheduler/post_task.h"
22 #include "base/threading/thread_restrictions.h" 21 #include "base/threading/thread_restrictions.h"
23 #include "ios/chrome/browser/experimental_flags.h" 22 #include "ios/chrome/browser/experimental_flags.h"
24 #import "ios/chrome/browser/snapshots/lru_cache.h" 23 #import "ios/chrome/browser/snapshots/lru_cache.h"
25 #import "ios/chrome/browser/snapshots/snapshot_cache_internal.h" 24 #import "ios/chrome/browser/snapshots/snapshot_cache_internal.h"
26 #include "ios/chrome/browser/ui/ui_util.h" 25 #include "ios/chrome/browser/ui/ui_util.h"
27 #import "ios/chrome/browser/ui/uikit_ui_util.h" 26 #import "ios/chrome/browser/ui/uikit_ui_util.h"
28 #include "ios/web/public/web_thread.h" 27 #include "ios/web/public/web_thread.h"
29 28
30 @interface SnapshotCache () 29 @interface SnapshotCache ()
31 // Returns the directory where the thumbnails are saved. 30 // Returns the directory where the thumbnails are saved.
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 FilePathForSessionID(sessionID, [SnapshotCache cacheDirectory]); 564 FilePathForSessionID(sessionID, [SnapshotCache cacheDirectory]);
566 565
567 // The color image may still be in memory. Verify the sessionID matches. 566 // The color image may still be in memory. Verify the sessionID matches.
568 if (backgroundingColorImage_) { 567 if (backgroundingColorImage_) {
569 if (![backgroundingImageSessionId_ isEqualToString:sessionID]) { 568 if (![backgroundingImageSessionId_ isEqualToString:sessionID]) {
570 backgroundingColorImage_.reset(); 569 backgroundingColorImage_.reset();
571 backgroundingImageSessionId_.reset(); 570 backgroundingImageSessionId_.reset();
572 } 571 }
573 } 572 }
574 573
575 base::PostTaskWithTraits( 574 web::WebThread::PostBlockingPoolTask(
576 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, 575 FROM_HERE, base::Bind(&ConvertAndSaveGreyImage, colorImagePath,
577 base::BindOnce(&ConvertAndSaveGreyImage, colorImagePath, greyImagePath, 576 greyImagePath, backgroundingColorImage_));
578 backgroundingColorImage_));
579 } 577 }
580 578
581 @end 579 @end
582 580
583 @implementation SnapshotCache (TestingAdditions) 581 @implementation SnapshotCache (TestingAdditions)
584 582
585 - (BOOL)hasImageInMemory:(NSString*)sessionID { 583 - (BOOL)hasImageInMemory:(NSString*)sessionID {
586 if ([self usesLRUCache]) 584 if ([self usesLRUCache])
587 return [lruCache_ objectForKey:sessionID] != nil; 585 return [lruCache_ objectForKey:sessionID] != nil;
588 else 586 else
589 return [imageDictionary_ objectForKey:sessionID] != nil; 587 return [imageDictionary_ objectForKey:sessionID] != nil;
590 } 588 }
591 589
592 - (BOOL)hasGreyImageInMemory:(NSString*)sessionID { 590 - (BOOL)hasGreyImageInMemory:(NSString*)sessionID {
593 return [greyImageDictionary_ objectForKey:sessionID] != nil; 591 return [greyImageDictionary_ objectForKey:sessionID] != nil;
594 } 592 }
595 593
596 - (NSUInteger)lruCacheMaxSize { 594 - (NSUInteger)lruCacheMaxSize {
597 return [lruCache_ maxCacheSize]; 595 return [lruCache_ maxCacheSize];
598 } 596 }
599 597
600 @end 598 @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