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

Unified Diff: base/sequenced_task_runner_helpers.h

Issue 2686033002: Simplify SequencedTaskRunner::{Delete,Releaose}Soon impl (Closed)
Patch Set: public -> private Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/sequenced_task_runner.cc ('k') | content/browser/browser_child_process_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sequenced_task_runner_helpers.h
diff --git a/base/sequenced_task_runner_helpers.h b/base/sequenced_task_runner_helpers.h
index 7980b46b6ceab1c12d43e735a49ec6d6f1f7ba21..18ec0e26f5d6dfb979a1a095f32b7f66491dd0d1 100644
--- a/base/sequenced_task_runner_helpers.h
+++ b/base/sequenced_task_runner_helpers.h
@@ -5,23 +5,9 @@
#ifndef BASE_SEQUENCED_TASK_RUNNER_HELPERS_H_
#define BASE_SEQUENCED_TASK_RUNNER_HELPERS_H_
-#include "base/debug/alias.h"
-#include "base/macros.h"
-
-// TODO(akalin): Investigate whether it's possible to just have
-// SequencedTaskRunner use these helpers (instead of MessageLoop).
-// Then we can just move these to sequenced_task_runner.h.
-
-namespace tracked_objects {
-class Location;
-}
-
namespace base {
-namespace subtle {
-template <class T, class R> class DeleteHelperInternal;
-template <class T, class R> class ReleaseHelperInternal;
-}
+class SequencedTaskRunner;
// Template helpers which use function indirection to erase T from the
// function signature while still remembering it so we can call the
@@ -34,80 +20,23 @@ template <class T, class R> class ReleaseHelperInternal;
template <class T>
class DeleteHelper {
private:
- template <class T2, class R> friend class subtle::DeleteHelperInternal;
-
static void DoDelete(const void* object) {
- delete reinterpret_cast<const T*>(object);
+ delete static_cast<const T*>(object);
}
- DISALLOW_COPY_AND_ASSIGN(DeleteHelper);
+ friend class SequencedTaskRunner;
};
template <class T>
class ReleaseHelper {
private:
- template <class T2, class R> friend class subtle::ReleaseHelperInternal;
-
static void DoRelease(const void* object) {
- reinterpret_cast<const T*>(object)->Release();
+ static_cast<const T*>(object)->Release();
}
- DISALLOW_COPY_AND_ASSIGN(ReleaseHelper);
+ friend class SequencedTaskRunner;
};
-namespace subtle {
-
-// An internal SequencedTaskRunner-like class helper for DeleteHelper
-// and ReleaseHelper. We don't want to expose the Do*() functions
-// directly directly since the void* argument makes it possible to
-// pass/ an object of the wrong type to delete. Instead, we force
-// callers to go through these internal helpers for type
-// safety. SequencedTaskRunner-like classes which expose DeleteSoon or
-// ReleaseSoon methods should friend the appropriate helper and
-// implement a corresponding *Internal method with the following
-// signature:
-//
-// bool(const tracked_objects::Location&,
-// void(*function)(const void*),
-// void* object)
-//
-// An implementation of this function should simply create a
-// base::Closure from (function, object) and return the result of
-// posting the task.
-template <class T, class ReturnType>
-class DeleteHelperInternal {
- public:
- template <class SequencedTaskRunnerType>
- static ReturnType DeleteViaSequencedTaskRunner(
- SequencedTaskRunnerType* sequenced_task_runner,
- const tracked_objects::Location& from_here,
- const T* object) {
- return sequenced_task_runner->DeleteSoonInternal(
- from_here, &DeleteHelper<T>::DoDelete, object);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DeleteHelperInternal);
-};
-
-template <class T, class ReturnType>
-class ReleaseHelperInternal {
- public:
- template <class SequencedTaskRunnerType>
- static ReturnType ReleaseViaSequencedTaskRunner(
- SequencedTaskRunnerType* sequenced_task_runner,
- const tracked_objects::Location& from_here,
- const T* object) {
- return sequenced_task_runner->ReleaseSoonInternal(
- from_here, &ReleaseHelper<T>::DoRelease, object);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ReleaseHelperInternal);
-};
-
-} // namespace subtle
-
} // namespace base
#endif // BASE_SEQUENCED_TASK_RUNNER_HELPERS_H_
« no previous file with comments | « base/sequenced_task_runner.cc ('k') | content/browser/browser_child_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698