| 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.h" | 5 #include "content/browser/memory/memory_coordinator.h" |
| 6 | 6 |
| 7 #include "base/memory/memory_pressure_monitor.h" | 7 #include "base/memory/memory_pressure_monitor.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 Child(mojom::ChildMemoryCoordinatorPtr* cmc_ptr) : cmc_binding(&cmc) { | 52 Child(mojom::ChildMemoryCoordinatorPtr* cmc_ptr) : cmc_binding(&cmc) { |
| 53 cmc_binding.Bind(mojo::GetProxy(cmc_ptr)); | 53 cmc_binding.Bind(mojo::GetProxy(cmc_ptr)); |
| 54 RunUntilIdle(); | 54 RunUntilIdle(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 MockChildMemoryCoordinator cmc; | 57 MockChildMemoryCoordinator cmc; |
| 58 mojo::Binding<mojom::ChildMemoryCoordinator> cmc_binding; | 58 mojo::Binding<mojom::ChildMemoryCoordinator> cmc_binding; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 TestMemoryCoordinator() {} | 61 TestMemoryCoordinator() {} |
| 62 ~TestMemoryCoordinator() {} | 62 ~TestMemoryCoordinator() override {} |
| 63 | 63 |
| 64 using MemoryCoordinator::OnConnectionError; | 64 using MemoryCoordinator::OnConnectionError; |
| 65 | 65 |
| 66 MockChildMemoryCoordinator* CreateChildMemoryCoordinator( | 66 MockChildMemoryCoordinator* CreateChildMemoryCoordinator( |
| 67 int process_id) { | 67 int process_id) { |
| 68 mojom::ChildMemoryCoordinatorPtr cmc_ptr; | 68 mojom::ChildMemoryCoordinatorPtr cmc_ptr; |
| 69 children_.push_back(std::unique_ptr<Child>(new Child(&cmc_ptr))); | 69 children_.push_back(std::unique_ptr<Child>(new Child(&cmc_ptr))); |
| 70 AddChildForTesting(process_id, std::move(cmc_ptr)); | 70 AddChildForTesting(process_id, std::move(cmc_ptr)); |
| 71 return &children_.back()->cmc; | 71 return &children_.back()->cmc; |
| 72 } | 72 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 EXPECT_TRUE(mc.SetMemoryState(1, mojom::MemoryState::THROTTLED)); | 130 EXPECT_TRUE(mc.SetMemoryState(1, mojom::MemoryState::THROTTLED)); |
| 131 EXPECT_EQ(1, cmc1->on_state_change_calls()); | 131 EXPECT_EQ(1, cmc1->on_state_change_calls()); |
| 132 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc1->state()); | 132 EXPECT_EQ(mojom::MemoryState::THROTTLED, cmc1->state()); |
| 133 | 133 |
| 134 EXPECT_TRUE(mc.SetMemoryState(2, mojom::MemoryState::SUSPENDED)); | 134 EXPECT_TRUE(mc.SetMemoryState(2, mojom::MemoryState::SUSPENDED)); |
| 135 EXPECT_EQ(1, cmc2->on_state_change_calls()); | 135 EXPECT_EQ(1, cmc2->on_state_change_calls()); |
| 136 EXPECT_EQ(mojom::MemoryState::SUSPENDED, cmc2->state()); | 136 EXPECT_EQ(mojom::MemoryState::SUSPENDED, cmc2->state()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace content | 139 } // namespace content |
| OLD | NEW |