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

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

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: Created 4 years 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 2015 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 #ifndef IOS_CHROME_BROWSER_CALLBACK_COUNTER_H_
6 #define IOS_CHROME_BROWSER_CALLBACK_COUNTER_H_
7
8 #include "base/callback.h"
9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/threading/thread.h"
12
13 // A helper class that keeps count of the number of pending callbacks that need
14 // to be received. Calls |final_callback| when all callbacks have been received.
15 // All methods (except the destructor) must be called on the same thread.
16 class CallbackCounter : public base::RefCounted<CallbackCounter> {
17 public:
18 typedef base::Callback<void()> FinalCallback;
19
20 explicit CallbackCounter(const FinalCallback& final_callback);
21
22 // Increments the count of pending callbacks.
23 void IncrementCount();
24 // Decrements the count of pending callbacks.
25 void DecrementCount();
26
27 private:
28 friend class base::RefCounted<CallbackCounter>;
29
30 ~CallbackCounter();
31
32 // The number of callbacks that still need to be received.
33 unsigned callback_count_;
34 // The callback that is finally called when all callbacks have been received
35 // (when the |callback_count_| goes down to 0).
36 FinalCallback final_callback_;
37 base::ThreadChecker thread_checker_;
38
39 DISALLOW_COPY_AND_ASSIGN(CallbackCounter);
40 };
41
42 #endif // IOS_CHROME_BROWSER_CALLBACK_COUNTER_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/browsing_data/browsing_data_removal_controller_unittest.mm ('k') | ios/chrome/browser/callback_counter.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698