OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
jam
2016/09/09 16:06:54
ditto re owners
bashi
2016/09/15 04:55:08
Done.
| |
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 #ifndef COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ | 5 #ifndef CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_H_ |
6 #define COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ | 6 #define CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/memory_coordinator_client.h" | 9 #include "base/memory/memory_coordinator_client.h" |
10 #include "components/memory_coordinator/common/memory_coordinator_export.h" | 10 #include "content/common/child_memory_coordinator.mojom.h" |
11 #include "components/memory_coordinator/common/memory_coordinator_features.h" | 11 #include "content/common/content_export.h" |
12 #include "components/memory_coordinator/public/interfaces/child_memory_coordinat or.mojom.h" | 12 #include "content/common/memory_coordinator.mojom.h" |
13 #include "components/memory_coordinator/public/interfaces/memory_coordinator.moj om.h" | |
14 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
15 | 14 |
16 namespace memory_coordinator { | 15 namespace content { |
17 | 16 |
18 class MEMORY_COORDINATOR_EXPORT ChildMemoryCoordinatorDelegate { | 17 class CONTENT_EXPORT ChildMemoryCoordinatorDelegate { |
19 public: | 18 public: |
20 virtual ~ChildMemoryCoordinatorDelegate() {} | 19 virtual ~ChildMemoryCoordinatorDelegate() {} |
21 | 20 |
22 // Called when the system requests immediate actions to free memory. | 21 // Called when the system requests immediate actions to free memory. |
23 virtual void OnTrimMemoryImmediately() = 0; | 22 virtual void OnTrimMemoryImmediately() = 0; |
24 }; | 23 }; |
25 | 24 |
26 // ChildMemoryCoordinatorImpl is the implementation of ChildMemoryCoordinator. | 25 // ChildMemoryCoordinatorImpl is the implementation of ChildMemoryCoordinator. |
27 // It lives in child processes and is responsible for dispatching memory events | 26 // It lives in child processes and is responsible for dispatching memory events |
28 // to its clients. | 27 // to its clients. |
29 class MEMORY_COORDINATOR_EXPORT ChildMemoryCoordinatorImpl | 28 class CONTENT_EXPORT ChildMemoryCoordinatorImpl |
30 : NON_EXPORTED_BASE(public mojom::ChildMemoryCoordinator) { | 29 : NON_EXPORTED_BASE(public mojom::ChildMemoryCoordinator) { |
31 public: | 30 public: |
32 // Returns the instance of ChildMemoryCoordinatorImpl. Could be nullptr. | 31 // Returns the instance of ChildMemoryCoordinatorImpl. Could be nullptr. |
33 static ChildMemoryCoordinatorImpl* GetInstance(); | 32 static ChildMemoryCoordinatorImpl* GetInstance(); |
34 | 33 |
35 ChildMemoryCoordinatorImpl(mojom::MemoryCoordinatorHandlePtr parent, | 34 ChildMemoryCoordinatorImpl(mojom::MemoryCoordinatorHandlePtr parent, |
36 ChildMemoryCoordinatorDelegate* delegate); | 35 ChildMemoryCoordinatorDelegate* delegate); |
37 ~ChildMemoryCoordinatorImpl() override; | 36 ~ChildMemoryCoordinatorImpl() override; |
38 | 37 |
39 // mojom::ChildMemoryCoordinator implementations: | 38 // mojom::ChildMemoryCoordinator implementations: |
40 void OnStateChange(mojom::MemoryState state) override; | 39 void OnStateChange(mojom::MemoryState state) override; |
41 | 40 |
42 protected: | 41 protected: |
43 ChildMemoryCoordinatorDelegate* delegate() { return delegate_; } | 42 ChildMemoryCoordinatorDelegate* delegate() { return delegate_; } |
44 | 43 |
45 private: | 44 private: |
46 friend class ChildMemoryCoordinatorImplTest; | 45 friend class ChildMemoryCoordinatorImplTest; |
47 | 46 |
48 mojo::Binding<mojom::ChildMemoryCoordinator> binding_; | 47 mojo::Binding<mojom::ChildMemoryCoordinator> binding_; |
49 mojom::MemoryCoordinatorHandlePtr parent_; | 48 mojom::MemoryCoordinatorHandlePtr parent_; |
50 ChildMemoryCoordinatorDelegate* delegate_; | 49 ChildMemoryCoordinatorDelegate* delegate_; |
51 | 50 |
52 DISALLOW_COPY_AND_ASSIGN(ChildMemoryCoordinatorImpl); | 51 DISALLOW_COPY_AND_ASSIGN(ChildMemoryCoordinatorImpl); |
53 }; | 52 }; |
54 | 53 |
55 // Factory function for creating a ChildMemoryCoordinator for the current | 54 // Factory function for creating a ChildMemoryCoordinator for the current |
56 // platform. Doesn't take the ownership of |delegate|. | 55 // platform. Doesn't take the ownership of |delegate|. |
57 MEMORY_COORDINATOR_EXPORT std::unique_ptr<ChildMemoryCoordinatorImpl> | 56 CONTENT_EXPORT std::unique_ptr<ChildMemoryCoordinatorImpl> |
58 CreateChildMemoryCoordinator(mojom::MemoryCoordinatorHandlePtr parent, | 57 CreateChildMemoryCoordinator(mojom::MemoryCoordinatorHandlePtr parent, |
59 ChildMemoryCoordinatorDelegate* delegate); | 58 ChildMemoryCoordinatorDelegate* delegate); |
60 | 59 |
61 } // namespace memory_coordinator | 60 } // namespace content |
62 | 61 |
63 #endif // COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_ | 62 #endif // CONTENT_CHILD_MEMORY_CHILD_MEMORY_COORDINATOR_IMPL_H_ |
OLD | NEW |