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> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 // static | 32 // static |
33 bool ParamTraits<HandleWin>::Read(const base::Pickle* m, | 33 bool ParamTraits<HandleWin>::Read(const base::Pickle* m, |
34 base::PickleIterator* iter, | 34 base::PickleIterator* iter, |
35 param_type* r) { | 35 param_type* r) { |
36 scoped_refptr<base::Pickle::Attachment> base_attachment; | 36 scoped_refptr<base::Pickle::Attachment> base_attachment; |
37 if (!m->ReadAttachment(iter, &base_attachment)) | 37 if (!m->ReadAttachment(iter, &base_attachment)) |
38 return false; | 38 return false; |
39 MessageAttachment* attachment = | 39 MessageAttachment* attachment = |
40 static_cast<MessageAttachment*>(base_attachment.get()); | 40 static_cast<MessageAttachment*>(base_attachment.get()); |
41 if (attachment->GetType() != MessageAttachment::TYPE_BROKERABLE_ATTACHMENT) | 41 if (attachment->GetType() != MessageAttachment::Type::WIN_HANDLE) |
42 return false; | 42 return false; |
43 BrokerableAttachment* brokerable_attachment = | |
44 static_cast<BrokerableAttachment*>(attachment); | |
45 if (brokerable_attachment->GetBrokerableType() != | |
46 BrokerableAttachment::WIN_HANDLE) { | |
47 return false; | |
48 } | |
49 IPC::internal::HandleAttachmentWin* handle_attachment = | 43 IPC::internal::HandleAttachmentWin* handle_attachment = |
50 static_cast<IPC::internal::HandleAttachmentWin*>(brokerable_attachment); | 44 static_cast<IPC::internal::HandleAttachmentWin*>(attachment); |
51 r->set_handle(handle_attachment->get_handle()); | 45 r->set_handle(handle_attachment->get_handle()); |
52 handle_attachment->reset_handle_ownership(); | 46 handle_attachment->reset_handle_ownership(); |
53 return true; | 47 return true; |
54 } | 48 } |
55 | 49 |
56 // static | 50 // static |
57 void ParamTraits<HandleWin>::Log(const param_type& p, std::string* l) { | 51 void ParamTraits<HandleWin>::Log(const param_type& p, std::string* l) { |
58 l->append(base::StringPrintf("0x%p", p.get_handle())); | 52 l->append(base::StringPrintf("0x%p", p.get_handle())); |
59 l->append(base::IntToString(p.get_permissions())); | 53 l->append(base::IntToString(p.get_permissions())); |
60 } | 54 } |
61 | 55 |
62 } // namespace IPC | 56 } // namespace IPC |
OLD | NEW |