Add ICU message format support
[chromium-blink-merge.git] / ipc / handle_attachment_win.cc
blob994b22dddca2e90df60db91ca1df906cdc6ea153
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.
5 #include "ipc/handle_attachment_win.h"
7 #include <windows.h>
9 namespace IPC {
10 namespace internal {
12 HandleAttachmentWin::HandleAttachmentWin(const HANDLE& handle)
13 : handle_(handle) {
16 HandleAttachmentWin::HandleAttachmentWin(const WireFormat& wire_format)
17 : BrokerableAttachment(wire_format.attachment_id, false),
18 handle_(LongToHandle(wire_format.handle)) {}
20 HandleAttachmentWin::HandleAttachmentWin(
21 const BrokerableAttachment::AttachmentId& id)
22 : BrokerableAttachment(id, true), handle_(INVALID_HANDLE_VALUE) {}
24 HandleAttachmentWin::~HandleAttachmentWin() {
27 HandleAttachmentWin::BrokerableType HandleAttachmentWin::GetBrokerableType()
28 const {
29 return WIN_HANDLE;
32 void HandleAttachmentWin::PopulateWithAttachment(
33 const BrokerableAttachment* attachment) {
34 DCHECK(NeedsBrokering());
35 DCHECK(!attachment->NeedsBrokering());
36 DCHECK(GetIdentifier() == attachment->GetIdentifier());
37 DCHECK_EQ(GetBrokerableType(), attachment->GetBrokerableType());
39 const HandleAttachmentWin* handle_attachment =
40 static_cast<const HandleAttachmentWin*>(attachment);
41 handle_ = handle_attachment->handle_;
42 SetNeedsBrokering(false);
45 HandleAttachmentWin::WireFormat HandleAttachmentWin::GetWireFormat(
46 const base::ProcessId& destination) const {
47 WireFormat format;
48 format.handle = HandleToLong(handle_);
49 format.attachment_id = GetIdentifier();
50 format.destination_process = destination;
51 return format;
54 } // namespace internal
55 } // namespace IPC