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

Unified Diff: base/barrier_closure.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/barrier_closure.h ('k') | base/barrier_closure_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/barrier_closure.cc
diff --git a/base/barrier_closure.cc b/base/barrier_closure.cc
deleted file mode 100644
index 1dcc50238fb07e00e8d86cf7b8db06c0ff23e5fb..0000000000000000000000000000000000000000
--- a/base/barrier_closure.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/barrier_closure.h"
-
-#include "base/atomic_ref_count.h"
-#include "base/bind.h"
-
-namespace {
-
-// Maintains state for a BarrierClosure.
-class BarrierInfo {
- public:
- BarrierInfo(int num_callbacks_left, const base::Closure& done_closure);
- void Run();
-
- private:
- base::AtomicRefCount num_callbacks_left_;
- base::Closure done_closure_;
-};
-
-BarrierInfo::BarrierInfo(int num_callbacks, const base::Closure& done_closure)
- : num_callbacks_left_(num_callbacks),
- done_closure_(done_closure) {
-}
-
-void BarrierInfo::Run() {
- DCHECK(!base::AtomicRefCountIsZero(&num_callbacks_left_));
- if (!base::AtomicRefCountDec(&num_callbacks_left_)) {
- base::Closure done_closure = done_closure_;
- done_closure_.Reset();
- done_closure.Run();
- }
-}
-
-} // namespace
-
-namespace base {
-
-base::Closure BarrierClosure(int num_callbacks_left,
- const base::Closure& done_closure) {
- DCHECK_GE(num_callbacks_left, 0);
-
- if (num_callbacks_left == 0)
- done_closure.Run();
-
- return base::Bind(&BarrierInfo::Run,
- base::Owned(
- new BarrierInfo(num_callbacks_left, done_closure)));
-}
-
-} // namespace base
« no previous file with comments | « base/barrier_closure.h ('k') | base/barrier_closure_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698