| OLD | NEW |
| 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 "content/browser/memory/memory_coordinator_impl.h" | 5 #include "content/browser/memory/memory_coordinator_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/memory_coordinator_client_registry.h" | 7 #include "base/memory/memory_coordinator_client_registry.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 void MemoryCoordinatorImpl::RecordMemoryPressure( | 226 void MemoryCoordinatorImpl::RecordMemoryPressure( |
| 227 base::MemoryPressureMonitor::MemoryPressureLevel level) { | 227 base::MemoryPressureMonitor::MemoryPressureLevel level) { |
| 228 // TODO(bashi): Record memory pressure level. | 228 // TODO(bashi): Record memory pressure level. |
| 229 } | 229 } |
| 230 | 230 |
| 231 MemoryState MemoryCoordinatorImpl::GetCurrentMemoryState() const { | 231 MemoryState MemoryCoordinatorImpl::GetCurrentMemoryState() const { |
| 232 return browser_memory_state_; | 232 return browser_memory_state_; |
| 233 } | 233 } |
| 234 | 234 |
| 235 void MemoryCoordinatorImpl::SetCurrentMemoryStateForTesting( | |
| 236 MemoryState memory_state) { | |
| 237 // Resets |last_state_change_| so that | |
| 238 // UpdateBrowserStateAndNotifyStateToClients() to set memory state forcibly. | |
| 239 last_state_change_ = base::TimeTicks(); | |
| 240 UpdateBrowserStateAndNotifyStateToClients(memory_state); | |
| 241 } | |
| 242 | |
| 243 void MemoryCoordinatorImpl::ForceSetMemoryCondition(MemoryCondition condition, | 235 void MemoryCoordinatorImpl::ForceSetMemoryCondition(MemoryCondition condition, |
| 244 base::TimeDelta duration) { | 236 base::TimeDelta duration) { |
| 245 UpdateConditionIfNeeded(condition); | 237 UpdateConditionIfNeeded(condition); |
| 246 condition_observer_->ScheduleUpdateCondition(duration); | 238 condition_observer_->ScheduleUpdateCondition(duration); |
| 247 } | 239 } |
| 248 | 240 |
| 249 void MemoryCoordinatorImpl::Observe(int type, | 241 void MemoryCoordinatorImpl::Observe(int type, |
| 250 const NotificationSource& source, | 242 const NotificationSource& source, |
| 251 const NotificationDetails& details) { | 243 const NotificationDetails& details) { |
| 252 DCHECK(type == NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED); | 244 DCHECK(type == NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 431 |
| 440 MemoryCoordinatorImpl::ChildInfo::ChildInfo() {} | 432 MemoryCoordinatorImpl::ChildInfo::ChildInfo() {} |
| 441 | 433 |
| 442 MemoryCoordinatorImpl::ChildInfo::ChildInfo(const ChildInfo& rhs) { | 434 MemoryCoordinatorImpl::ChildInfo::ChildInfo(const ChildInfo& rhs) { |
| 443 // This is a nop, but exists for compatibility with STL containers. | 435 // This is a nop, but exists for compatibility with STL containers. |
| 444 } | 436 } |
| 445 | 437 |
| 446 MemoryCoordinatorImpl::ChildInfo::~ChildInfo() {} | 438 MemoryCoordinatorImpl::ChildInfo::~ChildInfo() {} |
| 447 | 439 |
| 448 } // namespace content | 440 } // namespace content |
| OLD | NEW |