Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: content/child/child_thread_impl.cc

Issue 2544953002: content: Some code cleanup related to shared memory allocation. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 714 }
715 715
716 mojom::RouteProvider* ChildThreadImpl::GetRemoteRouteProvider() { 716 mojom::RouteProvider* ChildThreadImpl::GetRemoteRouteProvider() {
717 if (!remote_route_provider_) { 717 if (!remote_route_provider_) {
718 DCHECK(channel_); 718 DCHECK(channel_);
719 channel_->GetRemoteAssociatedInterface(&remote_route_provider_); 719 channel_->GetRemoteAssociatedInterface(&remote_route_provider_);
720 } 720 }
721 return remote_route_provider_.get(); 721 return remote_route_provider_.get();
722 } 722 }
723 723
724 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory(
725 size_t buf_size) {
726 DCHECK(message_loop_->task_runner()->BelongsToCurrentThread());
727 return AllocateSharedMemory(buf_size, this, nullptr);
728 }
729
730 // static 724 // static
731 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory( 725 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory(
732 size_t buf_size, 726 size_t buf_size,
733 IPC::Sender* sender,
734 bool* out_of_memory) { 727 bool* out_of_memory) {
735 mojo::ScopedSharedBufferHandle mojo_buf = 728 mojo::ScopedSharedBufferHandle mojo_buf =
736 mojo::SharedBufferHandle::Create(buf_size); 729 mojo::SharedBufferHandle::Create(buf_size);
737 if (!mojo_buf->is_valid()) { 730 if (!mojo_buf->is_valid()) {
738 LOG(WARNING) << "Browser failed to allocate shared memory"; 731 LOG(WARNING) << "Browser failed to allocate shared memory";
739 if (out_of_memory) 732 if (out_of_memory)
740 *out_of_memory = true; 733 *out_of_memory = true;
nasko 2016/12/02 19:58:08 Do we care to disambiguate an out of memory condit
sadrul 2016/12/08 03:27:52 Looks like the original failure mode during teardo
erikchen 2016/12/08 03:36:02 right. no IPC means this is no longer necessary.
741 return nullptr; 734 return nullptr;
742 } 735 }
743 736
744 base::SharedMemoryHandle shared_buf; 737 base::SharedMemoryHandle shared_buf;
745 if (mojo::UnwrapSharedMemoryHandle(std::move(mojo_buf), &shared_buf, 738 if (mojo::UnwrapSharedMemoryHandle(std::move(mojo_buf), &shared_buf,
746 nullptr, nullptr) != MOJO_RESULT_OK) { 739 nullptr, nullptr) != MOJO_RESULT_OK) {
747 LOG(WARNING) << "Browser failed to allocate shared memory"; 740 LOG(WARNING) << "Browser failed to allocate shared memory";
748 return nullptr; 741 return nullptr;
749 } 742 }
750 743
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 connected_to_browser_ = true; 909 connected_to_browser_ = true;
917 child_info_ = local_info; 910 child_info_ = local_info;
918 browser_info_ = remote_info; 911 browser_info_ = remote_info;
919 } 912 }
920 913
921 bool ChildThreadImpl::IsInBrowserProcess() const { 914 bool ChildThreadImpl::IsInBrowserProcess() const {
922 return static_cast<bool>(browser_process_io_runner_); 915 return static_cast<bool>(browser_process_io_runner_);
923 } 916 }
924 917
925 } // namespace content 918 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/renderer/media/renderer_gpu_video_accelerator_factories.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698