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 NULL; | 593 return nullptr; |
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 NULL; | 605 return nullptr; |
606 } | 606 } |
607 } else { | 607 } else { |
608 NOTREACHED() << "Browser allocation request message failed"; | 608 // Send is allowed to fail during shutdown. Return null in this case. |
609 return NULL; | 609 return nullptr; |
reveman
2015/09/18 14:51:35
Note: I can't have a ChildProcess::current() call
| |
610 } | 610 } |
611 #endif | 611 #endif |
612 return shared_buf; | 612 return shared_buf; |
613 } | 613 } |
614 | 614 |
615 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { | 615 bool ChildThreadImpl::OnMessageReceived(const IPC::Message& msg) { |
616 if (mojo_application_->OnMessageReceived(msg)) | 616 if (mojo_application_->OnMessageReceived(msg)) |
617 return true; | 617 return true; |
618 | 618 |
619 // 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... | |
738 void ChildThreadImpl::EnsureConnected() { | 738 void ChildThreadImpl::EnsureConnected() { |
739 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 739 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
740 base::Process::Current().Terminate(0, false); | 740 base::Process::Current().Terminate(0, false); |
741 } | 741 } |
742 | 742 |
743 bool ChildThreadImpl::IsInBrowserProcess() const { | 743 bool ChildThreadImpl::IsInBrowserProcess() const { |
744 return browser_process_io_runner_; | 744 return browser_process_io_runner_; |
745 } | 745 } |
746 | 746 |
747 } // namespace content | 747 } // namespace content |
OLD | NEW |