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

Unified Diff: cc/test/test_context_support.cc

Issue 2257533006: Free worker context resources on idle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix-cleanup2
Patch Set: rebase Created 4 years, 4 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 | « cc/test/test_context_support.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/test_context_support.cc
diff --git a/cc/test/test_context_support.cc b/cc/test/test_context_support.cc
index d3ec892fc5b48ad7ffe76a5044064de916039031..5153dcdf99d21caa4a1b0f3c09dc2b90dbe92b68 100644
--- a/cc/test/test_context_support.cc
+++ b/cc/test/test_context_support.cc
@@ -17,11 +17,13 @@ namespace cc {
namespace {
// Class that DCHECKs if it is destructed without first having Release called.
-class ScopedVisibilityImpl : public gpu::ContextSupport::ScopedVisibility {
+template <typename T>
+class ScopedContextSupportToken : public T {
public:
- explicit ScopedVisibilityImpl(gpu::ContextSupport* context_support)
+ explicit ScopedContextSupportToken(gpu::ContextSupport* context_support)
: initial_context_support_(context_support) {}
- ~ScopedVisibilityImpl() { DCHECK(!initial_context_support_); }
+
+ ~ScopedContextSupportToken() { DCHECK(!initial_context_support_); }
void Release(gpu::ContextSupport* context_support) {
DCHECK_EQ(initial_context_support_, context_support);
@@ -32,6 +34,11 @@ class ScopedVisibilityImpl : public gpu::ContextSupport::ScopedVisibility {
const gpu::ContextSupport* initial_context_support_;
};
+using ScopedVisibilityImpl =
+ ScopedContextSupportToken<gpu::ContextSupport::ScopedVisibility>;
+using ScopedBusyImpl =
+ ScopedContextSupportToken<gpu::ContextSupport::ScopedBusy>;
+
} // namespace
TestContextSupport::TestContextSupport() : weak_ptr_factory_(this) {}
@@ -126,4 +133,15 @@ bool TestContextSupport::AnyClientsVisible() const {
return num_visible_clients_ > 0;
}
+std::unique_ptr<gpu::ContextSupport::ScopedBusy>
+TestContextSupport::ClientBecameBusy() {
+ return base::MakeUnique<ScopedBusyImpl>(this);
+}
+
+void TestContextSupport::ClientBecameNotBusy(std::unique_ptr<ScopedBusy> busy) {
+ static_cast<ScopedBusyImpl*>(busy.get())->Release(this);
+}
+
+void TestContextSupport::SetIdleCallback(const base::Closure& callback) {}
+
} // namespace cc
« no previous file with comments | « cc/test/test_context_support.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698