OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_TCMALLOC_INTERNALS_REQUEST_JOB_H_ |
| 6 #define CONTENT_BROWSER_TCMALLOC_INTERNALS_REQUEST_JOB_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/singleton.h" |
| 12 #include "base/process.h" |
| 13 #include "build/build_config.h" // USE_TCMALLOC |
| 14 #include "content/public/common/process_type.h" |
| 15 #include "net/url_request/url_request_simple_job.h" |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class AboutTcmallocOutputs { |
| 20 public: |
| 21 // Returns the singleton instance. |
| 22 static AboutTcmallocOutputs* GetInstance(); |
| 23 |
| 24 // Records the output for a specified header string. |
| 25 void SetOutput(const std::string& header, const std::string& output); |
| 26 |
| 27 void DumpToHTMLTable(std::string* data); |
| 28 |
| 29 // Callback for output returned from a child process. Adds |
| 30 // the output for a canonical process-specific header string that |
| 31 // incorporates the pid. |
| 32 void OnStatsForChildProcess(base::ProcessId pid, |
| 33 ProcessType process_type, |
| 34 const std::string& output); |
| 35 |
| 36 private: |
| 37 AboutTcmallocOutputs(); |
| 38 ~AboutTcmallocOutputs(); |
| 39 |
| 40 // A map of header strings (e.g. "Browser", "Renderer PID 123") |
| 41 // to the tcmalloc output collected for each process. |
| 42 typedef std::map<std::string, std::string> AboutTcmallocOutputsType; |
| 43 AboutTcmallocOutputsType outputs_; |
| 44 |
| 45 friend struct DefaultSingletonTraits<AboutTcmallocOutputs>; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(AboutTcmallocOutputs); |
| 48 }; |
| 49 |
| 50 class TcmallocInternalsRequestJob : public net::URLRequestSimpleJob { |
| 51 public: |
| 52 explicit TcmallocInternalsRequestJob(net::URLRequest* request); |
| 53 |
| 54 virtual bool GetData(std::string* mime_type, |
| 55 std::string* charset, |
| 56 std::string* data) const OVERRIDE; |
| 57 |
| 58 private: |
| 59 DISALLOW_IMPLICIT_CONSTRUCTORS(TcmallocInternalsRequestJob); |
| 60 }; |
| 61 |
| 62 } // namespace content |
| 63 |
| 64 #endif // CONTENT_BROWSER_TCMALLOC_INTERNALS_REQUEST_JOB_H_ |
OLD | NEW |