Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / sync / internal_api / public / base / cancelation_signal.cc
blob94a479ba5cbdae5e31fb408c2894c4fde0611997
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "sync/internal_api/public/base/cancelation_signal.h"
7 #include "base/logging.h"
8 #include "sync/internal_api/public/base/cancelation_observer.h"
10 namespace syncer {
12 CancelationSignal::CancelationSignal()
13 : signalled_(false),
14 handler_(NULL) { }
16 CancelationSignal::~CancelationSignal() {
17 DCHECK(!handler_);
20 bool CancelationSignal::TryRegisterHandler(CancelationObserver* handler) {
21 base::AutoLock lock(signal_lock_);
22 DCHECK(!handler_);
24 if (signalled_)
25 return false;
27 handler_ = handler;
28 return true;
31 void CancelationSignal::UnregisterHandler(CancelationObserver* handler) {
32 base::AutoLock lock(signal_lock_);
33 DCHECK_EQ(handler_, handler);
34 handler_ = NULL;
37 bool CancelationSignal::IsSignalled() {
38 base::AutoLock lock(signal_lock_);
39 return signalled_;
42 void CancelationSignal::Signal() {
43 base::AutoLock lock(signal_lock_);
44 DCHECK(!signalled_);
46 signalled_ = true;
47 if (handler_) {
48 handler_->OnSignalReceived();
52 } // namespace syncer