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/common/child_thread.h" | 5 #include "content/common/child_thread.h" |
6 | 6 |
7 #include "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 void ChildThread::OnGetTcmallocStats() { | 321 void ChildThread::OnGetTcmallocStats() { |
322 std::string result; | 322 std::string result; |
323 char buffer[1024 * 32]; | 323 char buffer[1024 * 32]; |
324 base::allocator::GetStats(buffer, sizeof(buffer)); | 324 base::allocator::GetStats(buffer, sizeof(buffer)); |
325 result.append(buffer); | 325 result.append(buffer); |
326 Send(new ChildProcessHostMsg_TcmallocStats(result)); | 326 Send(new ChildProcessHostMsg_TcmallocStats(result)); |
327 } | 327 } |
328 #endif | 328 #endif |
329 | 329 |
330 ChildThread* ChildThread::current() { | 330 ChildThread* ChildThread::current() { |
331 return ChildProcess::current()->main_thread(); | 331 return ChildProcess::current() ? |
| 332 ChildProcess::current()->main_thread() : NULL; |
332 } | 333 } |
333 | 334 |
334 bool ChildThread::IsWebFrameValid(WebKit::WebFrame* frame) { | 335 bool ChildThread::IsWebFrameValid(WebKit::WebFrame* frame) { |
335 // Return false so that it is overridden in any process in which it is used. | 336 // Return false so that it is overridden in any process in which it is used. |
336 return false; | 337 return false; |
337 } | 338 } |
338 | 339 |
339 void ChildThread::OnProcessFinalRelease() { | 340 void ChildThread::OnProcessFinalRelease() { |
340 if (on_channel_error_called_) { | 341 if (on_channel_error_called_) { |
341 MessageLoop::current()->Quit(); | 342 MessageLoop::current()->Quit(); |
342 return; | 343 return; |
343 } | 344 } |
344 | 345 |
345 // The child process shutdown sequence is a request response based mechanism, | 346 // The child process shutdown sequence is a request response based mechanism, |
346 // where we send out an initial feeler request to the child process host | 347 // where we send out an initial feeler request to the child process host |
347 // instance in the browser to verify if it's ok to shutdown the child process. | 348 // instance in the browser to verify if it's ok to shutdown the child process. |
348 // The browser then sends back a response if it's ok to shutdown. This avoids | 349 // The browser then sends back a response if it's ok to shutdown. This avoids |
349 // race conditions if the process refcount is 0 but there's an IPC message | 350 // race conditions if the process refcount is 0 but there's an IPC message |
350 // inflight that would addref it. | 351 // inflight that would addref it. |
351 Send(new ChildProcessHostMsg_ShutdownRequest); | 352 Send(new ChildProcessHostMsg_ShutdownRequest); |
352 } | 353 } |
353 | 354 |
354 void ChildThread::EnsureConnected() { | 355 void ChildThread::EnsureConnected() { |
355 LOG(INFO) << "ChildThread::EnsureConnected()"; | 356 LOG(INFO) << "ChildThread::EnsureConnected()"; |
356 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 357 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
357 } | 358 } |
358 | 359 |
359 } // namespace content | 360 } // namespace content |
OLD | NEW |