OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_ABOUT_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ |
6 #define CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ | 6 #define CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/process.h" | 13 #include "base/process.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "build/build_config.h" // USE_TCMALLOC | 15 #include "build/build_config.h" // USE_TCMALLOC |
| 16 #include "content/public/common/process_type.h" |
16 | 17 |
17 template <typename T> struct DefaultSingletonTraits; | 18 template <typename T> struct DefaultSingletonTraits; |
18 class GURL; | 19 class GURL; |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class BrowserContext; | 22 class BrowserContext; |
22 } | 23 } |
23 | 24 |
24 // Returns true if the given URL will be handled by the browser about handler. | 25 // Returns true if the given URL will be handled by the browser about handler. |
25 // Nowadays, these go through the webui, so the return is always false. | 26 // Nowadays, these go through the webui, so the return is always false. |
(...skipping 24 matching lines...) Expand all Loading... |
50 // Returns the singleton instance. | 51 // Returns the singleton instance. |
51 static AboutTcmallocOutputs* GetInstance(); | 52 static AboutTcmallocOutputs* GetInstance(); |
52 | 53 |
53 AboutTcmallocOutputsType* outputs() { return &outputs_; } | 54 AboutTcmallocOutputsType* outputs() { return &outputs_; } |
54 | 55 |
55 // Records the output for a specified header string. | 56 // Records the output for a specified header string. |
56 void SetOutput(const std::string& header, const std::string& output) { | 57 void SetOutput(const std::string& header, const std::string& output) { |
57 outputs_[header] = output; | 58 outputs_[header] = output; |
58 } | 59 } |
59 | 60 |
60 // Callback for output returned from renderer processes. Adds | 61 // Callback for output returned from a child process. Adds |
61 // the output for a canonical renderer header string that | 62 // the output for a canonical process-specific header string that |
62 // incorporates the pid. | 63 // incorporates the pid. |
63 void RendererCallback(base::ProcessId pid, const std::string& output) { | 64 void OnStatsForChildProcess(base::ProcessId pid, |
64 SetOutput( | 65 content::ProcessType process_type, |
65 base::StringPrintf("Renderer PID %d", static_cast<int>(pid)), output); | 66 const std::string& output); |
66 } | |
67 | 67 |
68 private: | 68 private: |
69 AboutTcmallocOutputs(); | 69 AboutTcmallocOutputs(); |
70 ~AboutTcmallocOutputs(); | 70 ~AboutTcmallocOutputs(); |
71 | 71 |
72 AboutTcmallocOutputsType outputs_; | 72 AboutTcmallocOutputsType outputs_; |
73 | 73 |
74 friend struct DefaultSingletonTraits<AboutTcmallocOutputs>; | 74 friend struct DefaultSingletonTraits<AboutTcmallocOutputs>; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(AboutTcmallocOutputs); | 76 DISALLOW_COPY_AND_ASSIGN(AboutTcmallocOutputs); |
77 }; | 77 }; |
78 | |
79 // Glue between the callback task and the method in the singleton. | |
80 void AboutTcmallocRendererCallback(base::ProcessId pid, | |
81 const std::string& output); | |
82 #endif // defined(USE_TCMALLOC) | 78 #endif // defined(USE_TCMALLOC) |
83 | 79 |
84 #endif // CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ | 80 #endif // CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ |
OLD | NEW |