diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 01:24:16 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 01:24:16 +0000 |
commit | 9260757f9dd8de119450e6cc351dda15df17cf8d (patch) | |
tree | 1aa791088cd401d42e714c1b102635e7e4caf480 /cc/resources/single_release_callback.cc | |
parent | 0ceda8a5374cf90e636134835d41c3194c52b0bc (diff) | |
download | chromium_src-9260757f9dd8de119450e6cc351dda15df17cf8d.zip chromium_src-9260757f9dd8de119450e6cc351dda15df17cf8d.tar.gz chromium_src-9260757f9dd8de119450e6cc351dda15df17cf8d.tar.bz2 |
cc: Move TextureMailbox::ReleaseCallback to SingleReleaseCallback.
This moves the release callback out of the TextureMailbox so that we
can use it for other resource types than just texture mailboxes.
While doing this, we make a SingleReleaseCallback class that is
held in a scoped_ptr. This class DCHECKs that the callback is run
before it is destroyed, and ensures clear ownership semantics as
you must Pass() the callback around.
No change in behaviour, covered by existing tests.
R=piman
BUG=263069
Review URL: https://chromiumcodereview.appspot.com/23648014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223500 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources/single_release_callback.cc')
-rw-r--r-- | cc/resources/single_release_callback.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cc/resources/single_release_callback.cc b/cc/resources/single_release_callback.cc new file mode 100644 index 0000000..9c6b9de --- /dev/null +++ b/cc/resources/single_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/single_release_callback.h" + +#include "base/callback_helpers.h" +#include "base/logging.h" + +namespace cc { + +SingleReleaseCallback::SingleReleaseCallback(const ReleaseCallback& callback) + : has_been_run_(false), callback_(callback) { + DCHECK(!callback_.is_null()) + << "Use a NULL SingleReleaseCallback for an empty callback."; +} + +SingleReleaseCallback::~SingleReleaseCallback() { + DCHECK(callback_.is_null() || has_been_run_) + << "SingleReleaseCallback was never run."; +} + +void SingleReleaseCallback::Run(unsigned sync_point, bool is_lost) { + DCHECK(!has_been_run_) << "SingleReleaseCallback was run more than once."; + has_been_run_ = true; + callback_.Run(sync_point, is_lost); +} + +} // namespace cc |