Commit a3104df1 authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[TaskScheduler]: Use ScopedBlockingCall to mark blocking tasks.

This CL uses ScopedBlockingCall to mark blocking calls in /ios/chrome/browser/ui.

This CL was created by replacing calls to AssertBlockingAllowed()
with instantiations of ScopedBlockingCall(MAY_BLOCK).
I kindly ask the reviewer to make sure of the following:
  - ScopedBlockingCall is instantiated in a scope with minimal CPU usage.
    If this is not the case, ScopedBlockingCall should be instantiated
    closer to the blocking call. See scoped_blocking_call.h for more
    info. Please let me know when/where the blocking call happens if this needs
    to be changed.
  - Parameter |blocking_type| matches expectation (MAY_BLOCK/WILL_BLOCK). See
    BlockingType for more info. While I assumed MAY_BLOCK by default, that might
    not be the best fit if we know that this callsite is guaranteed to block.
  - The ScopedBlockingCall's scope covers the entirety of the blocking operation
    previously asserted against by the AssertBlockingAllowed().

This CL was uploaded by git cl split.

R=marq@chromium.org

Bug: 874080
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I519b492dc31621ebc2f85fb7952a48e286e21d9f
Reviewed-on: https://chromium-review.googlesource.com/1191532Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587550}
parent a0f906c1
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/scoped_blocking_call.h"
#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/web/public/web_view_creation_util.h" #import "ios/web/public/web_view_creation_util.h"
...@@ -80,7 +80,7 @@ const CFTimeInterval kSecondsPerDay = 60 * 60 * 24; ...@@ -80,7 +80,7 @@ const CFTimeInterval kSecondsPerDay = 60 * 60 * 24;
+ (void)removeFilesExcluding:(NSSet*)filesToKeep + (void)removeFilesExcluding:(NSSet*)filesToKeep
olderThan:(NSInteger)ageInDays { olderThan:(NSInteger)ageInDays {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::WILL_BLOCK);
NSFileManager* fileManager = [NSFileManager defaultManager]; NSFileManager* fileManager = [NSFileManager defaultManager];
NSString* inboxDirectory = [ExternalFileController inboxDirectoryPath]; NSString* inboxDirectory = [ExternalFileController inboxDirectoryPath];
NSArray* externalFiles = NSArray* externalFiles =
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/scoped_blocking_call.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
#import "ios/chrome/browser/ui/open_in_controller_testing.h" #import "ios/chrome/browser/ui/open_in_controller_testing.h"
...@@ -510,7 +510,7 @@ class OpenInControllerBridge ...@@ -510,7 +510,7 @@ class OpenInControllerBridge
#pragma mark File management #pragma mark File management
- (void)removeDocumentAtPath:(NSString*)path { - (void)removeDocumentAtPath:(NSString*)path {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::WILL_BLOCK);
NSFileManager* fileManager = [NSFileManager defaultManager]; NSFileManager* fileManager = [NSFileManager defaultManager];
NSError* error = nil; NSError* error = nil;
if (![fileManager removeItemAtPath:path error:&error]) { if (![fileManager removeItemAtPath:path error:&error]) {
...@@ -520,7 +520,7 @@ class OpenInControllerBridge ...@@ -520,7 +520,7 @@ class OpenInControllerBridge
} }
+ (void)removeAllStoredDocumentsAtPath:(NSString*)tempDirPath { + (void)removeAllStoredDocumentsAtPath:(NSString*)tempDirPath {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::WILL_BLOCK);
NSFileManager* fileManager = [NSFileManager defaultManager]; NSFileManager* fileManager = [NSFileManager defaultManager];
NSError* error = nil; NSError* error = nil;
NSArray* documentFiles = NSArray* documentFiles =
...@@ -541,7 +541,7 @@ class OpenInControllerBridge ...@@ -541,7 +541,7 @@ class OpenInControllerBridge
} }
+ (BOOL)createDestinationDirectoryAndRemoveObsoleteFiles { + (BOOL)createDestinationDirectoryAndRemoveObsoleteFiles {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::WILL_BLOCK);
NSString* tempDirPath = [NSTemporaryDirectory() NSString* tempDirPath = [NSTemporaryDirectory()
stringByAppendingPathComponent:kDocumentsTempPath]; stringByAppendingPathComponent:kDocumentsTempPath];
NSFileManager* fileManager = [NSFileManager defaultManager]; NSFileManager* fileManager = [NSFileManager defaultManager];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment