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

Unified Diff: sync/internal_api/public/base/cancelation_signal.h

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 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
Index: sync/internal_api/public/base/cancelation_signal.h
diff --git a/sync/internal_api/public/base/cancelation_signal.h b/sync/internal_api/public/base/cancelation_signal.h
deleted file mode 100644
index 6a84b7a1c6b96ff18a446c4c3a7051c155b5cb7c..0000000000000000000000000000000000000000
--- a/sync/internal_api/public/base/cancelation_signal.h
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2013 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 SYNC_INTERNAL_API_PUBLIC_BASE_CANCELATION_SIGNAL_H_
-#define SYNC_INTERNAL_API_PUBLIC_BASE_CANCELATION_SIGNAL_H_
-
-#include "base/synchronization/lock.h"
-#include "sync/base/sync_export.h"
-
-namespace syncer {
-
-class CancelationObserver;
-
-// This class is used to allow one thread to request that another abort and
-// return early.
-//
-// The signalling thread owns this class and my call Signal() at any time.
-// After that call, this class' IsSignalled() will always return true. The
-// intended use case is that the task intending to support early exit will
-// periodically check the value of IsSignalled() to see if it should return
-// early.
-//
-// The receiving task may also choose to register an CancelationObserver whose
-// OnSignalReceived() method will be executed on the signaller's thread when
-// Signal() is called. This may be used for sending an early Signal() to a
-// WaitableEvent. The registration of the handler is necessarily racy. If
-// Signal() is executes before TryRegisterHandler(), TryRegisterHandler() will
-// not perform any registration and return false. That function's caller must
-// handle this case.
-//
-// This class supports only one handler, though it could easily support multiple
-// observers if we found a use case for such a feature.
-class SYNC_EXPORT CancelationSignal {
- public:
- CancelationSignal();
- ~CancelationSignal();
-
- // Tries to register a handler to be invoked when Signal() is called.
- //
- // If Signal() has already been called, returns false without registering
- // the handler. Returns true when the registration is successful.
- //
- // If the registration was successful, the handler must be unregistered with
- // UnregisterHandler before this CancelationSignal is destroyed.
- bool TryRegisterHandler(CancelationObserver* handler);
-
- // Unregisters the abort handler.
- void UnregisterHandler(CancelationObserver* handler);
-
- // Returns true if Signal() has been called.
- bool IsSignalled();
-
- // Sets the stop_requested_ flag and calls the OnSignalReceived() method of
- // the registered handler, if there is one registered at the time.
- // SignalReceived() will be called with the |signal_lock_| held.
- void Signal();
-
- private:
- // Protects all members of this class.
- base::Lock signal_lock_;
-
- // True if Signal() has been invoked.
- bool signalled_;
-
- // The registered abort handler. May be NULL.
- CancelationObserver* handler_;
-};
-
-} // namespace syncer
-
-#endif // SYNC_INTERNAL_API_PUBLIC_BASE_CANCELATION_SIGNAL_H_
« no previous file with comments | « sync/internal_api/public/base/cancelation_observer.cc ('k') | sync/internal_api/public/base/cancelation_signal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698