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

Unified Diff: cc/resources/texture_mailbox_deleter.cc

Issue 23648014: cc: Move TextureMailbox::ReleaseCallback to SingleReleaseCallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: releasecallback: dchecks Created 7 years, 3 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
Index: cc/resources/texture_mailbox_deleter.cc
diff --git a/cc/resources/texture_mailbox_deleter.cc b/cc/resources/texture_mailbox_deleter.cc
index ed611e464fa756703a16a90224b6b55e60854729..02418734a6f0d6a13d7046909337c2facab1ee99 100644
--- a/cc/resources/texture_mailbox_deleter.cc
+++ b/cc/resources/texture_mailbox_deleter.cc
@@ -9,6 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "cc/output/context_provider.h"
+#include "cc/resources/scoped_release_callback.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
namespace cc {
@@ -25,7 +26,7 @@ static void DeleteTextureOnImplThread(
static void PostTaskFromMainToImplThread(
scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
- TextureMailbox::ReleaseCallback run_impl_callback,
+ ReleaseCallback run_impl_callback,
unsigned sync_point,
bool is_lost) {
// This posts the task to RunDeleteTextureOnImplThread().
@@ -40,43 +41,45 @@ TextureMailboxDeleter::~TextureMailboxDeleter() {
impl_callbacks_.at(i)->Run(0, true);
}
-TextureMailbox::ReleaseCallback TextureMailboxDeleter::GetReleaseCallback(
+scoped_ptr<ScopedReleaseCallback> TextureMailboxDeleter::GetReleaseCallback(
const scoped_refptr<ContextProvider>& context_provider,
unsigned texture_id) {
// This callback owns a reference on the |context_provider|. It must be
// destroyed on the impl thread. Upon destruction of this class, the
// callback must immediately be destroyed.
- scoped_ptr<TextureMailbox::ReleaseCallback> impl_callback(
- new TextureMailbox::ReleaseCallback(base::Bind(
- &DeleteTextureOnImplThread, context_provider, texture_id)));
+ scoped_ptr<ScopedReleaseCallback> impl_callback =
+ ScopedReleaseCallback::Create(base::Bind(&DeleteTextureOnImplThread,
+ context_provider,
+ texture_id));
impl_callbacks_.push_back(impl_callback.Pass());
// The raw pointer to the impl-side callback is valid as long as this
// class is alive. So we guard it with a WeakPtr.
- TextureMailbox::ReleaseCallback run_impl_callback =
+ ReleaseCallback run_impl_callback(
base::Bind(&TextureMailboxDeleter::RunDeleteTextureOnImplThread,
weak_ptr_factory_.GetWeakPtr(),
- impl_callbacks_.back());
+ impl_callbacks_.back()));
// Provide a callback for the main thread that posts back to the impl
// thread.
- TextureMailbox::ReleaseCallback main_callback =
- base::Bind(&PostTaskFromMainToImplThread,
- base::MessageLoopProxy::current(),
- run_impl_callback);
+ scoped_ptr<ScopedReleaseCallback> main_callback =
+ ScopedReleaseCallback::Create(base::Bind(
+ &PostTaskFromMainToImplThread,
+ base::MessageLoopProxy::current(),
+ run_impl_callback));
- return main_callback;
+ return main_callback.Pass();
}
void TextureMailboxDeleter::RunDeleteTextureOnImplThread(
- TextureMailbox::ReleaseCallback* impl_callback,
+ ScopedReleaseCallback* impl_callback,
unsigned sync_point,
bool is_lost) {
for (size_t i = 0; i < impl_callbacks_.size(); ++i) {
- if (impl_callbacks_.at(i)->Equals(*impl_callback)) {
+ if (impl_callbacks_.at(i) == impl_callback) {
// Run the callback, then destroy it here on the impl thread.
- impl_callback->Run(sync_point, is_lost);
+ impl_callbacks_.at(i)->Run(sync_point, is_lost);
impl_callbacks_.erase(impl_callbacks_.begin() + i);
return;
}

Powered by Google App Engine
This is Rietveld 408576698