| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/memory/memory_pressure_controller_impl.h" | 5 #include "content/browser/memory/memory_pressure_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/memory/memory_message_filter.h" | 8 #include "content/browser/memory/memory_message_filter.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 filter->SendSetPressureNotificationsSuppressed(true); | 32 filter->SendSetPressureNotificationsSuppressed(true); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void MemoryPressureControllerImpl::OnMemoryMessageFilterRemoved( | 35 void MemoryPressureControllerImpl::OnMemoryMessageFilterRemoved( |
| 36 MemoryMessageFilter* filter) { | 36 MemoryMessageFilter* filter) { |
| 37 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 37 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 38 | 38 |
| 39 // Remove the message filter from the set of all memory message filters, | 39 // Remove the message filter from the set of all memory message filters, |
| 40 // ensuring that it was there beforehand. | 40 // ensuring that it was there beforehand. |
| 41 auto it = memory_message_filters_.find(filter->process_host()); | 41 auto it = memory_message_filters_.find(filter->process_host()); |
| 42 DCHECK(it != memory_message_filters_.end()); | 42 if (it == memory_message_filters_.end()) |
| 43 return; |
| 43 DCHECK_EQ(filter, it->second); | 44 DCHECK_EQ(filter, it->second); |
| 44 memory_message_filters_.erase(it); | 45 memory_message_filters_.erase(it); |
| 45 } | 46 } |
| 46 | 47 |
| 47 // static | 48 // static |
| 48 MemoryPressureControllerImpl* MemoryPressureControllerImpl::GetInstance() { | 49 MemoryPressureControllerImpl* MemoryPressureControllerImpl::GetInstance() { |
| 49 return base::Singleton< | 50 return base::Singleton< |
| 50 MemoryPressureControllerImpl, | 51 MemoryPressureControllerImpl, |
| 51 base::LeakySingletonTraits<MemoryPressureControllerImpl>>::get(); | 52 base::LeakySingletonTraits<MemoryPressureControllerImpl>>::get(); |
| 52 } | 53 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 if (base::MemoryPressureListener::AreNotificationsSuppressed()) | 127 if (base::MemoryPressureListener::AreNotificationsSuppressed()) |
| 127 return; | 128 return; |
| 128 | 129 |
| 129 // Find the appropriate message filter and dispatch the message. | 130 // Find the appropriate message filter and dispatch the message. |
| 130 auto it = memory_message_filters_.find(child_process_host); | 131 auto it = memory_message_filters_.find(child_process_host); |
| 131 if (it != memory_message_filters_.end()) | 132 if (it != memory_message_filters_.end()) |
| 132 it->second->SendPressureNotification(level); | 133 it->second->SendPressureNotification(level); |
| 133 } | 134 } |
| 134 | 135 |
| 135 } // namespace content | 136 } // namespace content |
| OLD | NEW |