Skip to content

Commit

Permalink
Use TaskScheduler instead of SequencedWorkerPool in session_service_i…
Browse files Browse the repository at this point in the history
…os.mm.

SequencedWorkerPool is being deprecated in favor of TaskScheduler.

BUG=667892
R=rohitrao@chromium.org

Review-Url: https://codereview.chromium.org/2878953002
Cr-Commit-Position: refs/heads/master@{#472064}
  • Loading branch information
fdoray authored and Commit bot committed May 16, 2017
1 parent 128f4de commit 3b7bbde
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions ios/chrome/browser/sessions/session_service_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#import <UIKit/UIKit.h>

#include "base/critical_closure.h"
#include "base/files/file_path.h"
#include "base/format_macros.h"
#include "base/location.h"
Expand All @@ -16,14 +15,13 @@
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
#include "base/strings/sys_string_conversions.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_restrictions.h"
#import "ios/chrome/browser/sessions/session_ios.h"
#import "ios/chrome/browser/sessions/session_window_ios.h"
#import "ios/web/public/crw_navigation_item_storage.h"
#import "ios/web/public/crw_session_certificate_policy_cache_storage.h"
#import "ios/web/public/crw_session_storage.h"
#include "ios/web/public/web_thread.h"

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
Expand Down Expand Up @@ -82,9 +80,10 @@ @implementation SessionServiceIOS {
#pragma mark - NSObject overrides

- (instancetype)init {
base::SequencedWorkerPool* pool = web::WebThread::GetBlockingPool();
scoped_refptr<base::SequencedTaskRunner> taskRunner =
pool->GetSequencedTaskRunner(pool->GetSequenceToken());
base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
return [self initWithTaskRunner:taskRunner];
}

Expand Down Expand Up @@ -200,10 +199,10 @@ - (void)performSaveToPathInBackground:(NSString*)sessionPath {

@try {
NSData* sessionData = [NSKeyedArchiver archivedDataWithRootObject:session];
_taskRunner->PostTask(
FROM_HERE, base::MakeCriticalClosure(base::BindBlockArc(^{
[self performSaveSessionData:sessionData sessionPath:sessionPath];
})));
_taskRunner->PostTask(FROM_HERE, base::BindBlockArc(^{
[self performSaveSessionData:sessionData
sessionPath:sessionPath];
}));
} @catch (NSException* exception) {
NOTREACHED() << "Error serializing session for path: "
<< base::SysNSStringToUTF8(sessionPath) << ": "
Expand Down

0 comments on commit 3b7bbde

Please sign in to comment.