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

Side by Side Diff: ios/chrome/browser/callback_counter.mm

Issue 2885163004: [ObjC ARC] Converts ios/chrome/browser:browser_internal to ARC. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « ios/chrome/browser/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ios/chrome/browser/callback_counter.h" 5 #include "ios/chrome/browser/callback_counter.h"
6 6
7 #if !defined(__has_feature) || !__has_feature(objc_arc)
8 #error "This file requires ARC support."
9 #endif
10
7 CallbackCounter::CallbackCounter(const FinalCallback& final_callback) 11 CallbackCounter::CallbackCounter(const FinalCallback& final_callback)
8 : callback_count_(0U), final_callback_(final_callback) { 12 : callback_count_(0U), final_callback_(final_callback) {
9 DCHECK(!final_callback.is_null()); 13 DCHECK(!final_callback.is_null());
10 } 14 }
11 15
12 CallbackCounter::~CallbackCounter() { 16 CallbackCounter::~CallbackCounter() {
13 DCHECK_EQ(0U, callback_count_); 17 DCHECK_EQ(0U, callback_count_);
14 } 18 }
15 19
16 void CallbackCounter::IncrementCount() { 20 void CallbackCounter::IncrementCount() {
17 DCHECK(thread_checker_.CalledOnValidThread()); 21 DCHECK(thread_checker_.CalledOnValidThread());
18 DCHECK(!final_callback_.is_null()); 22 DCHECK(!final_callback_.is_null());
19 ++callback_count_; 23 ++callback_count_;
20 } 24 }
21 25
22 void CallbackCounter::DecrementCount() { 26 void CallbackCounter::DecrementCount() {
23 DCHECK(thread_checker_.CalledOnValidThread()); 27 DCHECK(thread_checker_.CalledOnValidThread());
24 DCHECK(callback_count_); 28 DCHECK(callback_count_);
25 29
26 --callback_count_; 30 --callback_count_;
27 if (callback_count_ == 0) { 31 if (callback_count_ == 0) {
28 final_callback_.Run(); 32 final_callback_.Run();
29 final_callback_.Reset(); 33 final_callback_.Reset();
30 } 34 }
31 } 35 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698