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 30 matching lines...) Expand all Loading... |
41 default: | 41 default: |
42 NOTREACHED(); | 42 NOTREACHED(); |
43 return mojom::MemoryState::UNKNOWN; | 43 return mojom::MemoryState::UNKNOWN; |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 const char* MemoryConditionToString(MemoryCondition condition) { | 47 const char* MemoryConditionToString(MemoryCondition condition) { |
48 switch (condition) { | 48 switch (condition) { |
49 case MemoryCondition::NORMAL: | 49 case MemoryCondition::NORMAL: |
50 return "normal"; | 50 return "normal"; |
51 case MemoryCondition::WARNING: | |
52 return "warning"; | |
53 case MemoryCondition::CRITICAL: | 51 case MemoryCondition::CRITICAL: |
54 return "critical"; | 52 return "critical"; |
55 } | 53 } |
56 NOTREACHED(); | 54 NOTREACHED(); |
57 return "N/A"; | 55 return "N/A"; |
58 } | 56 } |
59 | 57 |
60 void RecordBrowserPurge(size_t before) { | 58 void RecordBrowserPurge(size_t before) { |
61 auto metrics = base::ProcessMetrics::CreateCurrentProcessMetrics(); | 59 auto metrics = base::ProcessMetrics::CreateCurrentProcessMetrics(); |
62 size_t after = metrics->GetWorkingSetSize(); | 60 size_t after = metrics->GetWorkingSetSize(); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 if (render_process_host && render_process_host->GetHandle() == handle) | 313 if (render_process_host && render_process_host->GetHandle() == handle) |
316 return iter.second.memory_state; | 314 return iter.second.memory_state; |
317 } | 315 } |
318 return MemoryState::UNKNOWN; | 316 return MemoryState::UNKNOWN; |
319 } | 317 } |
320 | 318 |
321 void MemoryCoordinatorImpl::UpdateConditionIfNeeded( | 319 void MemoryCoordinatorImpl::UpdateConditionIfNeeded( |
322 MemoryCondition next_condition) { | 320 MemoryCondition next_condition) { |
323 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 321 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
324 | 322 |
325 if (next_condition == MemoryCondition::WARNING) | 323 if (next_condition == MemoryCondition::CRITICAL) |
326 policy_->OnWarningCondition(); | |
327 else if (next_condition == MemoryCondition::CRITICAL) | |
328 policy_->OnCriticalCondition(); | 324 policy_->OnCriticalCondition(); |
329 | 325 |
330 if (suppress_condition_change_until_ > tick_clock_->NowTicks() || | 326 if (suppress_condition_change_until_ > tick_clock_->NowTicks() || |
331 memory_condition_ == next_condition) | 327 memory_condition_ == next_condition) |
332 return; | 328 return; |
333 | 329 |
334 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("memory_coordinator"), | 330 TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("memory_coordinator"), |
335 "MemoryCoordinatorImpl::UpdateConditionIfNeeded", "prev", | 331 "MemoryCoordinatorImpl::UpdateConditionIfNeeded", "prev", |
336 MemoryConditionToString(memory_condition_), "next", | 332 MemoryConditionToString(memory_condition_), "next", |
337 MemoryConditionToString(next_condition)); | 333 MemoryConditionToString(next_condition)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 420 |
425 MemoryCoordinatorImpl::ChildInfo::ChildInfo() {} | 421 MemoryCoordinatorImpl::ChildInfo::ChildInfo() {} |
426 | 422 |
427 MemoryCoordinatorImpl::ChildInfo::ChildInfo(const ChildInfo& rhs) { | 423 MemoryCoordinatorImpl::ChildInfo::ChildInfo(const ChildInfo& rhs) { |
428 // This is a nop, but exists for compatibility with STL containers. | 424 // This is a nop, but exists for compatibility with STL containers. |
429 } | 425 } |
430 | 426 |
431 MemoryCoordinatorImpl::ChildInfo::~ChildInfo() {} | 427 MemoryCoordinatorImpl::ChildInfo::~ChildInfo() {} |
432 | 428 |
433 } // namespace content | 429 } // namespace content |
OLD | NEW |