| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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/handle_win.h" | 5 #include "ipc/handle_win.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 11 #include "ipc/handle_attachment_win.h" | 13 #include "ipc/handle_attachment_win.h" |
| 12 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
| 13 | 15 |
| 14 namespace IPC { | 16 namespace IPC { |
| 15 | 17 |
| 16 HandleWin::HandleWin() : handle_(nullptr), permissions_(INVALID) {} | 18 HandleWin::HandleWin() : handle_(nullptr), permissions_(INVALID) {} |
| 17 | 19 |
| 18 HandleWin::HandleWin(const HANDLE& handle, Permissions permissions) | 20 HandleWin::HandleWin(const HANDLE& handle, Permissions permissions) |
| 19 : handle_(handle), permissions_(permissions) {} | 21 : handle_(handle), permissions_(permissions) {} |
| 20 | 22 |
| 21 // static | 23 // static |
| 22 void ParamTraits<HandleWin>::Write(Message* m, const param_type& p) { | 24 void ParamTraits<HandleWin>::Write(Message* m, const param_type& p) { |
| 23 scoped_refptr<IPC::internal::HandleAttachmentWin> attachment( | 25 scoped_refptr<IPC::internal::HandleAttachmentWin> attachment( |
| 24 new IPC::internal::HandleAttachmentWin(p.get_handle(), | 26 new IPC::internal::HandleAttachmentWin(p.get_handle(), |
| 25 p.get_permissions())); | 27 p.get_permissions())); |
| 26 if (!m->WriteAttachment(attachment.Pass())) | 28 if (!m->WriteAttachment(std::move(attachment))) |
| 27 NOTREACHED(); | 29 NOTREACHED(); |
| 28 } | 30 } |
| 29 | 31 |
| 30 // static | 32 // static |
| 31 bool ParamTraits<HandleWin>::Read(const Message* m, | 33 bool ParamTraits<HandleWin>::Read(const Message* m, |
| 32 base::PickleIterator* iter, | 34 base::PickleIterator* iter, |
| 33 param_type* r) { | 35 param_type* r) { |
| 34 scoped_refptr<MessageAttachment> attachment; | 36 scoped_refptr<MessageAttachment> attachment; |
| 35 if (!m->ReadAttachment(iter, &attachment)) | 37 if (!m->ReadAttachment(iter, &attachment)) |
| 36 return false; | 38 return false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 return true; | 50 return true; |
| 49 } | 51 } |
| 50 | 52 |
| 51 // static | 53 // static |
| 52 void ParamTraits<HandleWin>::Log(const param_type& p, std::string* l) { | 54 void ParamTraits<HandleWin>::Log(const param_type& p, std::string* l) { |
| 53 l->append(base::StringPrintf("0x%p", p.get_handle())); | 55 l->append(base::StringPrintf("0x%p", p.get_handle())); |
| 54 l->append(base::IntToString(p.get_permissions())); | 56 l->append(base::IntToString(p.get_permissions())); |
| 55 } | 57 } |
| 56 | 58 |
| 57 } // namespace IPC | 59 } // namespace IPC |
| OLD | NEW |