| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 DCHECK(client); | 209 DCHECK(client); |
| 210 DCHECK(!client_); | 210 DCHECK(!client_); |
| 211 client_ = client; | 211 client_ = client; |
| 212 bool success = true; | 212 bool success = true; |
| 213 | 213 |
| 214 if (context_provider_.get()) { | 214 if (context_provider_.get()) { |
| 215 success = context_provider_->BindToCurrentThread(); | 215 success = context_provider_->BindToCurrentThread(); |
| 216 if (success) { | 216 if (success) { |
| 217 context_provider_->SetLostContextCallback(base::Bind( | 217 context_provider_->SetLostContextCallback(base::Bind( |
| 218 &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); | 218 &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); |
| 219 context_provider_->SetMemoryPolicyChangedCallback( |
| 220 base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this))); |
| 219 } | 221 } |
| 220 } | 222 } |
| 221 | 223 |
| 222 if (!success) | 224 if (!success) |
| 223 client_ = NULL; | 225 client_ = NULL; |
| 224 | 226 |
| 225 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). | 227 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). |
| 226 // Don't register a dump provider in these cases. | 228 // Don't register a dump provider in these cases. |
| 227 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 | 229 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 |
| 228 if (client_ && base::ThreadTaskRunnerHandle::IsSet()) { | 230 if (client_ && base::ThreadTaskRunnerHandle::IsSet()) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 DCHECK(client_); | 358 DCHECK(client_); |
| 357 | 359 |
| 358 // Unregister any dump provider. Safe to call (no-op) if we have not yet | 360 // Unregister any dump provider. Safe to call (no-op) if we have not yet |
| 359 // registered. | 361 // registered. |
| 360 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 362 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 361 this); | 363 this); |
| 362 | 364 |
| 363 if (context_provider_.get()) { | 365 if (context_provider_.get()) { |
| 364 context_provider_->SetLostContextCallback( | 366 context_provider_->SetLostContextCallback( |
| 365 ContextProvider::LostContextCallback()); | 367 ContextProvider::LostContextCallback()); |
| 368 context_provider_->SetMemoryPolicyChangedCallback( |
| 369 ContextProvider::MemoryPolicyChangedCallback()); |
| 366 } | 370 } |
| 367 context_provider_ = nullptr; | 371 context_provider_ = nullptr; |
| 368 client_ = nullptr; | 372 client_ = nullptr; |
| 369 weak_ptr_factory_.InvalidateWeakPtrs(); | 373 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 370 } | 374 } |
| 371 | 375 |
| 372 } // namespace cc | 376 } // namespace cc |
| OLD | NEW |