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

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

Issue 8760011: Move the ProcessType enum out to its own file. This is in preparation for getting rid of ChildPro... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 9 years 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 | « content/browser/worker_host/worker_service.cc ('k') | content/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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 CONTENT_COMMON_CHILD_PROCESS_INFO_H_ 5 #ifndef CONTENT_COMMON_CHILD_PROCESS_INFO_H_
6 #define CONTENT_COMMON_CHILD_PROCESS_INFO_H_ 6 #define CONTENT_COMMON_CHILD_PROCESS_INFO_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/process.h" 11 #include "base/process.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/public/common/process_type.h"
14 15
15 // Holds information about a child process. 16 // Holds information about a child process.
16 class CONTENT_EXPORT ChildProcessInfo { 17 class CONTENT_EXPORT ChildProcessInfo {
17 public: 18 public:
18 // NOTE: Do not remove or reorder the elements in this enum, and only add new
19 // items at the end, right before MAX_PROCESS. We depend on these specific
20 // values in histograms.
21 enum ProcessType {
22 UNKNOWN_PROCESS = 1,
23 BROWSER_PROCESS,
24 RENDER_PROCESS,
25 PLUGIN_PROCESS,
26 WORKER_PROCESS,
27 NACL_LOADER_PROCESS,
28 UTILITY_PROCESS,
29 PROFILE_IMPORT_PROCESS,
30 ZYGOTE_PROCESS,
31 SANDBOX_HELPER_PROCESS,
32 NACL_BROKER_PROCESS,
33 GPU_PROCESS,
34 PPAPI_PLUGIN_PROCESS,
35 PPAPI_BROKER_PROCESS,
36 MAX_PROCESS
37 };
38
39 ChildProcessInfo(const ChildProcessInfo& original); 19 ChildProcessInfo(const ChildProcessInfo& original);
40 virtual ~ChildProcessInfo(); 20 virtual ~ChildProcessInfo();
41 21
42 ChildProcessInfo& operator=(const ChildProcessInfo& original); 22 ChildProcessInfo& operator=(const ChildProcessInfo& original);
43 23
44 // Returns the type of the process. 24 // Returns the type of the process.
45 ProcessType type() const { return type_; } 25 content::ProcessType type() const { return type_; }
46 26
47 // Returns the name of the process. i.e. for plugins it might be Flash, while 27 // Returns the name of the process. i.e. for plugins it might be Flash, while
48 // for workers it might be the domain that it's from. 28 // for workers it might be the domain that it's from.
49 const string16& name() const { return name_; } 29 const string16& name() const { return name_; }
50 30
51 // Returns the version of the exe, this only applies to plugins. Otherwise 31 // Returns the version of the exe, this only applies to plugins. Otherwise
52 // the string is empty. 32 // the string is empty.
53 const string16& version() const { return version_; } 33 const string16& version() const { return version_; }
54 34
55 // Getter to the process handle. 35 // Getter to the process handle.
56 base::ProcessHandle handle() const { return process_.handle(); } 36 base::ProcessHandle handle() const { return process_.handle(); }
57 37
58 // Getter to the process ID. 38 // Getter to the process ID.
59 int pid() const { return process_.pid(); } 39 int pid() const { return process_.pid(); }
60 40
61 // The unique identifier for this child process. This identifier is NOT a 41 // The unique identifier for this child process. This identifier is NOT a
62 // process ID, and will be unique for all types of child process for 42 // process ID, and will be unique for all types of child process for
63 // one run of the browser. 43 // one run of the browser.
64 int id() const { return id_; } 44 int id() const { return id_; }
65 45
66 void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); } 46 void SetProcessBackgrounded() const { process_.SetProcessBackgrounded(true); }
67 47
68 // Returns an English name of the process type, should only be used for non 48 // Returns an English name of the process type, should only be used for non
69 // user-visible strings, or debugging pages like about:memory. 49 // user-visible strings, or debugging pages like about:memory.
70 static std::string GetTypeNameInEnglish(ProcessType type); 50 static std::string GetTypeNameInEnglish(content::ProcessType type);
71 51
72 // We define the < operator so that the ChildProcessInfo can be used as a key 52 // We define the < operator so that the ChildProcessInfo can be used as a key
73 // in a std::map. 53 // in a std::map.
74 bool operator <(const ChildProcessInfo& rhs) const { 54 bool operator <(const ChildProcessInfo& rhs) const {
75 if (process_.handle() != rhs.process_.handle()) 55 if (process_.handle() != rhs.process_.handle())
76 return process_ .handle() < rhs.process_.handle(); 56 return process_ .handle() < rhs.process_.handle();
77 return false; 57 return false;
78 } 58 }
79 59
80 bool operator ==(const ChildProcessInfo& rhs) const { 60 bool operator ==(const ChildProcessInfo& rhs) const {
(...skipping 11 matching lines...) Expand all
92 // 72 //
93 // This function is threadsafe since RenderProcessHost is on the UI thread, 73 // This function is threadsafe since RenderProcessHost is on the UI thread,
94 // but normally this will be used on the IO thread. 74 // but normally this will be used on the IO thread.
95 static int GenerateChildProcessUniqueId(); 75 static int GenerateChildProcessUniqueId();
96 76
97 protected: 77 protected:
98 // Derived objects need to use this constructor so we know what type we are. 78 // Derived objects need to use this constructor so we know what type we are.
99 // If the caller has already generated a unique ID for this child process, 79 // If the caller has already generated a unique ID for this child process,
100 // it should pass it as the second argument. Otherwise, -1 should be passed 80 // it should pass it as the second argument. Otherwise, -1 should be passed
101 // and a unique ID will be automatically generated. 81 // and a unique ID will be automatically generated.
102 ChildProcessInfo(ProcessType type, int id); 82 ChildProcessInfo(content::ProcessType type, int id);
103 83
104 void set_type(ProcessType type) { type_ = type; } 84 void set_type(content::ProcessType type) { type_ = type; }
105 void set_name(const string16& name) { name_ = name; } 85 void set_name(const string16& name) { name_ = name; }
106 void set_version(const string16& ver) { version_ = ver; } 86 void set_version(const string16& ver) { version_ = ver; }
107 void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); } 87 void set_handle(base::ProcessHandle handle) { process_.set_handle(handle); }
108 88
109 private: 89 private:
110 ProcessType type_; 90 content::ProcessType type_;
111 string16 name_; 91 string16 name_;
112 string16 version_; 92 string16 version_;
113 int id_; 93 int id_;
114 94
115 // The handle to the process. 95 // The handle to the process.
116 mutable base::Process process_; 96 mutable base::Process process_;
117 }; 97 };
118 98
119 #endif // CONTENT_COMMON_CHILD_PROCESS_INFO_H_ 99 #endif // CONTENT_COMMON_CHILD_PROCESS_INFO_H_
OLDNEW
« no previous file with comments | « content/browser/worker_host/worker_service.cc ('k') | content/common/child_process_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698