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

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

Issue 2374343002: Add MemoryCoordinatorImpl (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
7
8 #include "base/memory/singleton.h"
9 #include "base/time/time.h"
10 #include "content/browser/memory/memory_coordinator.h"
11
12 namespace content {
13
14 class MemoryMonitor;
15 struct MemoryCoordinatorSingletonTraits;
16
17 class MemoryCoordinatorImpl : public MemoryCoordinator {
18 public:
19 explicit MemoryCoordinatorImpl(std::unique_ptr<MemoryMonitor> monitor);
20 ~MemoryCoordinatorImpl() override;
21
22 protected:
23 void OnChildAdded() override;
24 void OnChildRemoved() override;
25
26 private:
27 friend struct MemoryCoordinatorSingletonTraits;
28
29 // This struct holds some parameters to determine the global state.
30 struct Configuration {
31 int pressure_threshold_mb;
32 size_t num_children_until_suspended;
33 base::TimeDelta minimum_transition_period;
34 };
35
36 void UpdateState();
37 void NotifyStateToClients();
38 void NotifyStateToChildren();
39
40 using MemoryState = base::MemoryState;
41
42 std::unique_ptr<MemoryMonitor> memory_monitor_;
43 Configuration config_;
44 base::MemoryState current_state_ = MemoryState::NORMAL;
45 base::TimeTicks last_state_change_;
46
47 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl);
48 };
49
50 } // namespace content
51
52 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698