Index: cc/resources/scoped_release_callback.cc |
diff --git a/cc/resources/scoped_release_callback.cc b/cc/resources/scoped_release_callback.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..415581bd3c7e448572034da6d65cb85ef43960b2 |
--- /dev/null |
+++ b/cc/resources/scoped_release_callback.cc |
@@ -0,0 +1,29 @@ |
+// 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 "cc/resources/scoped_release_callback.h" |
+ |
+#include "base/callback_helpers.h" |
+#include "base/logging.h" |
+ |
+namespace cc { |
+ |
+ScopedReleaseCallback::ScopedReleaseCallback(const ReleaseCallback& callback) |
+ : has_been_run_(false), callback_(callback) { |
+ DCHECK(!callback_.is_null()) |
+ << "Use a NULL ScopedReleaseCallback for an empty callback."; |
+} |
+ |
+ScopedReleaseCallback::~ScopedReleaseCallback() { |
+ DCHECK(callback_.is_null() || has_been_run_) |
+ << "ScopedReleaseCallback was never run."; |
+} |
+ |
+void ScopedReleaseCallback::Run(unsigned sync_point, bool is_lost) { |
+ DCHECK(!has_been_run_) << "ScopedReleaseCallback was run more than once."; |
+ has_been_run_ = true; |
+ callback_.Run(sync_point, is_lost); |
+} |
+ |
+} // namespace cc |