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

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

Issue 6001010: Move platform_thread to base/threading and put in the base namespace. I left ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
OLDNEW
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 #include "chrome/browser/browser_main_posix.h" 5 #include "chrome/browser/browser_main_posix.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <sys/resource.h> 9 #include <sys/resource.h>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/eintr_wrapper.h" 12 #include "base/eintr_wrapper.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/threading/platform_thread.h"
15 #include "chrome/browser/browser_list.h" 16 #include "chrome/browser/browser_list.h"
16 #include "chrome/browser/browser_thread.h" 17 #include "chrome/browser/browser_thread.h"
17 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
18 19
19 namespace { 20 namespace {
20 21
21 // See comment in |PreEarlyInitialization()|, where sigaction is called. 22 // See comment in |PreEarlyInitialization()|, where sigaction is called.
22 void SIGCHLDHandler(int signal) { 23 void SIGCHLDHandler(int signal) {
23 } 24 }
24 25
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 GracefulShutdownHandler(signal); 64 GracefulShutdownHandler(signal);
64 } 65 }
65 66
66 // See comment in |PreEarlyInitialization()|, where sigaction is called. 67 // See comment in |PreEarlyInitialization()|, where sigaction is called.
67 void SIGTERMHandler(int signal) { 68 void SIGTERMHandler(int signal) {
68 RAW_CHECK(signal == SIGTERM); 69 RAW_CHECK(signal == SIGTERM);
69 RAW_LOG(INFO, "Handling SIGTERM."); 70 RAW_LOG(INFO, "Handling SIGTERM.");
70 GracefulShutdownHandler(signal); 71 GracefulShutdownHandler(signal);
71 } 72 }
72 73
73 class ShutdownDetector : public PlatformThread::Delegate { 74 class ShutdownDetector : public base::PlatformThread::Delegate {
74 public: 75 public:
75 explicit ShutdownDetector(int shutdown_fd); 76 explicit ShutdownDetector(int shutdown_fd);
76 77
77 virtual void ThreadMain(); 78 virtual void ThreadMain();
78 79
79 private: 80 private:
80 const int shutdown_fd_; 81 const int shutdown_fd_;
81 82
82 DISALLOW_COPY_AND_ASSIGN(ShutdownDetector); 83 DISALLOW_COPY_AND_ASSIGN(ShutdownDetector);
83 }; 84 };
84 85
85 ShutdownDetector::ShutdownDetector(int shutdown_fd) 86 ShutdownDetector::ShutdownDetector(int shutdown_fd)
86 : shutdown_fd_(shutdown_fd) { 87 : shutdown_fd_(shutdown_fd) {
87 CHECK_NE(shutdown_fd_, -1); 88 CHECK_NE(shutdown_fd_, -1);
88 } 89 }
89 90
90 void ShutdownDetector::ThreadMain() { 91 void ShutdownDetector::ThreadMain() {
91 PlatformThread::SetName("CrShutdownDetector"); 92 base::PlatformThread::SetName("CrShutdownDetector");
92 93
93 int signal; 94 int signal;
94 size_t bytes_read = 0; 95 size_t bytes_read = 0;
95 ssize_t ret; 96 ssize_t ret;
96 do { 97 do {
97 ret = HANDLE_EINTR( 98 ret = HANDLE_EINTR(
98 read(shutdown_fd_, 99 read(shutdown_fd_,
99 reinterpret_cast<char*>(&signal) + bytes_read, 100 reinterpret_cast<char*>(&signal) + bytes_read,
100 sizeof(signal) - bytes_read)); 101 sizeof(signal) - bytes_read));
101 if (ret < 0) { 102 if (ret < 0) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 int pipefd[2]; 205 int pipefd[2];
205 int ret = pipe(pipefd); 206 int ret = pipe(pipefd);
206 if (ret < 0) { 207 if (ret < 0) {
207 PLOG(DFATAL) << "Failed to create pipe"; 208 PLOG(DFATAL) << "Failed to create pipe";
208 } else { 209 } else {
209 g_shutdown_pipe_read_fd = pipefd[0]; 210 g_shutdown_pipe_read_fd = pipefd[0];
210 g_shutdown_pipe_write_fd = pipefd[1]; 211 g_shutdown_pipe_write_fd = pipefd[1];
211 const size_t kShutdownDetectorThreadStackSize = 4096; 212 const size_t kShutdownDetectorThreadStackSize = 4096;
212 // TODO(viettrungluu,willchan): crbug.com/29675 - This currently leaks, so 213 // TODO(viettrungluu,willchan): crbug.com/29675 - This currently leaks, so
213 // if you change this, you'll probably need to change the suppression. 214 // if you change this, you'll probably need to change the suppression.
214 if (!PlatformThread::CreateNonJoinable( 215 if (!base::PlatformThread::CreateNonJoinable(
215 kShutdownDetectorThreadStackSize, 216 kShutdownDetectorThreadStackSize,
216 new ShutdownDetector(g_shutdown_pipe_read_fd))) { 217 new ShutdownDetector(g_shutdown_pipe_read_fd))) {
217 LOG(DFATAL) << "Failed to create shutdown detector task."; 218 LOG(DFATAL) << "Failed to create shutdown detector task.";
218 } 219 }
219 } 220 }
220 } 221 }
OLDNEW
« no previous file with comments | « base/waitable_event_watcher_unittest.cc ('k') | chrome/browser/debugger/devtools_remote_listen_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698