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