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

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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 } 670 }
671 671
672 mojom::RouteProvider* ChildThreadImpl::GetRemoteRouteProvider() { 672 mojom::RouteProvider* ChildThreadImpl::GetRemoteRouteProvider() {
673 if (!remote_route_provider_) { 673 if (!remote_route_provider_) {
674 DCHECK(channel_); 674 DCHECK(channel_);
675 channel_->GetRemoteAssociatedInterface(&remote_route_provider_); 675 channel_->GetRemoteAssociatedInterface(&remote_route_provider_);
676 } 676 }
677 return remote_route_provider_.get(); 677 return remote_route_provider_.get();
678 } 678 }
679 679
680 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory(
681 size_t buf_size) {
682 DCHECK(message_loop_->task_runner()->BelongsToCurrentThread());
683 return AllocateSharedMemory(buf_size, this, nullptr);
684 }
685
686 // static 680 // static
687 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory( 681 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory(
688 size_t buf_size, 682 size_t buf_size) {
689 IPC::Sender* sender,
690 bool* out_of_memory) {
691 mojo::ScopedSharedBufferHandle mojo_buf = 683 mojo::ScopedSharedBufferHandle mojo_buf =
692 mojo::SharedBufferHandle::Create(buf_size); 684 mojo::SharedBufferHandle::Create(buf_size);
693 if (!mojo_buf->is_valid()) { 685 if (!mojo_buf->is_valid()) {
694 LOG(WARNING) << "Browser failed to allocate shared memory"; 686 LOG(WARNING) << "Browser failed to allocate shared memory";
695 if (out_of_memory)
696 *out_of_memory = true;
697 return nullptr; 687 return nullptr;
698 } 688 }
699 689
700 base::SharedMemoryHandle shared_buf; 690 base::SharedMemoryHandle shared_buf;
701 if (mojo::UnwrapSharedMemoryHandle(std::move(mojo_buf), &shared_buf, 691 if (mojo::UnwrapSharedMemoryHandle(std::move(mojo_buf), &shared_buf,
702 nullptr, nullptr) != MOJO_RESULT_OK) { 692 nullptr, nullptr) != MOJO_RESULT_OK) {
703 LOG(WARNING) << "Browser failed to allocate shared memory"; 693 LOG(WARNING) << "Browser failed to allocate shared memory";
704 return nullptr; 694 return nullptr;
705 } 695 }
706 696
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 connected_to_browser_ = true; 862 connected_to_browser_ = true;
873 child_info_ = local_info; 863 child_info_ = local_info;
874 browser_info_ = remote_info; 864 browser_info_ = remote_info;
875 } 865 }
876 866
877 bool ChildThreadImpl::IsInBrowserProcess() const { 867 bool ChildThreadImpl::IsInBrowserProcess() const {
878 return static_cast<bool>(browser_process_io_runner_); 868 return static_cast<bool>(browser_process_io_runner_);
879 } 869 }
880 870
881 } // namespace content 871 } // 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