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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 DCHECK(client); | 203 DCHECK(client); |
204 DCHECK(!client_); | 204 DCHECK(!client_); |
205 client_ = client; | 205 client_ = client; |
206 bool success = true; | 206 bool success = true; |
207 | 207 |
208 if (context_provider_.get()) { | 208 if (context_provider_.get()) { |
209 success = context_provider_->BindToCurrentThread(); | 209 success = context_provider_->BindToCurrentThread(); |
210 if (success) { | 210 if (success) { |
211 context_provider_->SetLostContextCallback(base::Bind( | 211 context_provider_->SetLostContextCallback(base::Bind( |
212 &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); | 212 &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); |
213 context_provider_->SetMemoryPolicyChangedCallback( | |
214 base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this))); | |
215 } | 213 } |
216 } | 214 } |
217 | 215 |
218 if (!success) | 216 if (!success) |
219 client_ = NULL; | 217 client_ = NULL; |
220 | 218 |
221 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). | 219 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). |
222 // Don't register a dump provider in these cases. | 220 // Don't register a dump provider in these cases. |
223 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 | 221 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 |
224 if (client_ && base::ThreadTaskRunnerHandle::IsSet()) { | 222 if (client_ && base::ThreadTaskRunnerHandle::IsSet()) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 DCHECK(client_); | 346 DCHECK(client_); |
349 | 347 |
350 // Unregister any dump provider. Safe to call (no-op) if we have not yet | 348 // Unregister any dump provider. Safe to call (no-op) if we have not yet |
351 // registered. | 349 // registered. |
352 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 350 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
353 this); | 351 this); |
354 | 352 |
355 if (context_provider_.get()) { | 353 if (context_provider_.get()) { |
356 context_provider_->SetLostContextCallback( | 354 context_provider_->SetLostContextCallback( |
357 ContextProvider::LostContextCallback()); | 355 ContextProvider::LostContextCallback()); |
358 context_provider_->SetMemoryPolicyChangedCallback( | |
359 ContextProvider::MemoryPolicyChangedCallback()); | |
360 } | 356 } |
361 context_provider_ = nullptr; | 357 context_provider_ = nullptr; |
362 client_ = nullptr; | 358 client_ = nullptr; |
363 weak_ptr_factory_.InvalidateWeakPtrs(); | 359 weak_ptr_factory_.InvalidateWeakPtrs(); |
364 } | 360 } |
365 | 361 |
366 } // namespace cc | 362 } // namespace cc |
OLD | NEW |