OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/tcmalloc_internals_request_job.h" | 5 #include "content/browser/tcmalloc_internals_request_job.h" |
6 | 6 |
| 7 #include "base/allocator/allocator_extension.h" |
7 #include "content/common/child_process_messages.h" | 8 #include "content/common/child_process_messages.h" |
8 #include "content/public/browser/browser_child_process_host_iterator.h" | 9 #include "content/public/browser/browser_child_process_host_iterator.h" |
9 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
11 #include "content/public/common/process_type.h" | 12 #include "content/public/common/process_type.h" |
12 | 13 |
13 #if defined(USE_TCMALLOC) | |
14 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" | |
15 #endif | |
16 | |
17 namespace content { | 14 namespace content { |
18 | 15 |
19 // static | 16 // static |
20 AboutTcmallocOutputs* AboutTcmallocOutputs::GetInstance() { | 17 AboutTcmallocOutputs* AboutTcmallocOutputs::GetInstance() { |
21 return Singleton<AboutTcmallocOutputs>::get(); | 18 return Singleton<AboutTcmallocOutputs>::get(); |
22 } | 19 } |
23 | 20 |
24 AboutTcmallocOutputs::AboutTcmallocOutputs() {} | 21 AboutTcmallocOutputs::AboutTcmallocOutputs() {} |
25 | 22 |
26 AboutTcmallocOutputs::~AboutTcmallocOutputs() {} | 23 AboutTcmallocOutputs::~AboutTcmallocOutputs() {} |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 data->append("reload to get stats as of this page load.</p>\n"); | 78 data->append("reload to get stats as of this page load.</p>\n"); |
82 data->append("<table width=\"100%\">\n"); | 79 data->append("<table width=\"100%\">\n"); |
83 | 80 |
84 AboutTcmallocOutputs::GetInstance()->DumpToHTMLTable(data); | 81 AboutTcmallocOutputs::GetInstance()->DumpToHTMLTable(data); |
85 | 82 |
86 data->append("</body></html>\n"); | 83 data->append("</body></html>\n"); |
87 | 84 |
88 // Populate the collector with stats from the local browser process | 85 // Populate the collector with stats from the local browser process |
89 // and send off requests to all the renderer processes. | 86 // and send off requests to all the renderer processes. |
90 char buffer[1024 * 32]; | 87 char buffer[1024 * 32]; |
91 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); | 88 base::allocator::GetStats(buffer, sizeof(buffer)); |
92 std::string browser("Browser"); | 89 std::string browser("Browser"); |
93 AboutTcmallocOutputs::GetInstance()->SetOutput(browser, buffer); | 90 AboutTcmallocOutputs::GetInstance()->SetOutput(browser, buffer); |
94 | 91 |
95 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 92 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
96 iter.Send(new ChildProcessMsg_GetTcmallocStats); | 93 iter.Send(new ChildProcessMsg_GetTcmallocStats); |
97 } | 94 } |
98 | 95 |
99 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 96 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
100 &RequestTcmallocStatsFromChildRenderProcesses)); | 97 &RequestTcmallocStatsFromChildRenderProcesses)); |
101 } | 98 } |
102 #endif | 99 #endif |
103 | 100 |
104 bool TcmallocInternalsRequestJob::GetData(std::string* mime_type, | 101 bool TcmallocInternalsRequestJob::GetData(std::string* mime_type, |
105 std::string* charset, | 102 std::string* charset, |
106 std::string* data) const { | 103 std::string* data) const { |
107 mime_type->assign("text/html"); | 104 mime_type->assign("text/html"); |
108 charset->assign("UTF8"); | 105 charset->assign("UTF8"); |
109 | 106 |
110 data->clear(); | 107 data->clear(); |
111 #if defined(USE_TCMALLOC) | 108 #if defined(USE_TCMALLOC) |
112 AboutTcmalloc(data); | 109 AboutTcmalloc(data); |
113 #endif | 110 #endif |
114 return true; | 111 return true; |
115 } | 112 } |
116 | 113 |
117 } // namespace content | 114 } // namespace content |
OLD | NEW |