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

Side by Side Diff: chrome/browser/zygote_main_linux.cc

Issue 125268: Revert r18641: "Linux: Enable metrics_service_uitest.cc." (Closed)
Patch Set: Created 11 years, 6 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
« no previous file with comments | « chrome/browser/zygote_host_linux.cc ('k') | chrome/chrome.gyp » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include <unistd.h> 5 #include <unistd.h>
6 #include <sys/epoll.h> 6 #include <sys/epoll.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <sys/socket.h> 8 #include <sys/socket.h>
9 #include <sys/signal.h> 9 #include <sys/signal.h>
10 #include <sys/prctl.h> 10 #include <sys/prctl.h>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 if (len == 0) { 70 if (len == 0) {
71 // EOF from the browser. We should die. 71 // EOF from the browser. We should die.
72 _exit(0); 72 _exit(0);
73 return false; 73 return false;
74 } 74 }
75 75
76 Pickle pickle(buf, len); 76 Pickle pickle(buf, len);
77 void* iter = NULL; 77 void* iter = NULL;
78 78
79 int kind; 79 int kind;
80 if (pickle.ReadInt(&iter, &kind)) { 80 if (!pickle.ReadInt(&iter, &kind))
81 switch (kind) { 81 goto error;
82 case ZygoteHost::kCmdFork: 82
83 return HandleForkRequest(fd, pickle, iter, fds); 83 if (kind == ZygoteHost::kCmdFork) {
84 case ZygoteHost::kCmdReap: 84 return HandleForkRequest(fd, pickle, iter, fds);
85 if (!fds.empty()) 85 } else if (kind == ZygoteHost::kCmdReap) {
86 break; 86 if (fds.size())
87 return HandleReapRequest(fd, pickle, iter); 87 goto error;
88 case ZygoteHost::kCmdDidProcessCrash: 88 return HandleReapRequest(fd, pickle, iter);
89 if (!fds.empty())
90 break;
91 return HandleDidProcessCrash(fd, pickle, iter);
92 default:
93 NOTREACHED();
94 break;
95 }
96 } 89 }
97 90
91 error:
98 LOG(WARNING) << "Error parsing message from browser"; 92 LOG(WARNING) << "Error parsing message from browser";
99 for (std::vector<int>::const_iterator 93 for (std::vector<int>::const_iterator
100 i = fds.begin(); i != fds.end(); ++i) 94 i = fds.begin(); i != fds.end(); ++i)
101 close(*i); 95 close(*i);
102 return false; 96 return false;
103 } 97 }
104 98
105 bool HandleReapRequest(int fd, Pickle& pickle, void* iter) { 99 bool HandleReapRequest(int fd, Pickle& pickle, void* iter) {
106 pid_t child; 100 pid_t child;
107 101
108 if (!pickle.ReadInt(&iter, &child)) { 102 if (!pickle.ReadInt(&iter, &child)) {
109 LOG(WARNING) << "Error parsing reap request from browser"; 103 LOG(WARNING) << "Error parsing reap request from browser";
110 return false; 104 return false;
111 } 105 }
112 106
113 ProcessWatcher::EnsureProcessTerminated(child); 107 ProcessWatcher::EnsureProcessTerminated(child);
114 108
115 return false; 109 return false;
116 } 110 }
117 111
118 bool HandleDidProcessCrash(int fd, Pickle& pickle, void* iter) {
119 base::ProcessHandle child;
120
121 if (!pickle.ReadInt(&iter, &child)) {
122 LOG(WARNING) << "Error parsing DidProcessCrash request from browser";
123 return false;
124 }
125
126 bool child_exited;
127 bool did_crash = base::DidProcessCrash(&child_exited, child);
128
129 Pickle write_pickle;
130 write_pickle.WriteBool(did_crash);
131 write_pickle.WriteBool(child_exited);
132 HANDLE_EINTR(write(fd, write_pickle.data(), write_pickle.size()));
133
134 return false;
135 }
136
137 // Handle a 'fork' request from the browser: this means that the browser 112 // Handle a 'fork' request from the browser: this means that the browser
138 // wishes to start a new renderer. 113 // wishes to start a new renderer.
139 bool HandleForkRequest(int fd, Pickle& pickle, void* iter, 114 bool HandleForkRequest(int fd, Pickle& pickle, void* iter,
140 std::vector<int>& fds) { 115 std::vector<int>& fds) {
141 std::vector<std::string> args; 116 std::vector<std::string> args;
142 int argc, numfds; 117 int argc, numfds;
143 base::GlobalDescriptors::Mapping mapping; 118 base::GlobalDescriptors::Mapping mapping;
144 pid_t child; 119 pid_t child;
145 120
146 if (!pickle.ReadInt(&iter, &argc)) 121 if (!pickle.ReadInt(&iter, &argc))
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 bool ZygoteMain(const MainFunctionParams& params) { 212 bool ZygoteMain(const MainFunctionParams& params) {
238 if (!MaybeEnterChroot()) { 213 if (!MaybeEnterChroot()) {
239 LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: " 214 LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: "
240 << errno << ")"; 215 << errno << ")";
241 return false; 216 return false;
242 } 217 }
243 218
244 Zygote zygote; 219 Zygote zygote;
245 return zygote.ProcessRequests(); 220 return zygote.ProcessRequests();
246 } 221 }
OLDNEW
« no previous file with comments | « chrome/browser/zygote_host_linux.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698