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

Unified Diff: components/sync/base/scoped_event_signal.h

Issue 2820623002: Revert of [Sync] Refactor ModelSafeWorker::DoWorkAndWaitUntilDone() to avoid code duplication. (Closed)
Patch Set: Created 3 years, 8 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 | « components/sync/BUILD.gn ('k') | components/sync/base/scoped_event_signal.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/base/scoped_event_signal.h
diff --git a/components/sync/base/scoped_event_signal.h b/components/sync/base/scoped_event_signal.h
new file mode 100644
index 0000000000000000000000000000000000000000..d8df1044afdb84bcfe9d7471d697dc5eb961ee60
--- /dev/null
+++ b/components/sync/base/scoped_event_signal.h
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SYNC_BASE_SCOPED_EVENT_SIGNAL_H_
+#define COMPONENTS_SYNC_BASE_SCOPED_EVENT_SIGNAL_H_
+
+#include "base/macros.h"
+
+namespace base {
+class WaitableEvent;
+}
+
+namespace syncer {
+
+// An object which signals a WaitableEvent when it is deleted. Used to wait for
+// a task to run or be abandoned.
+class ScopedEventSignal {
+ public:
+ // |event| will be signaled in the destructor.
+ explicit ScopedEventSignal(base::WaitableEvent* event);
+
+ // This ScopedEventSignal will signal |other|'s WaitableEvent in its
+ // destructor. |other| will not signal anything in its destructor. The
+ // assignment operator cannot be used if this ScopedEventSignal's
+ // WaitableEvent hasn't been moved to another ScopedEventSignal.
+ ScopedEventSignal(ScopedEventSignal&& other);
+ ScopedEventSignal& operator=(ScopedEventSignal&& other);
+
+ ~ScopedEventSignal();
+
+ private:
+ base::WaitableEvent* event_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedEventSignal);
+};
+
+} // namespace syncer
+
+#endif // COMPONENTS_SYNC_BASE_SCOPED_EVENT_SIGNAL_H_
« no previous file with comments | « components/sync/BUILD.gn ('k') | components/sync/base/scoped_event_signal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698