Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: content/browser/memory/memory_coordinator_impl.h

Issue 2703743002: Refactor MemoryCoordinatorProxy (Closed)
Patch Set: Remove atomics Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/memory/memory_coordinator_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/memory_coordinator_client.h" 9 #include "base/memory/memory_coordinator_client.h"
10 #include "base/memory/memory_coordinator_proxy.h"
10 #include "base/memory/memory_pressure_monitor.h" 11 #include "base/memory/memory_pressure_monitor.h"
11 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
16 #include "content/common/memory_coordinator.mojom.h" 17 #include "content/common/memory_coordinator.mojom.h"
17 #include "content/public/browser/memory_coordinator.h" 18 #include "content/public/browser/memory_coordinator.h"
18 #include "content/public/browser/memory_coordinator_delegate.h" 19 #include "content/public/browser/memory_coordinator_delegate.h"
19 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
21 22
22 namespace content { 23 namespace content {
23 24
24 // NOTE: Memory coordinator is under development and not fully working. 25 // NOTE: Memory coordinator is under development and not fully working.
25 26
26 class MemoryCoordinatorHandleImpl; 27 class MemoryCoordinatorHandleImpl;
27 class MemoryCoordinatorImplTest; 28 class MemoryCoordinatorImplTest;
28 class MemoryMonitor; 29 class MemoryMonitor;
29 class MemoryStateUpdater; 30 class MemoryStateUpdater;
30 class RenderProcessHost; 31 class RenderProcessHost;
31 struct MemoryCoordinatorSingletonTraits; 32 struct MemoryCoordinatorSingletonTraits;
32 33
33 // MemoryCoordinatorImpl is an implementation of MemoryCoordinator. 34 // MemoryCoordinatorImpl is an implementation of MemoryCoordinator.
34 // The current implementation uses MemoryStateUpdater to update the global 35 // The current implementation uses MemoryStateUpdater to update the global
35 // memory state. See comments in MemoryStateUpdater for details. 36 // memory state. See comments in MemoryStateUpdater for details.
36 class CONTENT_EXPORT MemoryCoordinatorImpl : public MemoryCoordinator, 37 class CONTENT_EXPORT MemoryCoordinatorImpl : public base::MemoryCoordinator,
38 public MemoryCoordinator,
37 public NotificationObserver, 39 public NotificationObserver,
38 public base::NonThreadSafe { 40 public base::NonThreadSafe {
39 public: 41 public:
40 using MemoryState = base::MemoryState; 42 using MemoryState = base::MemoryState;
41 43
42 static MemoryCoordinatorImpl* GetInstance(); 44 static MemoryCoordinatorImpl* GetInstance();
43 45
44 MemoryCoordinatorImpl(scoped_refptr<base::SingleThreadTaskRunner> task_runner, 46 MemoryCoordinatorImpl(scoped_refptr<base::SingleThreadTaskRunner> task_runner,
45 std::unique_ptr<MemoryMonitor> monitor); 47 std::unique_ptr<MemoryMonitor> monitor);
46 ~MemoryCoordinatorImpl() override; 48 ~MemoryCoordinatorImpl() override;
(...skipping 21 matching lines...) Expand all
68 // TODO(bashi): Remove this when MemoryPressureMonitor is retired. 70 // TODO(bashi): Remove this when MemoryPressureMonitor is retired.
69 void RecordMemoryPressure( 71 void RecordMemoryPressure(
70 base::MemoryPressureMonitor::MemoryPressureLevel level); 72 base::MemoryPressureMonitor::MemoryPressureLevel level);
71 73
72 // Returns the global memory state. 74 // Returns the global memory state.
73 virtual MemoryState GetGlobalMemoryState() const; 75 virtual MemoryState GetGlobalMemoryState() const;
74 76
75 // Returns the browser's current memory state. Note that the current state 77 // Returns the browser's current memory state. Note that the current state
76 // could be different from the global memory state as the browser won't be 78 // could be different from the global memory state as the browser won't be
77 // suspended. 79 // suspended.
78 MemoryState GetCurrentMemoryState() const; 80 MemoryState GetCurrentMemoryState() const override;
79 81
80 // Sets the global memory state for testing. 82 // Sets the global memory state for testing.
81 void SetCurrentMemoryStateForTesting(MemoryState memory_state); 83 void SetCurrentMemoryStateForTesting(MemoryState memory_state) override;
82 84
83 // MemoryCoordinator implementation: 85 // MemoryCoordinator implementation:
84 MemoryState GetStateForProcess(base::ProcessHandle handle) override; 86 MemoryState GetStateForProcess(base::ProcessHandle handle) override;
85 87
86 // NotificationObserver implementation: 88 // NotificationObserver implementation:
87 void Observe(int type, 89 void Observe(int type,
88 const NotificationSource& source, 90 const NotificationSource& source,
89 const NotificationDetails& details) override; 91 const NotificationDetails& details) override;
90 92
91 // Overrides the global state to |new_state|. State update tasks won't be 93 // Overrides the global state to |new_state|. State update tasks won't be
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // MemoryCoordinator and removed automatically when an underlying binding is 192 // MemoryCoordinator and removed automatically when an underlying binding is
191 // disconnected. 193 // disconnected.
192 ChildInfoMap children_; 194 ChildInfoMap children_;
193 195
194 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); 196 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl);
195 }; 197 };
196 198
197 } // namespace content 199 } // namespace content
198 200
199 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ 201 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/browser/memory/memory_coordinator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698