Chromium 中chrome.system.memory扩展接口定义c++
一、chrome.system.memory
chrome.system.memory
API。
权限
system.memory
类型
MemoryInfo
属性
-
availableCapacity
number
可用容量的量(以字节为单位)。
-
容量
number
物理内存容量的总容量(以字节为单位)。
方法
getInfo()
<ph type="x-smartling-placeholder"></ph> 承诺
chrome.system.memory.getInfo(callback?: function, )
获取物理内存信息。
参数
-
callback
函数(可选)
callback
参数如下所示:(info: MemoryInfo) => void
chrome.system.memory | API | Chrome for Developers
二、chrome.system.memory
API c++接口定义:
1、system_memory.idl
extensions\common\api\system_memory.idl
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.// The <code>chrome.system.memory</code> API.
namespace system.memory {dictionary MemoryInfo {// The total amount of physical memory capacity, in bytes.double capacity;// The amount of available capacity, in bytes.double availableCapacity;};callback MemoryInfoCallback = void (MemoryInfo info);interface Functions {// Get physical memory information.[supportsPromises] static void getInfo(MemoryInfoCallback callback);};
};
2、system_memory.idl 自动生成c++文件:
out\Debug\gen\extensions\common\api\system_memory.cc
out\Debug\gen\extensions\common\api\system_memory.h
3、chrome.system.memory
API 接口定义c++:
extensions\browser\api\system_memory\system_memory_api.h
extensions\browser\api\system_memory\system_memory_api.cc
namespace extensions {class SystemMemoryGetInfoFunction : public ExtensionFunction {public:DECLARE_EXTENSION_FUNCTION("system.memory.getInfo", SYSTEM_MEMORY_GETINFO)SystemMemoryGetInfoFunction() = default;SystemMemoryGetInfoFunction(const SystemMemoryGetInfoFunction&) = delete;SystemMemoryGetInfoFunction& operator=(const SystemMemoryGetInfoFunction&) =delete;private:~SystemMemoryGetInfoFunction() override = default;// ExtensionFunction:ResponseAction Run() override;void OnGetMemoryInfoCompleted(bool success);
};} // namespace extensions