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/memory_coordinator_proxy.h" | 8 #include "base/memory/memory_coordinator_proxy.h" |
9 #include "base/memory/memory_pressure_monitor.h" | 9 #include "base/memory/memory_pressure_monitor.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 #define MAYBE_GetStateForProcess GetStateForProcess | 525 #define MAYBE_GetStateForProcess GetStateForProcess |
526 #endif | 526 #endif |
527 TEST_F(MemoryCoordinatorImplTest, MAYBE_GetStateForProcess) { | 527 TEST_F(MemoryCoordinatorImplTest, MAYBE_GetStateForProcess) { |
528 EXPECT_EQ(base::MemoryState::UNKNOWN, | 528 EXPECT_EQ(base::MemoryState::UNKNOWN, |
529 coordinator_->GetStateForProcess(base::kNullProcessHandle)); | 529 coordinator_->GetStateForProcess(base::kNullProcessHandle)); |
530 EXPECT_EQ(base::MemoryState::NORMAL, | 530 EXPECT_EQ(base::MemoryState::NORMAL, |
531 coordinator_->GetStateForProcess(base::GetCurrentProcessHandle())); | 531 coordinator_->GetStateForProcess(base::GetCurrentProcessHandle())); |
532 | 532 |
533 coordinator_->CreateChildMemoryCoordinator(1); | 533 coordinator_->CreateChildMemoryCoordinator(1); |
534 coordinator_->CreateChildMemoryCoordinator(2); | 534 coordinator_->CreateChildMemoryCoordinator(2); |
535 base::Process process1 = SpawnChild("process1"); | 535 |
536 base::Process process2 = SpawnChild("process2"); | 536 base::SpawnChildResult spawn_result = SpawnChild("process1"); |
| 537 base::Process process1 = std::move(spawn_result.process); |
| 538 spawn_result = SpawnChild("process2"); |
| 539 base::Process process2 = std::move(spawn_result.process); |
| 540 |
537 coordinator_->GetMockRenderProcessHost(1)->SetProcessHandle( | 541 coordinator_->GetMockRenderProcessHost(1)->SetProcessHandle( |
538 base::MakeUnique<base::ProcessHandle>(process1.Handle())); | 542 base::MakeUnique<base::ProcessHandle>(process1.Handle())); |
539 coordinator_->GetMockRenderProcessHost(2)->SetProcessHandle( | 543 coordinator_->GetMockRenderProcessHost(2)->SetProcessHandle( |
540 base::MakeUnique<base::ProcessHandle>(process2.Handle())); | 544 base::MakeUnique<base::ProcessHandle>(process2.Handle())); |
541 | 545 |
542 EXPECT_EQ(base::MemoryState::NORMAL, | 546 EXPECT_EQ(base::MemoryState::NORMAL, |
543 coordinator_->GetStateForProcess(process1.Handle())); | 547 coordinator_->GetStateForProcess(process1.Handle())); |
544 EXPECT_EQ(base::MemoryState::NORMAL, | 548 EXPECT_EQ(base::MemoryState::NORMAL, |
545 coordinator_->GetStateForProcess(process2.Handle())); | 549 coordinator_->GetStateForProcess(process2.Handle())); |
546 | 550 |
547 EXPECT_TRUE( | 551 EXPECT_TRUE( |
548 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED)); | 552 coordinator_->SetChildMemoryState(1, MemoryState::THROTTLED)); |
549 EXPECT_EQ(base::MemoryState::THROTTLED, | 553 EXPECT_EQ(base::MemoryState::THROTTLED, |
550 coordinator_->GetStateForProcess(process1.Handle())); | 554 coordinator_->GetStateForProcess(process1.Handle())); |
551 EXPECT_EQ(base::MemoryState::NORMAL, | 555 EXPECT_EQ(base::MemoryState::NORMAL, |
552 coordinator_->GetStateForProcess(process2.Handle())); | 556 coordinator_->GetStateForProcess(process2.Handle())); |
553 } | 557 } |
554 | 558 |
555 } // namespace content | 559 } // namespace content |
OLD | NEW |