OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_COMMON_CHILD_PROCESS_INFO_H_ | 5 #ifndef CHROME_COMMON_CHILD_PROCESS_INFO_H_ |
6 #define CHROME_COMMON_CHILD_PROCESS_INFO_H_ | 6 #define CHROME_COMMON_CHILD_PROCESS_INFO_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 NACL_LOADER_PROCESS, | 25 NACL_LOADER_PROCESS, |
26 UTILITY_PROCESS, | 26 UTILITY_PROCESS, |
27 PROFILE_IMPORT_PROCESS, | 27 PROFILE_IMPORT_PROCESS, |
28 ZYGOTE_PROCESS, | 28 ZYGOTE_PROCESS, |
29 SANDBOX_HELPER_PROCESS, | 29 SANDBOX_HELPER_PROCESS, |
30 NACL_BROKER_PROCESS, | 30 NACL_BROKER_PROCESS, |
31 GPU_PROCESS, | 31 GPU_PROCESS, |
32 PPAPI_PLUGIN_PROCESS | 32 PPAPI_PLUGIN_PROCESS |
33 }; | 33 }; |
34 | 34 |
35 // NOTE: Do not remove or reorder the elements in this enum, and only add new | |
asargent_no_longer_on_chrome
2010/12/23 21:32:41
Consider adding a unit test that depends on the ex
Erik does not do reviews
2010/12/24 00:52:11
To document our offline conversation:
I agree in p
| |
36 // items at the end. We depend on these specific values in a histogram. | |
37 // TODO(erikkay) - other possibilities to include background contents, | |
38 // interstitials, ChromeOS UI, devtools, etc. | |
39 enum RendererProcessType { | |
40 RENDERER_UNKNOWN = 0, | |
41 RENDERER_NORMAL, | |
42 RENDERER_CHROME, | |
43 RENDERER_EXTENSION | |
44 }; | |
45 | |
35 ChildProcessInfo(const ChildProcessInfo& original); | 46 ChildProcessInfo(const ChildProcessInfo& original); |
36 virtual ~ChildProcessInfo(); | 47 virtual ~ChildProcessInfo(); |
37 | 48 |
38 ChildProcessInfo& operator=(const ChildProcessInfo& original); | 49 ChildProcessInfo& operator=(const ChildProcessInfo& original); |
39 | 50 |
40 // Returns the type of the process. | 51 // Returns the type of the process. |
41 ProcessType type() const { return type_; } | 52 ProcessType type() const { return type_; } |
53 RendererProcessType renderer_type() const { return renderer_type_; } | |
42 | 54 |
43 // Returns the name of the process. i.e. for plugins it might be Flash, while | 55 // Returns the name of the process. i.e. for plugins it might be Flash, while |
44 // for workers it might be the domain that it's from. | 56 // for workers it might be the domain that it's from. |
45 std::wstring name() const { return name_; } | 57 std::wstring name() const { return name_; } |
46 | 58 |
47 // Returns the version of the exe, this only appliest to plugins. Otherwise | 59 // Returns the version of the exe, this only appliest to plugins. Otherwise |
48 // the string is empty. | 60 // the string is empty. |
49 std::wstring version() const { return version_; } | 61 std::wstring version() const { return version_; } |
50 | 62 |
51 // Getter to the process handle. | 63 // Getter to the process handle. |
52 base::ProcessHandle handle() const { return process_.handle(); } | 64 base::ProcessHandle handle() const { return process_.handle(); } |
53 | 65 |
54 // The unique identifier for this child process. This identifier is NOT a | 66 // The unique identifier for this child process. This identifier is NOT a |
55 // process ID, and will be unique for all types of child process for | 67 // process ID, and will be unique for all types of child process for |
56 // one run of the browser. | 68 // one run of the browser. |
57 int id() const { return id_; } | 69 int id() const { return id_; } |
58 | 70 |
59 void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); } | 71 void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); } |
60 | 72 |
61 // Returns an English name of the process type, should only be used for non | 73 // Returns an English name of the process type, should only be used for non |
62 // user-visible strings, or debugging pages like about:memory. | 74 // user-visible strings, or debugging pages like about:memory. |
75 static std::string GetFullTypeNameInEnglish(ProcessType type, | |
76 RendererProcessType rtype); | |
63 static std::string GetTypeNameInEnglish(ProcessType type); | 77 static std::string GetTypeNameInEnglish(ProcessType type); |
78 static std::string GetRendererTypeNameInEnglish(RendererProcessType type); | |
64 | 79 |
65 // Returns a localized title for the child process. For example, a plugin | 80 // Returns a localized title for the child process. For example, a plugin |
66 // process would be "Plug-in: Flash" when name is "Flash". | 81 // process would be "Plug-in: Flash" when name is "Flash". |
67 string16 GetLocalizedTitle() const; | 82 string16 GetLocalizedTitle() const; |
68 | 83 |
69 // We define the < operator so that the ChildProcessInfo can be used as a key | 84 // We define the < operator so that the ChildProcessInfo can be used as a key |
70 // in a std::map. | 85 // in a std::map. |
71 bool operator <(const ChildProcessInfo& rhs) const { | 86 bool operator <(const ChildProcessInfo& rhs) const { |
72 if (process_.handle() != rhs.process_.handle()) | 87 if (process_.handle() != rhs.process_.handle()) |
73 return process_ .handle() < rhs.process_.handle(); | 88 return process_ .handle() < rhs.process_.handle(); |
(...skipping 18 matching lines...) Expand all Loading... | |
92 static int GenerateChildProcessUniqueId(); | 107 static int GenerateChildProcessUniqueId(); |
93 | 108 |
94 protected: | 109 protected: |
95 // Derived objects need to use this constructor so we know what type we are. | 110 // Derived objects need to use this constructor so we know what type we are. |
96 // If the caller has already generated a unique ID for this child process, | 111 // If the caller has already generated a unique ID for this child process, |
97 // it should pass it as the second argument. Otherwise, -1 should be passed | 112 // it should pass it as the second argument. Otherwise, -1 should be passed |
98 // and a unique ID will be automatically generated. | 113 // and a unique ID will be automatically generated. |
99 ChildProcessInfo(ProcessType type, int id); | 114 ChildProcessInfo(ProcessType type, int id); |
100 | 115 |
101 void set_type(ProcessType type) { type_ = type; } | 116 void set_type(ProcessType type) { type_ = type; } |
117 void set_renderer_type(RendererProcessType type) { renderer_type_ = type; } | |
102 void set_name(const std::wstring& name) { name_ = name; } | 118 void set_name(const std::wstring& name) { name_ = name; } |
103 void set_version(const std::wstring& ver) { version_ = ver; } | 119 void set_version(const std::wstring& ver) { version_ = ver; } |
104 void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); } | 120 void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); } |
105 | 121 |
106 private: | 122 private: |
107 ProcessType type_; | 123 ProcessType type_; |
124 RendererProcessType renderer_type_; | |
108 std::wstring name_; | 125 std::wstring name_; |
109 std::wstring version_; | 126 std::wstring version_; |
110 int id_; | 127 int id_; |
111 | 128 |
112 // The handle to the process. | 129 // The handle to the process. |
113 mutable base::Process process_; | 130 mutable base::Process process_; |
114 }; | 131 }; |
115 | 132 |
116 #endif // CHROME_COMMON_CHILD_PROCESS_INFO_H_ | 133 #endif // CHROME_COMMON_CHILD_PROCESS_INFO_H_ |
OLD | NEW |