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

Side by Side Diff: chrome/browser/task_manager/sampling/shared_sampler.h

Issue 2238403003: Task manager: Get physical memory efficiently for all processes from SharedSampler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 4 years, 3 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 | « no previous file | chrome/browser/task_manager/sampling/shared_sampler_posix.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 CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_H_ 5 #ifndef CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_H_ 6 #define CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 // some types like Idle Wakeups can only be collected this way. 33 // some types like Idle Wakeups can only be collected this way.
34 class SharedSampler : public base::RefCountedThreadSafe<SharedSampler> { 34 class SharedSampler : public base::RefCountedThreadSafe<SharedSampler> {
35 public: 35 public:
36 explicit SharedSampler( 36 explicit SharedSampler(
37 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner); 37 const scoped_refptr<base::SequencedTaskRunner>& blocking_pool_runner);
38 38
39 // Below are the types of callbacks that are invoked on the UI thread 39 // Below are the types of callbacks that are invoked on the UI thread
40 // when the refresh is done on the worker thread. 40 // when the refresh is done on the worker thread.
41 // These callbacks are passed via RegisterCallbacks. 41 // These callbacks are passed via RegisterCallbacks.
42 using OnIdleWakeupsCallback = base::Callback<void(int)>; 42 using OnIdleWakeupsCallback = base::Callback<void(int)>;
43 using OnPhysicalMemoryCallback = base::Callback<void(int64_t)>;
43 44
44 // Returns a combination of refresh flags supported by the shared sampler. 45 // Returns a combination of refresh flags supported by the shared sampler.
45 int64_t GetSupportedFlags() const; 46 int64_t GetSupportedFlags() const;
46 47
47 // Registers task group specific callbacks. 48 // Registers task group specific callbacks.
48 void RegisterCallbacks(base::ProcessId process_id, 49 void RegisterCallbacks(base::ProcessId process_id,
49 const OnIdleWakeupsCallback& on_idle_wakeups); 50 const OnIdleWakeupsCallback& on_idle_wakeups,
51 const OnPhysicalMemoryCallback& on_physical_memory);
50 52
51 // Unregisters task group specific callbacks. 53 // Unregisters task group specific callbacks.
52 void UnregisterCallbacks(base::ProcessId process_id); 54 void UnregisterCallbacks(base::ProcessId process_id);
53 55
54 // Refreshes the expensive process' stats (for now only idle wakeups per 56 // Refreshes the expensive process' stats (for now only idle wakeups per
55 // second) on the worker thread. 57 // second) on the worker thread.
56 void Refresh(base::ProcessId process_id, int64_t refresh_flags); 58 void Refresh(base::ProcessId process_id, int64_t refresh_flags);
57 59
58 private: 60 private:
59 friend class base::RefCountedThreadSafe<SharedSampler>; 61 friend class base::RefCountedThreadSafe<SharedSampler>;
60 ~SharedSampler(); 62 ~SharedSampler();
61 63
62 #if defined(OS_WIN) 64 #if defined(OS_WIN)
63 // The UI-thread callbacks in TaskGroup registered with RegisterCallbacks and 65 // The UI-thread callbacks in TaskGroup registered with RegisterCallbacks and
64 // to be called when refresh on the worker thread is done. 66 // to be called when refresh on the worker thread is done.
65 struct Callbacks { 67 struct Callbacks {
66 Callbacks(); 68 Callbacks();
67 Callbacks(Callbacks&& other); 69 Callbacks(Callbacks&& other);
68 ~Callbacks(); 70 ~Callbacks();
69 71
70 OnIdleWakeupsCallback on_idle_wakeups; 72 OnIdleWakeupsCallback on_idle_wakeups;
73 OnPhysicalMemoryCallback on_physical_memory;
71 74
72 private: 75 private:
73 DISALLOW_COPY_AND_ASSIGN(Callbacks); 76 DISALLOW_COPY_AND_ASSIGN(Callbacks);
74 }; 77 };
75 78
76 typedef std::map<base::ProcessId, Callbacks> CallbacksMap; 79 typedef std::map<base::ProcessId, Callbacks> CallbacksMap;
77 80
78 // Contains all results of refresh for a single process. 81 // Contains all results of refresh for a single process.
79 struct RefreshResult { 82 struct RefreshResult {
80 base::ProcessId process_id; 83 base::ProcessId process_id;
81 int idle_wakeups_per_second; 84 int idle_wakeups_per_second;
85 int64_t physical_bytes;
82 }; 86 };
83 87
84 typedef std::vector<RefreshResult> RefreshResults; 88 typedef std::vector<RefreshResult> RefreshResults;
85 89
86 // Posted on the worker thread to do the actual refresh. 90 // Posted on the worker thread to do the actual refresh.
87 std::unique_ptr<RefreshResults> RefreshOnWorkerThread(); 91 std::unique_ptr<RefreshResults> RefreshOnWorkerThread();
88 92
89 // Called on UI thread when the refresh is done. 93 // Called on UI thread when the refresh is done.
90 void OnRefreshDone(std::unique_ptr<RefreshResults> refresh_results); 94 void OnRefreshDone(std::unique_ptr<RefreshResults> refresh_results);
91 95
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // To assert we're running on the correct thread. 139 // To assert we're running on the correct thread.
136 base::SequenceChecker worker_pool_sequenced_checker_; 140 base::SequenceChecker worker_pool_sequenced_checker_;
137 #endif // defined(OS_WIN) 141 #endif // defined(OS_WIN)
138 142
139 DISALLOW_COPY_AND_ASSIGN(SharedSampler); 143 DISALLOW_COPY_AND_ASSIGN(SharedSampler);
140 }; 144 };
141 145
142 } // namespace task_manager 146 } // namespace task_manager
143 147
144 #endif // CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_H_ 148 #endif // CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/task_manager/sampling/shared_sampler_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698