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

Side by Side Diff: ipc/mojo/ipc_mojo_handle_attachment.cc

Issue 1174423002: Fix leak of PlatformHandleDispatchers in Mojo IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "ipc/mojo/ipc_mojo_handle_attachment.h" 5 #include "ipc/mojo/ipc_mojo_handle_attachment.h"
6 6
7 #include "ipc/ipc_message_attachment_set.h" 7 #include "ipc/ipc_message_attachment_set.h"
8 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" 8 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
9 9
10 namespace IPC { 10 namespace IPC {
11 namespace internal { 11 namespace internal {
12 12
13 MojoHandleAttachment::MojoHandleAttachment(mojo::ScopedHandle handle) 13 MojoHandleAttachment::MojoHandleAttachment(mojo::ScopedHandle handle)
14 : handle_(handle.Pass()) { 14 : handle_(handle.Pass()) {
15 } 15 }
16 16
17 MojoHandleAttachment::~MojoHandleAttachment() { 17 MojoHandleAttachment::~MojoHandleAttachment() {
18 } 18 }
19 19
20 MessageAttachment::Type MojoHandleAttachment::GetType() const { 20 MessageAttachment::Type MojoHandleAttachment::GetType() const {
21 return TYPE_MOJO_HANDLE; 21 return TYPE_MOJO_HANDLE;
22 } 22 }
23 23
24 #if defined(OS_POSIX) 24 #if defined(OS_POSIX)
25 base::PlatformFile MojoHandleAttachment::TakePlatformFile() { 25 base::PlatformFile MojoHandleAttachment::TakePlatformFile() {
26 mojo::embedder::ScopedPlatformHandle platform_handle; 26 mojo::embedder::ScopedPlatformHandle platform_handle;
27 MojoResult unwrap_result = mojo::embedder::PassWrappedPlatformHandle( 27 MojoResult unwrap_result = mojo::embedder::PassWrappedPlatformHandle(
28 handle_.release().value(), &platform_handle); 28 handle_.get().value(), &platform_handle);
29 handle_.reset();
29 if (unwrap_result != MOJO_RESULT_OK) { 30 if (unwrap_result != MOJO_RESULT_OK) {
30 LOG(ERROR) << "Pipe failed to covert handles. Closing: " << unwrap_result; 31 LOG(ERROR) << "Pipe failed to covert handles. Closing: " << unwrap_result;
31 return -1; 32 return -1;
32 } 33 }
33 34
34 return platform_handle.release().fd; 35 return platform_handle.release().fd;
35 } 36 }
36 #endif // OS_POSIX 37 #endif // OS_POSIX
37 38
38 mojo::ScopedHandle MojoHandleAttachment::TakeHandle() { 39 mojo::ScopedHandle MojoHandleAttachment::TakeHandle() {
39 return handle_.Pass(); 40 return handle_.Pass();
40 } 41 }
41 42
42 } // namespace internal 43 } // namespace internal
43 } // namespace IPC 44 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698