Ai
2 Star 0 Fork 0

chromium_develop/chromium_ipc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
handle_win.cc 1.66 KB
一键复制 编辑 原始数据 按行查看 历史
李想 提交于 2022-08-16 15:52 +08:00 . chromium origin init
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ipc/handle_win.h"
#include <utility>
#include "base/memory/ref_counted.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "ipc/handle_attachment_win.h"
#include "ipc/ipc_message.h"
namespace IPC {
HandleWin::HandleWin() : handle_(INVALID_HANDLE_VALUE) {}
HandleWin::HandleWin(const HANDLE& handle) : handle_(handle) {}
// static
void ParamTraits<HandleWin>::Write(base::Pickle* m, const param_type& p) {
scoped_refptr<IPC::internal::HandleAttachmentWin> attachment(
new IPC::internal::HandleAttachmentWin(p.get_handle()));
if (!m->WriteAttachment(std::move(attachment)))
NOTREACHED();
}
// static
bool ParamTraits<HandleWin>::Read(const base::Pickle* m,
base::PickleIterator* iter,
param_type* r) {
scoped_refptr<base::Pickle::Attachment> base_attachment;
if (!m->ReadAttachment(iter, &base_attachment))
return false;
MessageAttachment* attachment =
static_cast<MessageAttachment*>(base_attachment.get());
if (attachment->GetType() != MessageAttachment::Type::WIN_HANDLE)
return false;
IPC::internal::HandleAttachmentWin* handle_attachment =
static_cast<IPC::internal::HandleAttachmentWin*>(attachment);
r->set_handle(handle_attachment->Take());
return true;
}
// static
void ParamTraits<HandleWin>::Log(const param_type& p, std::string* l) {
l->append(base::StringPrintf("0x%p", p.get_handle()));
}
} // namespace IPC
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chromium_develop/chromium_ipc.git
git@gitee.com:chromium_develop/chromium_ipc.git
chromium_develop
chromium_ipc
chromium_ipc
master

搜索帮助