OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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_PROCESS_RESOURCE_USAGE_IMPL_H_ | |
6 #define CONTENT_BROWSER_PROCESS_RESOURCE_USAGE_IMPL_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/message_loop/message_loop_proxy.h" | |
12 #include "base/synchronization/lock.h" | |
13 #include "content/public/browser/process_resource_usage.h" | |
14 #include "content/public/common/resource_usage_reporter.mojom.h" | |
15 | |
16 namespace content { | |
17 | |
ncarter (slow)
2015/05/01 21:16:52
Could you add a class comment that tries to answer
Anand Mistry (off Chromium)
2015/05/06 02:44:18
Expanded the class comment for the public interfac
ncarter (slow)
2015/05/07 20:12:43
Makes sense, thank you.
| |
18 class CONTENT_EXPORT ProcessResourceUsageImpl : public ProcessResourceUsage { | |
19 public: | |
20 // Must be called from the same thread that created |service|. | |
21 explicit ProcessResourceUsageImpl(ResourceUsageReporterPtr service); | |
22 | |
23 // ProcessResourceUsage implementation. May be called from any thread. | |
24 void Refresh() override; | |
25 bool ReportsV8MemoryStats() const override; | |
26 size_t GetV8MemoryAllocated() const override; | |
27 size_t GetV8MemoryUsed() const override; | |
28 | |
29 private: | |
30 class Client; | |
31 | |
32 ~ProcessResourceUsageImpl() override; | |
33 | |
34 // Data refresh callback. Will be run on |mojo_message_loop_|. | |
35 void OnRefreshDone(ResourceUsageDataPtr data); | |
36 | |
37 // Accessed on any thread. | |
38 mutable base::Lock lock_; | |
ncarter (slow)
2015/05/01 21:16:52
What would this look like if we used PostTask inst
Anand Mistry (off Chromium)
2015/05/06 02:44:18
Done. It's cleaner, but requires some passing arou
| |
39 ResourceUsageDataPtr stats_; | |
40 | |
41 // Message loop the Mojo service is tied to. Mojo interfaces are | |
42 // thread-hostile and must always be accessed from the same thread. | |
43 scoped_refptr<base::MessageLoopProxy> mojo_message_loop_; | |
ncarter (slow)
2015/05/01 21:16:52
This is my first time looking at code that uses mo
Anand Mistry (off Chromium)
2015/05/05 04:11:21
Mojo hides all the IPC details, but it still expos
| |
44 | |
45 // All methods must be posted to |mojo_message_loop_|. | |
46 base::WeakPtr<Client> client_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(ProcessResourceUsageImpl); | |
49 }; | |
50 | |
51 } // namespace content | |
52 | |
53 #endif // CONTENT_BROWSER_PROCESS_RESOURCE_USAGE_IMPL_H_ | |
OLD | NEW |