Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: chrome/common/child_process_info.h

Issue 6612040: Move ChildProcessHost and ChildProcessInfo to content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/child_process_host.cc ('k') | chrome/common/child_process_info.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 CHROME_COMMON_CHILD_PROCESS_INFO_H_
6 #define CHROME_COMMON_CHILD_PROCESS_INFO_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/process.h"
12 #include "base/string16.h"
13
14 // Holds information about a child process.
15 class ChildProcessInfo {
16 public:
17 // NOTE: Do not remove or reorder the elements in this enum, and only add new
18 // items at the end. We depend on these specific values in a histogram.
19 enum ProcessType {
20 UNKNOWN_PROCESS = 1,
21 BROWSER_PROCESS,
22 RENDER_PROCESS,
23 PLUGIN_PROCESS,
24 WORKER_PROCESS,
25 NACL_LOADER_PROCESS,
26 UTILITY_PROCESS,
27 PROFILE_IMPORT_PROCESS,
28 ZYGOTE_PROCESS,
29 SANDBOX_HELPER_PROCESS,
30 NACL_BROKER_PROCESS,
31 GPU_PROCESS,
32 PPAPI_PLUGIN_PROCESS
33 };
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, // WebUI (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
48 ChildProcessInfo(const ChildProcessInfo& original);
49 virtual ~ChildProcessInfo();
50
51 ChildProcessInfo& operator=(const ChildProcessInfo& original);
52
53 // Returns the type of the process.
54 ProcessType type() const { return type_; }
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
60 // Returns the name of the process. i.e. for plugins it might be Flash, while
61 // for workers it might be the domain that it's from.
62 std::wstring name() const { return name_; }
63
64 // Returns the version of the exe, this only appliest to plugins. Otherwise
65 // the string is empty.
66 std::wstring version() const { return version_; }
67
68 // Getter to the process handle.
69 base::ProcessHandle handle() const { return process_.handle(); }
70
71 // Getter to the process ID.
72 int pid() const { return process_.pid(); }
73
74 // The unique identifier for this child process. This identifier is NOT a
75 // process ID, and will be unique for all types of child process for
76 // one run of the browser.
77 int id() const { return id_; }
78
79 void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); }
80
81 // Returns an English name of the process type, should only be used for non
82 // user-visible strings, or debugging pages like about:memory.
83 static std::string GetFullTypeNameInEnglish(ProcessType type,
84 RendererProcessType rtype);
85 static std::string GetTypeNameInEnglish(ProcessType type);
86 static std::string GetRendererTypeNameInEnglish(RendererProcessType type);
87
88 // Returns a localized title for the child process. For example, a plugin
89 // process would be "Plug-in: Flash" when name is "Flash".
90 string16 GetLocalizedTitle() const;
91
92 // We define the < operator so that the ChildProcessInfo can be used as a key
93 // in a std::map.
94 bool operator <(const ChildProcessInfo& rhs) const {
95 if (process_.handle() != rhs.process_.handle())
96 return process_ .handle() < rhs.process_.handle();
97 return false;
98 }
99
100 bool operator ==(const ChildProcessInfo& rhs) const {
101 return process_.handle() == rhs.process_.handle();
102 }
103
104 // Generates a unique channel name for a child renderer/plugin process.
105 // The "instance" pointer value is baked into the channel id.
106 static std::string GenerateRandomChannelID(void* instance);
107
108 // Returns a unique ID to identify a child process. On construction, this
109 // function will be used to generate the id_, but it is also used to generate
110 // IDs for the RenderProcessHost, which doesn't inherit from us, and whose IDs
111 // must be unique for all child processes.
112 //
113 // This function is threadsafe since RenderProcessHost is on the UI thread,
114 // but normally this will be used on the IO thread.
115 static int GenerateChildProcessUniqueId();
116
117 protected:
118 // Derived objects need to use this constructor so we know what type we are.
119 // If the caller has already generated a unique ID for this child process,
120 // it should pass it as the second argument. Otherwise, -1 should be passed
121 // and a unique ID will be automatically generated.
122 ChildProcessInfo(ProcessType type, int id);
123
124 void set_type(ProcessType type) { type_ = type; }
125 void set_renderer_type(RendererProcessType type) { renderer_type_ = type; }
126 void set_name(const std::wstring& name) { name_ = name; }
127 void set_version(const std::wstring& ver) { version_ = ver; }
128 void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); }
129
130 private:
131 ProcessType type_;
132 RendererProcessType renderer_type_;
133 std::wstring name_;
134 std::wstring version_;
135 int id_;
136
137 // The handle to the process.
138 mutable base::Process process_;
139 };
140
141 #endif // CHROME_COMMON_CHILD_PROCESS_INFO_H_
OLDNEW
« no previous file with comments | « chrome/common/child_process_host.cc ('k') | chrome/common/child_process_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698