google_apis: Remove PostBlockingPoolSequencedTask () and friends (issue 11363234)

14 views
Skip to first unread message

sat...@chromium.org

unread,
Nov 14, 2012, 1:23:59 AM11/14/12
to hash...@chromium.org, chromium...@chromium.org, nkostyl...@chromium.org, tzik+...@chromium.org, achuit...@chromium.org, oshima...@chromium.org, kinuko...@chromium.org, stevenj...@chromium.org, davemoo...@chromium.org
Reviewers: hashimoto,

Description:
google_apis: Remove PostBlockingPoolSequencedTask () and friends

These were introduced to hide some complexity about WaitableEvent (ugh)
but the complexity was gone long time ago. There is no need to keep
the wrappers.

BUG=158495
TEST=none


Please review this at http://codereview.chromium.org/11363234/

SVN Base: svn://svn.chromium.org/chrome/trunk/src

Affected files:
M chrome/browser/chromeos/drive/drive_feed_loader.cc
M chrome/browser/chromeos/drive/drive_file_system.cc
M chrome/browser/chromeos/drive/file_system/copy_operation.cc
M chrome/browser/google_apis/gdata_util.h
M chrome/browser/google_apis/gdata_util.cc


Index: chrome/browser/chromeos/drive/drive_feed_loader.cc
diff --git a/chrome/browser/chromeos/drive/drive_feed_loader.cc
b/chrome/browser/chromeos/drive/drive_feed_loader.cc
index
2190de996ad3f026677b963568de4b27b8cb917e..751c98330b2d52948b3044a33cdae0581f853ec3
100644
--- a/chrome/browser/chromeos/drive/drive_feed_loader.cc
+++ b/chrome/browser/chromeos/drive/drive_feed_loader.cc
@@ -310,9 +310,8 @@ void DriveFeedLoader::OnGetAccountMetadata(
const FilePath path =
cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_META).Append(
kAccountMetadataFile);
- google_apis::util::PostBlockingPoolSequencedTask(
+ blocking_task_runner_->PostTask(
FROM_HERE,
- blocking_task_runner_,
base::Bind(&SaveFeedOnBlockingPoolForDebugging,
path, base::Passed(&feed_data)));
#endif
@@ -514,9 +513,8 @@ void
DriveFeedLoader::OnGetDocuments(scoped_ptr<LoadFeedParams> params,

scoped_ptr<google_apis::DocumentFeed>* current_feed =
new scoped_ptr<google_apis::DocumentFeed>;
- google_apis::util::PostBlockingPoolSequencedTaskAndReply(
+ blocking_task_runner_->PostTaskAndReply(
FROM_HERE,
- blocking_task_runner_,
base::Bind(&ParseFeedOnBlockingPool,
base::Passed(&data),
current_feed),
@@ -637,9 +635,8 @@ void
DriveFeedLoader::OnGetChangelist(scoped_ptr<LoadFeedParams> params,
std::string file_name =
base::StringPrintf("DEBUG_changelist_%" PRId64 ".json",
params->start_changestamp);
- google_apis::util::PostBlockingPoolSequencedTask(
+ blocking_task_runner_->PostTask(
FROM_HERE,
- blocking_task_runner_,
base::Bind(&SaveFeedOnBlockingPoolForDebugging,
cache_->GetCacheDirectoryPath(
DriveCache::CACHE_TYPE_META).Append(file_name),
@@ -831,9 +828,8 @@ void DriveFeedLoader::SaveFileSystem() {
resource_metadata_->SerializeToString(serialized_proto.get());
resource_metadata_->set_last_serialized(base::Time::Now());
resource_metadata_->set_serialized_size(serialized_proto->size());
- google_apis::util::PostBlockingPoolSequencedTask(
+ blocking_task_runner_->PostTask(
FROM_HERE,
- blocking_task_runner_,
base::Bind(&SaveProtoOnBlockingPool, path,
base::Passed(serialized_proto.Pass())));
}
Index: chrome/browser/chromeos/drive/drive_file_system.cc
diff --git a/chrome/browser/chromeos/drive/drive_file_system.cc
b/chrome/browser/chromeos/drive/drive_file_system.cc
index
958f49f089e2931c817b909fbf7f4bd537549b8b..ae55e18a01a3cc047d99aa81e221404d5234ec28
100644
--- a/chrome/browser/chromeos/drive/drive_file_system.cc
+++ b/chrome/browser/chromeos/drive/drive_file_system.cc
@@ -848,9 +848,9 @@ void DriveFileSystem::GetResolvedFileByPath(
FilePath* temp_file_path = new FilePath;
const std::string mime_type = kMimeTypeJson;
const DriveFileType file_type = HOSTED_DOCUMENT;
- google_apis::util::PostBlockingPoolSequencedTaskAndReplyWithResult(
- FROM_HERE,
+ base::PostTaskAndReplyWithResult(
blocking_task_runner_,
+ FROM_HERE,
base::Bind(&CreateDocumentJsonFileOnBlockingPool,
cache_->GetCacheDirectoryPath(
DriveCache::CACHE_TYPE_TMP_DOCUMENTS),
@@ -1041,9 +1041,9 @@ void DriveFileSystem::CheckForSpaceBeforeDownload(
return;
}

- google_apis::util::PostBlockingPoolSequencedTaskAndReplyWithResult(
- FROM_HERE,
+ base::PostTaskAndReplyWithResult(
blocking_task_runner_,
+ FROM_HERE,
base::Bind(&DriveCache::FreeDiskSpaceOnBlockingPoolIfNeededFor,
base::Unretained(cache_),
file_size),
@@ -1350,9 +1350,9 @@ void DriveFileSystem::OnGetFileCompleteForUpdateFile(
// Gets the size of the cache file. Since the file is locally modified,
the
// file size information stored in DriveEntry is not correct.
int64* file_size = new int64(0);
- google_apis::util::PostBlockingPoolSequencedTaskAndReplyWithResult(
- FROM_HERE,
+ base::PostTaskAndReplyWithResult(
blocking_task_runner_,
+ FROM_HERE,
base::Bind(&file_util::GetFileSize,
cache_file_path,
file_size),
@@ -1736,9 +1736,9 @@ void DriveFileSystem::OnFileDownloaded(
//
// If we don't have enough space, we return PLATFORM_FILE_ERROR_NO_SPACE,
// and try to free up space, even if the file was downloaded
successfully.
- google_apis::util::PostBlockingPoolSequencedTaskAndReplyWithResult(
- FROM_HERE,
+ base::PostTaskAndReplyWithResult(
blocking_task_runner_,
+ FROM_HERE,
base::Bind(&DriveCache::FreeDiskSpaceOnBlockingPoolIfNeededFor,
base::Unretained(cache_),
0),
@@ -1787,9 +1787,8 @@ void DriveFileSystem::OnFileDownloadedAndSpaceChecked(
} else {
// If we don't have enough space, remove the downloaded file, and
// report "no space" error.
- google_apis::util::PostBlockingPoolSequencedTask(
+ blocking_task_runner_->PostTask(
FROM_HERE,
- blocking_task_runner_,
base::Bind(base::IgnoreResult(&file_util::Delete),
downloaded_file_path,
false /* recursive*/));
@@ -2380,9 +2379,9 @@ void
DriveFileSystem::CheckLocalModificationAndRunAfterGetCacheFile(

// If the cache is dirty, obtain the file info from the cache file
itself.
base::PlatformFileInfo* file_info = new base::PlatformFileInfo;
- google_apis::util::PostBlockingPoolSequencedTaskAndReplyWithResult(
- FROM_HERE,
+ base::PostTaskAndReplyWithResult(
blocking_task_runner_,
+ FROM_HERE,
base::Bind(&file_util::GetFileInfo,
local_cache_path,
base::Unretained(file_info)),
Index: chrome/browser/chromeos/drive/file_system/copy_operation.cc
diff --git a/chrome/browser/chromeos/drive/file_system/copy_operation.cc
b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
index
61b91ef6ca1d6f215cab9ee23eccfed2963da897..380f15b8f8d0bced5f0a560d00f172a73b86400e
100644
--- a/chrome/browser/chromeos/drive/file_system/copy_operation.cc
+++ b/chrome/browser/chromeos/drive/file_system/copy_operation.cc
@@ -161,9 +161,9 @@ void CopyOperation::OnGetFileCompleteForTransferFile(
// GetFileByPath downloads the file from Drive to a local cache, which
is then
// copied to the actual destination path on the local file system using
// CopyLocalFileOnBlockingPool.
- google_apis::util::PostBlockingPoolSequencedTaskAndReplyWithResult(
- FROM_HERE,
+ base::PostTaskAndReplyWithResult(
blocking_task_runner_,
+ FROM_HERE,
base::Bind(&CopyLocalFileOnBlockingPool,
local_file_path,
local_dest_file_path),
@@ -196,9 +196,9 @@ void CopyOperation::TransferRegularFile(

int64* file_size = new int64;
std::string* content_type = new std::string;
- google_apis::util::PostBlockingPoolSequencedTaskAndReplyWithResult(
- FROM_HERE,
+ base::PostTaskAndReplyWithResult(
blocking_task_runner_,
+ FROM_HERE,
base::Bind(&GetLocalFileInfoOnBlockingPool,
local_file_path,
file_size,
@@ -523,9 +523,8 @@ void
CopyOperation::TransferFileFromLocalToRemoteAfterGetEntryInfo(
}

std::string* resource_id = new std::string;
- google_apis::util::PostBlockingPoolSequencedTaskAndReply(
+ blocking_task_runner_->PostTaskAndReply(
FROM_HERE,
- blocking_task_runner_,
base::Bind(&GetDocumentResourceIdOnBlockingPool,
local_src_file_path,
resource_id),
Index: chrome/browser/google_apis/gdata_util.cc
diff --git a/chrome/browser/google_apis/gdata_util.cc
b/chrome/browser/google_apis/gdata_util.cc
index
6d306749aa856e02c838686d29e0e62ab107fa41..df35a7284db2e5de5982101c3032e63c1b9fe568
100644
--- a/chrome/browser/google_apis/gdata_util.cc
+++ b/chrome/browser/google_apis/gdata_util.cc
@@ -187,27 +187,5 @@ std::string FormatTimeAsStringLocaltime(const
base::Time& time) {
exploded.hour, exploded.minute, exploded.second,
exploded.millisecond);
}

-void PostBlockingPoolSequencedTask(
- const tracked_objects::Location& from_here,
- base::SequencedTaskRunner* blocking_task_runner,
- const base::Closure& task) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- const bool posted = blocking_task_runner->PostTask(from_here, task);
- DCHECK(posted);
-}
-
-void PostBlockingPoolSequencedTaskAndReply(
- const tracked_objects::Location& from_here,
- base::SequencedTaskRunner* blocking_task_runner,
- const base::Closure& request_task,
- const base::Closure& reply_task) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- const bool posted = blocking_task_runner->PostTaskAndReply(
- from_here, request_task, reply_task);
- DCHECK(posted);
-}
-
} // namespace util
} // namespace google_apis
Index: chrome/browser/google_apis/gdata_util.h
diff --git a/chrome/browser/google_apis/gdata_util.h
b/chrome/browser/google_apis/gdata_util.h
index
7f54b403725ba16524c77bff3154d2f58e058c37..40c35f393ac64572b1f9c55172ad74f1fce43982
100644
--- a/chrome/browser/google_apis/gdata_util.h
+++ b/chrome/browser/google_apis/gdata_util.h
@@ -41,36 +41,6 @@ std::string FormatTimeAsString(const base::Time& time);
// Formats a base::Time as an RFC 3339 date/time (in localtime).
std::string FormatTimeAsStringLocaltime(const base::Time& time);

-// Wrapper around BrowserThread::PostTask to post a task to the blocking
-// pool with the given sequence token.
-void PostBlockingPoolSequencedTask(
- const tracked_objects::Location& from_here,
- base::SequencedTaskRunner* blocking_task_runner,
- const base::Closure& task);
-
-// Similar to PostBlockingPoolSequencedTask() but this one takes a reply
-// callback that runs on the calling thread.
-void PostBlockingPoolSequencedTaskAndReply(
- const tracked_objects::Location& from_here,
- base::SequencedTaskRunner* blocking_task_runner,
- const base::Closure& request_task,
- const base::Closure& reply_task);
-
-// Similar to PostBlockingPoolSequencedTaskAndReply() but this one runs the
-// reply callback with the return value of the request task.
-template <typename ReturnType>
-void PostBlockingPoolSequencedTaskAndReplyWithResult(
- const tracked_objects::Location& from_here,
- base::SequencedTaskRunner* blocking_task_runner,
- const base::Callback<ReturnType(void)>& request_task,
- const base::Callback<void(ReturnType)>& reply_task) {
- const bool posted =
base::PostTaskAndReplyWithResult(blocking_task_runner,
- from_here,
- request_task,
- reply_task);
- DCHECK(posted);
-}
-
} // namespace util
} // namespace google_apis



hash...@chromium.org

unread,
Nov 14, 2012, 1:30:17 AM11/14/12
to sat...@chromium.org, chromium...@chromium.org, nkostyl...@chromium.org, tzik+...@chromium.org, achuit...@chromium.org, oshima...@chromium.org, kinuko...@chromium.org, stevenj...@chromium.org, davemoo...@chromium.org

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h
File chrome/browser/google_apis/gdata_util.h (right):

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode10
chrome/browser/google_apis/gdata_util.h:10: #include
"base/callback_forward.h"
No need to include this.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode11
chrome/browser/google_apis/gdata_util.h:11: #include "base/logging.h"
ditto.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode12
chrome/browser/google_apis/gdata_util.h:12: #include
"base/platform_file.h"
ditto.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode13
chrome/browser/google_apis/gdata_util.h:13: #include
"base/task_runner_util.h"
ditto.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode14
chrome/browser/google_apis/gdata_util.h:14: #include
"chrome/browser/google_apis/gdata_errorcode.h"
ditto.

http://codereview.chromium.org/11363234/

sat...@chromium.org

unread,
Nov 14, 2012, 2:14:30 AM11/14/12
to hash...@chromium.org, chromium...@chromium.org, nkostyl...@chromium.org, tzik+...@chromium.org, achuit...@chromium.org, oshima...@chromium.org, kinuko...@chromium.org, stevenj...@chromium.org, davemoo...@chromium.org
http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode9
chrome/browser/google_apis/gdata_util.h:9:
added "base/string_piece.h". StringPiece cannot be forward-declared.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode10
chrome/browser/google_apis/gdata_util.h:10: #include
"base/callback_forward.h"
On 2012/11/14 06:30:18, hashimoto wrote:
> No need to include this.

Done.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode11
chrome/browser/google_apis/gdata_util.h:11: #include "base/logging.h"
On 2012/11/14 06:30:18, hashimoto wrote:
> ditto.

Done.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode12
chrome/browser/google_apis/gdata_util.h:12: #include
"base/platform_file.h"
On 2012/11/14 06:30:18, hashimoto wrote:
> ditto.

Done.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode13
chrome/browser/google_apis/gdata_util.h:13: #include
"base/task_runner_util.h"
On 2012/11/14 06:30:18, hashimoto wrote:
> ditto.

Done.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode14
chrome/browser/google_apis/gdata_util.h:14: #include
"chrome/browser/google_apis/gdata_errorcode.h"
On 2012/11/14 06:30:18, hashimoto wrote:
> ditto.

Done.

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode20
chrome/browser/google_apis/gdata_util.h:20: class SequencedTaskRunner;
removed

http://codereview.chromium.org/11363234/diff/4001/chrome/browser/google_apis/gdata_util.h#newcode26
chrome/browser/google_apis/gdata_util.h:26: } // tracked_objects
removed.

http://codereview.chromium.org/11363234/

hash...@chromium.org

unread,
Nov 14, 2012, 2:21:49 AM11/14/12
to sat...@chromium.org, chromium...@chromium.org, nkostyl...@chromium.org, tzik+...@chromium.org, achuit...@chromium.org, oshima...@chromium.org, kinuko...@chromium.org, stevenj...@chromium.org, davemoo...@chromium.org
Reply all
Reply to author
Forward
0 new messages