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

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

Issue 23189021: sync: Gracefully handle very early shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync_client compile Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 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/cancellation_signal.h"
6
7 #include "base/logging.h"
8 #include "sync/internal_api/public/base/cancellation_observer.h"
9
10 namespace syncer {
11
12 CancellationSignal::CancellationSignal()
13 : stop_requested_(false),
14 handler_(NULL){ }
akalin 2013/09/05 16:06:35 space after )
rlarocque 2013/09/05 22:37:06 Done.
15
16 CancellationSignal::~CancellationSignal() {
17 DCHECK(!handler_);
18 }
19
20 bool CancellationSignal::TryRegisterHandler(CancellationObserver* handler) {
21 base::AutoLock lock(stop_requested_lock_);
22 DCHECK(!handler_);
23
24 if (stop_requested_)
25 return false;
26
27 handler_ = handler;
28 return true;
29 }
30
31 void CancellationSignal::UnregisterHandler(CancellationObserver* handler) {
32 base::AutoLock lock(stop_requested_lock_);
33 DCHECK_EQ(handler_, handler);
34 handler_ = NULL;
35 }
36
37 bool CancellationSignal::IsStopRequested() {
38 base::AutoLock lock(stop_requested_lock_);
39 return stop_requested_;
40 }
41
42 void CancellationSignal::RequestStop() {
43 base::AutoLock lock(stop_requested_lock_);
44 DCHECK(!stop_requested_);
45
46 stop_requested_ = true;
47 if (handler_) {
48 handler_->OnStopRequested();
49 }
50 }
51
52 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698