OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/renderer/render_process_visibility_manager.h" | 5 #include "content/renderer/render_process_visibility_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/memory_pressure_listener.h" | 8 #include "base/memory/memory_pressure_listener.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 RenderProcessVisibilityManager::RenderProcessVisibilityManager() | 12 RenderProcessVisibilityManager::RenderProcessVisibilityManager() |
13 : num_visible_render_widgets_(0) { | 13 : num_visible_render_widgets_(0) { |
14 } | 14 } |
15 | 15 |
16 RenderProcessVisibilityManager::~RenderProcessVisibilityManager() { | 16 RenderProcessVisibilityManager::~RenderProcessVisibilityManager() { |
17 } | 17 } |
18 | 18 |
19 // static | 19 // static |
20 RenderProcessVisibilityManager* RenderProcessVisibilityManager::GetInstance() { | 20 RenderProcessVisibilityManager* RenderProcessVisibilityManager::GetInstance() { |
21 return Singleton<RenderProcessVisibilityManager>::get(); | 21 return Singleton<RenderProcessVisibilityManager>::get(); |
22 } | 22 } |
23 | 23 |
24 void RenderProcessVisibilityManager::WidgetVisibilityChanged(bool visible) { | 24 void RenderProcessVisibilityManager::WidgetVisibilityChanged(bool visible) { |
25 #if !defined(DISCARDABLE_MEMORY_ALWAYS_SUPPORTED_NATIVELY) | 25 #if !defined(SYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE) |
26 num_visible_render_widgets_ += visible ? 1 : -1; | 26 num_visible_render_widgets_ += visible ? 1 : -1; |
27 DCHECK_LE(0, num_visible_render_widgets_); | 27 DCHECK_LE(0, num_visible_render_widgets_); |
28 if (num_visible_render_widgets_ == 0) { | 28 if (num_visible_render_widgets_ == 0) { |
29 // TODO(vollick): Remove this this heavy-handed approach once we're polling | 29 // TODO(vollick): Remove this this heavy-handed approach once we're polling |
30 // the real system memory pressure. | 30 // the real system memory pressure. |
31 base::MemoryPressureListener::NotifyMemoryPressure( | 31 base::MemoryPressureListener::NotifyMemoryPressure( |
32 base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL); | 32 base::MemoryPressureListener::MEMORY_PRESSURE_MODERATE); |
33 } | 33 } |
34 #endif | 34 #endif |
35 } | 35 } |
36 | 36 |
37 } // namespace content | 37 } // namespace content |
OLD | NEW |