Commit eb65c1f7 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 /chrome/browser/sync_file_system.

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=tzik@chromium.org

Bug: 874080
Change-Id: I12d0e731ef9d052129bec273df61cf1ccd670568
Reviewed-on: https://chromium-review.googlesource.com/1191194Reviewed-by: default avatarTaiju Tsuiki <tzik@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587551}
parent a3104df1
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/scoped_blocking_call.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
#include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
...@@ -155,7 +155,7 @@ bool RemovePrefix(const std::string& str, const std::string& prefix, ...@@ -155,7 +155,7 @@ bool RemovePrefix(const std::string& str, const std::string& prefix,
} }
std::unique_ptr<ServiceMetadata> InitializeServiceMetadata(LevelDBWrapper* db) { std::unique_ptr<ServiceMetadata> InitializeServiceMetadata(LevelDBWrapper* db) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
DCHECK(db); DCHECK(db);
std::unique_ptr<ServiceMetadata> service_metadata; std::unique_ptr<ServiceMetadata> service_metadata;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h"
...@@ -208,7 +208,7 @@ SyncStatusCode OpenDatabase(const base::FilePath& path, ...@@ -208,7 +208,7 @@ SyncStatusCode OpenDatabase(const base::FilePath& path,
leveldb::Env* env_override, leveldb::Env* env_override,
std::unique_ptr<LevelDBWrapper>* db_out, std::unique_ptr<LevelDBWrapper>* db_out,
bool* created) { bool* created) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
DCHECK(db_out); DCHECK(db_out);
DCHECK(created); DCHECK(created);
DCHECK(path.IsAbsolute()); DCHECK(path.IsAbsolute());
...@@ -237,7 +237,7 @@ SyncStatusCode OpenDatabase(const base::FilePath& path, ...@@ -237,7 +237,7 @@ SyncStatusCode OpenDatabase(const base::FilePath& path,
SyncStatusCode MigrateDatabaseIfNeeded(LevelDBWrapper* db) { SyncStatusCode MigrateDatabaseIfNeeded(LevelDBWrapper* db) {
// See metadata_database_index.cc for the database schema. // See metadata_database_index.cc for the database schema.
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
DCHECK(db); DCHECK(db);
std::string value; std::string value;
leveldb::Status status = db->Get(kDatabaseVersionKey, &value); leveldb::Status status = db->Get(kDatabaseVersionKey, &value);
......
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