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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(MockMemoryMonitor); | 83 DISALLOW_COPY_AND_ASSIGN(MockMemoryMonitor); |
84 }; | 84 }; |
85 | 85 |
86 // A MemoryCoordinatorImpl that can be directly constructed. | 86 // A MemoryCoordinatorImpl that can be directly constructed. |
87 class TestMemoryCoordinatorImpl : public MemoryCoordinatorImpl { | 87 class TestMemoryCoordinatorImpl : public MemoryCoordinatorImpl { |
88 public: | 88 public: |
89 // Mojo machinery for wrapping a mock ChildMemoryCoordinator. | 89 // Mojo machinery for wrapping a mock ChildMemoryCoordinator. |
90 struct Child { | 90 struct Child { |
91 Child(mojom::ChildMemoryCoordinatorPtr* cmc_ptr) : cmc_binding(&cmc) { | 91 Child(mojom::ChildMemoryCoordinatorPtr* cmc_ptr) : cmc_binding(&cmc) { |
92 cmc_binding.Bind(mojo::GetProxy(cmc_ptr)); | 92 cmc_binding.Bind(mojo::MakeRequest(cmc_ptr)); |
93 RunUntilIdle(); | 93 RunUntilIdle(); |
94 } | 94 } |
95 | 95 |
96 MockChildMemoryCoordinator cmc; | 96 MockChildMemoryCoordinator cmc; |
97 mojo::Binding<mojom::ChildMemoryCoordinator> cmc_binding; | 97 mojo::Binding<mojom::ChildMemoryCoordinator> cmc_binding; |
98 }; | 98 }; |
99 | 99 |
100 TestMemoryCoordinatorImpl( | 100 TestMemoryCoordinatorImpl( |
101 scoped_refptr<base::TestMockTimeTaskRunner> task_runner) | 101 scoped_refptr<base::TestMockTimeTaskRunner> task_runner) |
102 : MemoryCoordinatorImpl(task_runner, | 102 : MemoryCoordinatorImpl(task_runner, |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 // Also make sure that the state is updated based on free avaiable memory. | 417 // Also make sure that the state is updated based on free avaiable memory. |
418 // Since the global state has changed in the previous task, we have to wait | 418 // Since the global state has changed in the previous task, we have to wait |
419 // for |minimum_transition|. | 419 // for |minimum_transition|. |
420 GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(40); | 420 GetMockMemoryMonitor()->SetFreeMemoryUntilCriticalMB(40); |
421 task_runner_->FastForwardBy(minimum_transition); | 421 task_runner_->FastForwardBy(minimum_transition); |
422 task_runner_->RunUntilIdle(); | 422 task_runner_->RunUntilIdle(); |
423 EXPECT_EQ(base::MemoryState::THROTTLED, coordinator_->GetGlobalMemoryState()); | 423 EXPECT_EQ(base::MemoryState::THROTTLED, coordinator_->GetGlobalMemoryState()); |
424 } | 424 } |
425 | 425 |
426 } // namespace content | 426 } // namespace content |
OLD | NEW |