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

Side by Side Diff: ipc/handle_win.cc

Issue 1281083004: ipc: Add the class HandleWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add logging. Created 5 years, 4 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 | « ipc/handle_win.h ('k') | ipc/ipc.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ipc/handle_win.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "ipc/handle_attachment_win.h"
11
12 namespace IPC {
13
14 HandleWin::HandleWin(const HANDLE& handle, Permissions permissions)
15 : handle_(handle), permissions_(permissions) {}
16
17 // static
18 void ParamTraits<HandleWin>::Write(Message* m, const param_type& p) {
19 scoped_refptr<IPC::internal::HandleAttachmentWin> attachment(
20 new IPC::internal::HandleAttachmentWin(p.get_handle(),
21 p.get_permissions()));
22 if (!m->WriteAttachment(attachment.Pass()))
23 NOTREACHED();
24 }
25
26 // static
27 bool ParamTraits<HandleWin>::Read(const Message* m,
28 base::PickleIterator* iter,
29 param_type* r) {
30 scoped_refptr<MessageAttachment> attachment;
31 if (!m->ReadAttachment(iter, &attachment))
32 return false;
33 if (attachment->GetType() != MessageAttachment::TYPE_BROKERABLE_ATTACHMENT)
34 return false;
35 BrokerableAttachment* brokerable_attachment =
36 static_cast<BrokerableAttachment*>(attachment.get());
37 if (brokerable_attachment->GetBrokerableType() !=
38 BrokerableAttachment::WIN_HANDLE) {
39 return false;
40 }
41 IPC::internal::HandleAttachmentWin* handle_attachment =
42 static_cast<IPC::internal::HandleAttachmentWin*>(brokerable_attachment);
43 r->set_handle(handle_attachment->get_handle());
44 return true;
45 }
46
47 // static
48 void ParamTraits<HandleWin>::Log(const param_type& p, std::string* l) {
49 l->append(base::StringPrintf("0x%X", p.get_handle()));
50 l->append(base::IntToString(p.get_permissions()));
51 }
52
53 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/handle_win.h ('k') | ipc/ipc.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698