summaryrefslogtreecommitdiffstats
path: root/chrome/common/child_process_info.h
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 23:55:10 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-11 23:55:10 +0000
commita27a938d8511abfaf89d6e2d0e4d4242c76dffed (patch)
tree98b133536459106b96a0ee09e0deb94b8d92c4b3 /chrome/common/child_process_info.h
parent342c2c40bd1729fe985d5a6ee06f6eb28bbcdc22 (diff)
downloadchromium_src-a27a938d8511abfaf89d6e2d0e4d4242c76dffed.zip
chromium_src-a27a938d8511abfaf89d6e2d0e4d4242c76dffed.tar.gz
chromium_src-a27a938d8511abfaf89d6e2d0e4d4242c76dffed.tar.bz2
Refactor plugin process code in the browser process so that the browser/about:memory/task manager/metrics code doesn't depend on PluginProcessHost pointers. In a future changelist I'll add one central child process registry in the browser process.
Review URL: http://codereview.chromium.org/20196 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/child_process_info.h')
-rw-r--r--chrome/common/child_process_info.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/chrome/common/child_process_info.h b/chrome/common/child_process_info.h
new file mode 100644
index 0000000..2007bcb
--- /dev/null
+++ b/chrome/common/child_process_info.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_CHILD_PROCESS_INFO_H_
+#define CHROME_COMMON_CHILD_PROCESS_INFO_H_
+
+#include <string>
+#include "base/basictypes.h"
+#include "base/process.h"
+
+// Holds information about a child process.
+class ChildProcessInfo {
+ public:
+ enum ProcessType {
+ BROWSER_PROCESS,
+ RENDER_PROCESS,
+ PLUGIN_PROCESS,
+ WORKER_PROCESS,
+ UNKNOWN_PROCESS,
+ };
+
+ // Returns the type of the process.
+ ProcessType type() const { return type_; }
+
+ // Returns the name of the process. i.e. for plugins it might be Flash, while
+ // for workers it might be the domain that it's from.
+ std::wstring name() const { return name_; }
+
+ // Getter to the process.
+ base::Process& process() { return process_; }
+
+ // Returns an English name of the process type, should only be used for non
+ // user-visible strings, or debugging pages like about:memory.
+ static std::wstring GetTypeNameInEnglish(ProcessType type);
+
+ // Returns a localized title for the child process. For example, a plugin
+ // process would be "Plug-in: Flash" when name is "Flash".
+ std::wstring GetLocalizedTitle() const;
+
+ // We define the < operator so that the ChildProcessInfo can be used as a key
+ // in a std::map.
+ bool operator <(const ChildProcessInfo& rhs) const {
+ if (process_.handle() != rhs.process_.handle())
+ return process_ .handle() < rhs.process_.handle();
+ return name_ < rhs.name_;
+ }
+
+ bool operator ==(const ChildProcessInfo& rhs) const {
+ return (process_.handle() == rhs.process_.handle()) && (name_ == rhs.name_);
+ }
+
+ protected:
+ void set_type(ProcessType type) { type_ = type; }
+ void set_name(const std::wstring& name) { name_ = name; }
+
+ private:
+ ProcessType type_;
+ std::wstring name_;
+
+ // The handle to the process.
+ base::Process process_;
+};
+
+#endif // CHROME_COMMON_CHILD_PROCESS_INFO_H_
+