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

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: fixes 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
Index: cc/test/test_context_support.cc
diff --git a/cc/test/test_context_support.cc b/cc/test/test_context_support.cc
index e0c71e316d07cee9aa3670eb2a5febf6b22ddebf..8b2a279401810dbb88b4abd048b99cefcb8938df 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) {}
@@ -58,6 +65,8 @@ void TestContextSupport::SetAggressivelyFreeResources(
bool aggressively_free_resources) {
}
+void TestContextSupport::TrimResources() {}
+
void TestContextSupport::CallAllSyncPointCallbacks() {
size_t size = sync_point_callbacks_.size();
if (out_of_order_callbacks_) {
@@ -128,4 +137,17 @@ 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,
+ scoped_refptr<base::SingleThreadTaskRunner> callback_task_runner) {}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698