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

Side by Side Diff: cc/raster/staging_buffer_pool.cc

Issue 2648323005: memory coordinator: Add MemoryCoordinatorClient::OnPurgeMemory() (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/raster/staging_buffer_pool.h" 5 #include "cc/raster/staging_buffer_pool.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/memory_coordinator_client_registry.h" 9 #include "base/memory/memory_coordinator_client_registry.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 if (busy_buffers_.front()->last_usage > time) 425 if (busy_buffers_.front()->last_usage > time)
426 return; 426 return;
427 427
428 busy_buffers_.front()->DestroyGLResources(gl); 428 busy_buffers_.front()->DestroyGLResources(gl);
429 RemoveStagingBuffer(busy_buffers_.front().get()); 429 RemoveStagingBuffer(busy_buffers_.front().get());
430 busy_buffers_.pop_front(); 430 busy_buffers_.pop_front();
431 } 431 }
432 } 432 }
433 } 433 }
434 434
435 void StagingBufferPool::OnMemoryStateChange(base::MemoryState state) { 435 void StagingBufferPool::OnPurgeMemory() {
436 switch (state) { 436 base::AutoLock lock(lock_);
437 case base::MemoryState::NORMAL: 437 // Release all buffers, regardless of how recently they were used.
438 // TODO(tasak): go back to normal state. 438 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
439 break;
440 case base::MemoryState::THROTTLED:
441 // TODO(tasak): make the limits of this component's caches smaller to
442 // save memory usage.
443 break;
444 case base::MemoryState::SUSPENDED: {
445 base::AutoLock lock(lock_);
446 // Release all buffers, regardless of how recently they were used.
447 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
448 } break;
449 case base::MemoryState::UNKNOWN:
450 // NOT_REACHED.
451 break;
452 }
453 } 439 }
454 440
455 } // namespace cc 441 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698