| 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 |
| 36 // items at the end. We depend on these specific values in a histogram. |
| 37 enum RendererProcessType { |
| 38 RENDERER_UNKNOWN = 0, |
| 39 RENDERER_NORMAL, |
| 40 RENDERER_CHROME, // DOMUI (chrome:// URL) |
| 41 RENDERER_EXTENSION, // chrome-extension:// |
| 42 RENDERER_DEVTOOLS, // Web inspector |
| 43 RENDERER_INTERSTITIAL, // malware/phishing interstitial |
| 44 RENDERER_NOTIFICATION, // HTML notification bubble |
| 45 RENDERER_BACKGROUND_APP // hosted app background page |
| 46 }; |
| 47 |
| 35 ChildProcessInfo(const ChildProcessInfo& original); | 48 ChildProcessInfo(const ChildProcessInfo& original); |
| 36 virtual ~ChildProcessInfo(); | 49 virtual ~ChildProcessInfo(); |
| 37 | 50 |
| 38 ChildProcessInfo& operator=(const ChildProcessInfo& original); | 51 ChildProcessInfo& operator=(const ChildProcessInfo& original); |
| 39 | 52 |
| 40 // Returns the type of the process. | 53 // Returns the type of the process. |
| 41 ProcessType type() const { return type_; } | 54 ProcessType type() const { return type_; } |
| 42 | 55 |
| 56 // Returns the renderer subtype of this process. |
| 57 // Only valid if the type() is RENDER_PROCESS. |
| 58 RendererProcessType renderer_type() const { return renderer_type_; } |
| 59 |
| 43 // Returns the name of the process. i.e. for plugins it might be Flash, while | 60 // 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. | 61 // for workers it might be the domain that it's from. |
| 45 std::wstring name() const { return name_; } | 62 std::wstring name() const { return name_; } |
| 46 | 63 |
| 47 // Returns the version of the exe, this only appliest to plugins. Otherwise | 64 // Returns the version of the exe, this only appliest to plugins. Otherwise |
| 48 // the string is empty. | 65 // the string is empty. |
| 49 std::wstring version() const { return version_; } | 66 std::wstring version() const { return version_; } |
| 50 | 67 |
| 51 // Getter to the process handle. | 68 // Getter to the process handle. |
| 52 base::ProcessHandle handle() const { return process_.handle(); } | 69 base::ProcessHandle handle() const { return process_.handle(); } |
| 53 | 70 |
| 54 // The unique identifier for this child process. This identifier is NOT a | 71 // 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 | 72 // process ID, and will be unique for all types of child process for |
| 56 // one run of the browser. | 73 // one run of the browser. |
| 57 int id() const { return id_; } | 74 int id() const { return id_; } |
| 58 | 75 |
| 59 void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); } | 76 void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); } |
| 60 | 77 |
| 61 // Returns an English name of the process type, should only be used for non | 78 // Returns an English name of the process type, should only be used for non |
| 62 // user-visible strings, or debugging pages like about:memory. | 79 // user-visible strings, or debugging pages like about:memory. |
| 80 static std::string GetFullTypeNameInEnglish(ProcessType type, |
| 81 RendererProcessType rtype); |
| 63 static std::string GetTypeNameInEnglish(ProcessType type); | 82 static std::string GetTypeNameInEnglish(ProcessType type); |
| 83 static std::string GetRendererTypeNameInEnglish(RendererProcessType type); |
| 64 | 84 |
| 65 // Returns a localized title for the child process. For example, a plugin | 85 // Returns a localized title for the child process. For example, a plugin |
| 66 // process would be "Plug-in: Flash" when name is "Flash". | 86 // process would be "Plug-in: Flash" when name is "Flash". |
| 67 string16 GetLocalizedTitle() const; | 87 string16 GetLocalizedTitle() const; |
| 68 | 88 |
| 69 // We define the < operator so that the ChildProcessInfo can be used as a key | 89 // We define the < operator so that the ChildProcessInfo can be used as a key |
| 70 // in a std::map. | 90 // in a std::map. |
| 71 bool operator <(const ChildProcessInfo& rhs) const { | 91 bool operator <(const ChildProcessInfo& rhs) const { |
| 72 if (process_.handle() != rhs.process_.handle()) | 92 if (process_.handle() != rhs.process_.handle()) |
| 73 return process_ .handle() < rhs.process_.handle(); | 93 return process_ .handle() < rhs.process_.handle(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 92 static int GenerateChildProcessUniqueId(); | 112 static int GenerateChildProcessUniqueId(); |
| 93 | 113 |
| 94 protected: | 114 protected: |
| 95 // Derived objects need to use this constructor so we know what type we are. | 115 // 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, | 116 // 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 | 117 // it should pass it as the second argument. Otherwise, -1 should be passed |
| 98 // and a unique ID will be automatically generated. | 118 // and a unique ID will be automatically generated. |
| 99 ChildProcessInfo(ProcessType type, int id); | 119 ChildProcessInfo(ProcessType type, int id); |
| 100 | 120 |
| 101 void set_type(ProcessType type) { type_ = type; } | 121 void set_type(ProcessType type) { type_ = type; } |
| 122 void set_renderer_type(RendererProcessType type) { renderer_type_ = type; } |
| 102 void set_name(const std::wstring& name) { name_ = name; } | 123 void set_name(const std::wstring& name) { name_ = name; } |
| 103 void set_version(const std::wstring& ver) { version_ = ver; } | 124 void set_version(const std::wstring& ver) { version_ = ver; } |
| 104 void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); } | 125 void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); } |
| 105 | 126 |
| 106 private: | 127 private: |
| 107 ProcessType type_; | 128 ProcessType type_; |
| 129 RendererProcessType renderer_type_; |
| 108 std::wstring name_; | 130 std::wstring name_; |
| 109 std::wstring version_; | 131 std::wstring version_; |
| 110 int id_; | 132 int id_; |
| 111 | 133 |
| 112 // The handle to the process. | 134 // The handle to the process. |
| 113 mutable base::Process process_; | 135 mutable base::Process process_; |
| 114 }; | 136 }; |
| 115 | 137 |
| 116 #endif // CHROME_COMMON_CHILD_PROCESS_INFO_H_ | 138 #endif // CHROME_COMMON_CHILD_PROCESS_INFO_H_ |
| OLD | NEW |