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

Side by Side Diff: sync/internal_api/public/base/cancelation_signal.cc

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, 4 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "sync/internal_api/public/base/cancelation_signal.h"
6
7 #include "base/logging.h"
8 #include "sync/internal_api/public/base/cancelation_observer.h"
9
10 namespace syncer {
11
12 CancelationSignal::CancelationSignal()
13 : signalled_(false),
14 handler_(NULL) { }
15
16 CancelationSignal::~CancelationSignal() {
17 DCHECK(!handler_);
18 }
19
20 bool CancelationSignal::TryRegisterHandler(CancelationObserver* handler) {
21 base::AutoLock lock(signal_lock_);
22 DCHECK(!handler_);
23
24 if (signalled_)
25 return false;
26
27 handler_ = handler;
28 return true;
29 }
30
31 void CancelationSignal::UnregisterHandler(CancelationObserver* handler) {
32 base::AutoLock lock(signal_lock_);
33 DCHECK_EQ(handler_, handler);
34 handler_ = NULL;
35 }
36
37 bool CancelationSignal::IsSignalled() {
38 base::AutoLock lock(signal_lock_);
39 return signalled_;
40 }
41
42 void CancelationSignal::Signal() {
43 base::AutoLock lock(signal_lock_);
44 DCHECK(!signalled_);
45
46 signalled_ = true;
47 if (handler_) {
48 handler_->OnSignalReceived();
49 }
50 }
51
52 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/public/base/cancelation_signal.h ('k') | sync/internal_api/public/base/cancelation_signal_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698