OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/child/child_thread.h" | 5 #include "content/child/child_thread.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622 | 77 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622 |
78 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ | 78 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ |
79 defined(THREAD_SANITIZER)) && !defined(OS_CHROMEOS) | 79 defined(THREAD_SANITIZER)) && !defined(OS_CHROMEOS) |
80 // A thread delegate that waits for |duration| and then exits the process with | 80 // A thread delegate that waits for |duration| and then exits the process with |
81 // _exit(0). | 81 // _exit(0). |
82 class WaitAndExitDelegate : public base::PlatformThread::Delegate { | 82 class WaitAndExitDelegate : public base::PlatformThread::Delegate { |
83 public: | 83 public: |
84 explicit WaitAndExitDelegate(base::TimeDelta duration) | 84 explicit WaitAndExitDelegate(base::TimeDelta duration) |
85 : duration_(duration) {} | 85 : duration_(duration) {} |
86 virtual ~WaitAndExitDelegate() OVERRIDE {} | 86 virtual ~WaitAndExitDelegate() override {} |
87 | 87 |
88 virtual void ThreadMain() OVERRIDE { | 88 virtual void ThreadMain() override { |
89 base::PlatformThread::Sleep(duration_); | 89 base::PlatformThread::Sleep(duration_); |
90 _exit(0); | 90 _exit(0); |
91 } | 91 } |
92 | 92 |
93 private: | 93 private: |
94 const base::TimeDelta duration_; | 94 const base::TimeDelta duration_; |
95 DISALLOW_COPY_AND_ASSIGN(WaitAndExitDelegate); | 95 DISALLOW_COPY_AND_ASSIGN(WaitAndExitDelegate); |
96 }; | 96 }; |
97 | 97 |
98 bool CreateWaitAndExitThread(base::TimeDelta duration) { | 98 bool CreateWaitAndExitThread(base::TimeDelta duration) { |
(...skipping 10 matching lines...) Expand all Loading... |
109 WaitAndExitDelegate* leaking_delegate = delegate.release(); | 109 WaitAndExitDelegate* leaking_delegate = delegate.release(); |
110 ANNOTATE_LEAKING_OBJECT_PTR(leaking_delegate); | 110 ANNOTATE_LEAKING_OBJECT_PTR(leaking_delegate); |
111 ignore_result(leaking_delegate); | 111 ignore_result(leaking_delegate); |
112 return true; | 112 return true; |
113 } | 113 } |
114 #endif | 114 #endif |
115 | 115 |
116 class SuicideOnChannelErrorFilter : public IPC::MessageFilter { | 116 class SuicideOnChannelErrorFilter : public IPC::MessageFilter { |
117 public: | 117 public: |
118 // IPC::MessageFilter | 118 // IPC::MessageFilter |
119 virtual void OnChannelError() OVERRIDE { | 119 virtual void OnChannelError() override { |
120 // For renderer/worker processes: | 120 // For renderer/worker processes: |
121 // On POSIX, at least, one can install an unload handler which loops | 121 // On POSIX, at least, one can install an unload handler which loops |
122 // forever and leave behind a renderer process which eats 100% CPU forever. | 122 // forever and leave behind a renderer process which eats 100% CPU forever. |
123 // | 123 // |
124 // This is because the terminate signals (ViewMsg_ShouldClose and the error | 124 // This is because the terminate signals (ViewMsg_ShouldClose and the error |
125 // from the IPC sender) are routed to the main message loop but never | 125 // from the IPC sender) are routed to the main message loop but never |
126 // processed (because that message loop is stuck in V8). | 126 // processed (because that message loop is stuck in V8). |
127 // | 127 // |
128 // One could make the browser SIGKILL the renderers, but that leaves open a | 128 // One could make the browser SIGKILL the renderers, but that leaves open a |
129 // large window where a browser failure (or a user, manually terminating | 129 // large window where a browser failure (or a user, manually terminating |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 | 591 |
592 void ChildThread::OnProcessBackgrounded(bool background) { | 592 void ChildThread::OnProcessBackgrounded(bool background) { |
593 // Set timer slack to maximum on main thread when in background. | 593 // Set timer slack to maximum on main thread when in background. |
594 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 594 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
595 if (background) | 595 if (background) |
596 timer_slack = base::TIMER_SLACK_MAXIMUM; | 596 timer_slack = base::TIMER_SLACK_MAXIMUM; |
597 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 597 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
598 } | 598 } |
599 | 599 |
600 } // namespace content | 600 } // namespace content |
OLD | NEW |