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

Unified Diff: cc/output/compositor_frame_sink.cc

Issue 2404993002: cc: Stop calling DetachFromClient if bind failed. (Closed)
Patch Set: detachinternal: rebase Created 4 years, 2 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/output/compositor_frame_sink.h ('k') | cc/output/output_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/compositor_frame_sink.cc
diff --git a/cc/output/compositor_frame_sink.cc b/cc/output/compositor_frame_sink.cc
index 0958a6214adb95c6f3cef1852352902b6f556952..d4939cc8dd838aeb61d1662398a94bc1a9840b18 100644
--- a/cc/output/compositor_frame_sink.cc
+++ b/cc/output/compositor_frame_sink.cc
@@ -34,7 +34,7 @@ CompositorFrameSink::CompositorFrameSink(
CompositorFrameSink::~CompositorFrameSink() {
if (client_)
- DetachFromClientInternal();
+ DetachFromClient();
}
bool CompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) {
@@ -53,22 +53,16 @@ bool CompositorFrameSink::BindToClient(CompositorFrameSinkClient* client) {
}
}
- if (!success)
- DetachFromClient();
+ if (!success) {
+ // Destroy the ContextProvider on the thread attempted to be bound.
+ context_provider_ = nullptr;
+ client_ = nullptr;
+ }
+
return success;
}
void CompositorFrameSink::DetachFromClient() {
- DetachFromClientInternal();
-}
-
-// We don't post tasks bound to the client directly since they might run
-// after the CompositorFrameSink has been destroyed.
-void CompositorFrameSink::OnSwapBuffersComplete() {
- client_->DidSwapBuffersComplete();
-}
-
-void CompositorFrameSink::DetachFromClientInternal() {
DCHECK(client_thread_checker_.CalledOnValidThread());
DCHECK(client_);
@@ -76,10 +70,17 @@ void CompositorFrameSink::DetachFromClientInternal() {
context_provider_->SetLostContextCallback(
ContextProvider::LostContextCallback());
}
+ // Destroy the ContextProvider on the bound thread.
context_provider_ = nullptr;
client_ = nullptr;
}
+// We don't post tasks bound to the client directly since they might run
+// after the CompositorFrameSink has been destroyed.
+void CompositorFrameSink::OnSwapBuffersComplete() {
+ client_->DidSwapBuffersComplete();
+}
+
void CompositorFrameSink::DidLoseCompositorFrameSink() {
TRACE_EVENT0("cc", "CompositorFrameSink::DidLoseCompositorFrameSink");
client_->DidLoseCompositorFrameSink();
« no previous file with comments | « cc/output/compositor_frame_sink.h ('k') | cc/output/output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698