| 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_impl.h" | 5 #include "content/child/child_thread_impl.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 | 583 |
| 584 // static | 584 // static |
| 585 scoped_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory( | 585 scoped_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory( |
| 586 size_t buf_size, | 586 size_t buf_size, |
| 587 IPC::Sender* sender) { | 587 IPC::Sender* sender) { |
| 588 scoped_ptr<base::SharedMemory> shared_buf; | 588 scoped_ptr<base::SharedMemory> shared_buf; |
| 589 #if defined(OS_WIN) | 589 #if defined(OS_WIN) |
| 590 shared_buf.reset(new base::SharedMemory); | 590 shared_buf.reset(new base::SharedMemory); |
| 591 if (!shared_buf->CreateAnonymous(buf_size)) { | 591 if (!shared_buf->CreateAnonymous(buf_size)) { |
| 592 NOTREACHED(); | 592 NOTREACHED(); |
| 593 return nullptr; | 593 return NULL; |
| 594 } | 594 } |
| 595 #else | 595 #else |
| 596 // On POSIX, we need to ask the browser to create the shared memory for us, | 596 // On POSIX, we need to ask the browser to create the shared memory for us, |
| 597 // since this is blocked by the sandbox. | 597 // since this is blocked by the sandbox. |
| 598 base::SharedMemoryHandle shared_mem_handle; | 598 base::SharedMemoryHandle shared_mem_handle; |
| 599 if (sender->Send(new ChildProcessHostMsg_SyncAllocateSharedMemory( | 599 if (sender->Send(new ChildProcessHostMsg_SyncAllocateSharedMemory( |
| 600 buf_size, &shared_mem_handle))) { | 600 buf_size, &shared_mem_handle))) { |
| 601 if (base::SharedMemory::IsHandleValid(shared_mem_handle)) { | 601 if (base::SharedMemory::IsHandleValid(shared_mem_handle)) { |
| 602 shared_buf.reset(new base::SharedMemory(shared_mem_handle, false)); | 602 shared_buf.reset(new base::SharedMemory(shared_mem_handle, false)); |
| 603 } else { | 603 } else { |
| 604 NOTREACHED() << "Browser failed to allocate shared memory"; | 604 NOTREACHED() << "Browser failed to allocate shared memory"; |
| 605 return nullptr; | 605 return NULL; |
| 606 } | 606 } |
| 607 } else if (ChildProcess::current()->GetShutDownEvent()->IsSignaled()) { | |
| 608 // Send is allowed to fail during shutdown. Return null in this case. | |
| 609 return nullptr; | |
| 610 } else { | 607 } else { |
| 611 NOTREACHED() << "Browser allocation request message failed"; | 608 NOTREACHED() << "Browser allocation request message failed"; |
| 612 return nullptr; | 609 return NULL; |
| 613 } | 610 } |
| 614 #endif | 611 #endif |
| 615 return shared_buf; | 612 return shared_buf; |
| 616 } | 613 } |
| 617 | 614 |
| 618 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { | 615 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { |
| 619 if (mojo_application_->OnMessageReceived(msg)) | 616 if (mojo_application_->OnMessageReceived(msg)) |
| 620 return true; | 617 return true; |
| 621 | 618 |
| 622 // Resource responses are sent to the resource dispatcher. | 619 // Resource responses are sent to the resource dispatcher. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 void ChildThreadImpl::EnsureConnected() { | 738 void ChildThreadImpl::EnsureConnected() { |
| 742 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 739 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
| 743 base::Process::Current().Terminate(0, false); | 740 base::Process::Current().Terminate(0, false); |
| 744 } | 741 } |
| 745 | 742 |
| 746 bool ChildThreadImpl::IsInBrowserProcess() const { | 743 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 747 return browser_process_io_runner_; | 744 return browser_process_io_runner_; |
| 748 } | 745 } |
| 749 | 746 |
| 750 } // namespace content | 747 } // namespace content |
| OLD | NEW |