diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-24 23:18:10 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-24 23:18:10 +0000 |
commit | 5bd3268b2040e950d4aed108a35aec8affdbc5d0 (patch) | |
tree | 9fa7114819cad6f6d3aeb0c08a38aae9f1980d21 /ppapi/api | |
parent | dd1ba69a3afddd98dd4c69b9f7022834b43f8800 (diff) | |
download | chromium_src-5bd3268b2040e950d4aed108a35aec8affdbc5d0.zip chromium_src-5bd3268b2040e950d4aed108a35aec8affdbc5d0.tar.gz chromium_src-5bd3268b2040e950d4aed108a35aec8affdbc5d0.tar.bz2 |
PPAPI: Move file mapping to new PPB_FileMapping API
This CL moves Map/Unmap etc to a new PPB_FileMapping API, as we discussed previously. (Unfortunately, somehow that e-mail thread dropped off the public list :-( ).
This also changes Unmap to use a completion callback. In "shared" mode,
Unmap commits any changes that were made in the mapped memory region to
the backing file, which could take a long time (analogous to FileIO::Flush).
I have a POSIX implementation mostly working and mostly tested here: https://codereview.chromium.org/69663002/
...but I'm trying to break it in to smaller pieces.
BUG=83774
Review URL: https://codereview.chromium.org/139853007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/api')
-rw-r--r-- | ppapi/api/dev/ppb_file_io_dev.idl | 116 | ||||
-rw-r--r-- | ppapi/api/ppb_file_mapping.idl | 129 |
2 files changed, 129 insertions, 116 deletions
diff --git a/ppapi/api/dev/ppb_file_io_dev.idl b/ppapi/api/dev/ppb_file_io_dev.idl deleted file mode 100644 index 82a64521..0000000 --- a/ppapi/api/dev/ppb_file_io_dev.idl +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (c) 2013 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. - */ - - -/** - * This file defines methods for use with a PPB_FileIO resource that may become - * stable in the future. For now, they can be used only in plugins with DEV - * permissions. - */ - -label Chrome { - M31 = 0.1 -}; - -/** - * The PP_FileMapProtection values indicate the permissions requested for the - * file mapping. These should be used in a uint32_t bitfield. - */ -[assert_size(4)] - enum PP_FileMapProtection { - /** Requests read access to the mapped address. */ - PP_FILEMAPPROTECTION_READ = 1u << 0, - - /** Requests write access to the mapped address. */ - PP_FILEMAPPROTECTION_WRITE = 1u << 1 -}; - -/** - * The PP_FileMapFlags contain flag values for use with Map(). - */ -[assert_size(4)] - enum PP_FileMapFlags { - /** - * Requests a shared mapping. If this flag is set, changes written to the - * memory region will be reflected in the underlying file and will thus - * eventually be visible to other processes which have opened the file. The - * file may not actually be updated until Unmap() is called. This is only - * valid if the PPB_FileIO resource was opened with write permission. - */ - PP_FILEMAPFLAG_SHARED = 1u << 0, - - /** - * Requests a copy-on-write mapping. If this flag is set, changes are not - * written to the underlying file, but only in the memory of the process - * (copy-on-write). - */ - PP_FILEMAPFLAG_PRIVATE = 1u << 1, - - /** - * Forces Map() to map the file contents at the provided |address|. If Map() - * can not comply, Map() will fail. - */ - PP_FILEMAPFLAG_FIXED = 1u << 2 -}; - -/** - * PPB_FileIO_Dev contains functions that are usable with PPB_FileIO resources - * but aren't yet considered stable yet and thus are not supported for general - * NaCl or PNaCl apps yet. Features here are being tested and refined for - * possible future inclusion in (stable) PPB_FileIO. - */ -interface PPB_FileIO_Dev { - /** - * Map() maps the contents from an offset of the file into memory. - * - * @param[in] file_io A PP_Resource corresponding to a file. - * @param[in] length The number of bytes to map. - * @param[in] map_protection A bitfield containing values from - * PP_FileMapProtection, indicating what memory operations should be permitted - * on the mapped region. - * @param[in] map_flags A bitfield containing values from - * PP_FileMapFlags, providing options for the behavior of Map. If the region - * is to be writeable, then exactly one of PP_FILEMAPFLAG_SHARED or - * PP_FILEMAPFLAG_PRIVATE must be set. - * @param[in] offset The offset into the file. Must be a multiple of the - * Map page size as returned by GetMapPageSize. - * @param[inout] address The value of |*address|, if non-NULL, will be used as - * a hint to determine where in memory the file should be mapped. If the value - * is NULL, the host operating system will choose |address|. Upon - * Map() completing, |*address| will contain the actual memory location at - * which the file was mapped. If the plugin provides a non-NULL |*address|, it - * must be a multiple of the map page size as returned by GetMapPageSize(). - * @param[in] callback A PP_CompletionCallback to be called upon - * completion of Map(). - * - * @return An int32_t containing an error code from <code>pp_errors.h</code>. - */ - int32_t Map([in] PP_Resource file_io, - [in] int64_t length, - [in] uint32_t map_protection, - [in] uint32_t map_flags, - [in] int64_t offset, - [inout] mem_ptr_t address, - [in] PP_CompletionCallback callback); - - /** - * Unmap() deletes the mapping of the specified address address to a - * file io. The specified address must have been retrieved with - * Map(). - * @param[in] file_io A PP_Resource corresponding to a file. - * @param[in] address The starting address of the address in memory to - * be unmapped. - * @param[in] length The length of the region to unmap. - */ - void Unmap(PP_Resource file_io, mem_t address, int64_t length); - - /** - * GetMapPageSize() returns the size of pages that Map() uses. Returns 0 on - * failure. - */ - [on_failure=0] - int64_t GetMapPageSize(PP_Resource file_io); -}; - diff --git a/ppapi/api/ppb_file_mapping.idl b/ppapi/api/ppb_file_mapping.idl new file mode 100644 index 0000000..2a10946 --- /dev/null +++ b/ppapi/api/ppb_file_mapping.idl @@ -0,0 +1,129 @@ +/* Copyright 2014 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. + */ + + +/** + * This file defines methods for mapping and unmapping files into and out of + * memory. + */ + +label Chrome { + [channel=dev] M34 = 0.1 +}; + +/** + * The PP_FileMapProtection values indicate the permissions requested for the + * file mapping. These should be used in a uint32_t bitfield. + */ +[assert_size(4)] +enum PP_FileMapProtection { + /** Requests read access to the mapped address. */ + PP_FILEMAPPROTECTION_READ = 1u << 0, + + /** Requests write access to the mapped address. */ + PP_FILEMAPPROTECTION_WRITE = 1u << 1 +}; + +/** + * The PP_FileMapFlags contain flag values for use with Map(). + */ +[assert_size(4)] +enum PP_FileMapFlags { + /** + * Requests a shared mapping. If this flag is set, changes written to the + * memory region will be reflected in the underlying file and will thus + * eventually be visible to other processes which have opened the file. The + * file may not actually be updated until Unmap() is called. This is only + * valid if the PPB_FileIO resource was opened with write permission. + */ + PP_FILEMAPFLAG_SHARED = 1u << 0, + + /** + * Requests a copy-on-write mapping. If this flag is set, changes are not + * written to the underlying file, but only in the memory of the process + * (copy-on-write). + */ + PP_FILEMAPFLAG_PRIVATE = 1u << 1, + + /** + * Forces Map() to map the file contents at the provided |address|. If Map() + * can not comply, Map() will fail. + */ + PP_FILEMAPFLAG_FIXED = 1u << 2 +}; + +/** + * PPB_FileMapping contains functions for mapping and unmapping files into and + * out of memory. + */ +[singleton] +interface PPB_FileMapping { + /** + * Map() maps the contents from an offset of the file into memory. + * + * @param[in] instance A <code>PP_Instance</code> identifying one instance of + * a module. + * @param[in] file_io A <code>PPB_FileIO</code> <code>PP_Resource</code> + * corresponding to the file that should be mapped in to memory. + * @param[in] length The number of bytes to map. + * @param[in] map_protection A bitfield containing values from + * <code>PP_FileMapProtection</code>, indicating what memory operations + * should be permitted on the mapped region. + * @param[in] map_flags A bitfield containing values from + * <code>PP_FileMapFlags</code>, providing options for the behavior of Map. + * If the region is to be writeable, then exactly one of + * <code>PP_FILEMAPFLAG_SHARED</code> or <code>PP_FILEMAPFLAG_PRIVATE</code> + * must be set. + * @param[in] offset The offset into the file. Must be a multiple of the + * Map page size as returned by GetMapPageSize(). + * @param[inout] address The value of <code>*address</code>, if non-NULL, + * will be used as a hint to determine where in memory the file should be + * mapped. If the value is NULL, the host operating system will choose + * <code>address</code>. Upon Map() completing, <code>*address</code> will + * contain the actual memory location at which the file was mapped. If the + * plugin provides a non-NULL <code>*address</code>, it must be a multiple of + * the map page size as returned by GetMapPageSize(). + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of Map(). + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t Map([in] PP_Instance instance, + [in] PP_Resource file_io, + [in] int64_t length, + [in] uint32_t map_protection, + [in] uint32_t map_flags, + [in] int64_t offset, + [inout] mem_ptr_t address, + [in] PP_CompletionCallback callback); + + /** + * Unmap() deletes the mapping of the specified address. The specified + * address must have been retrieved with Map(). + * @param[in] instance A <code>PP_Instance</code> identifying the instance. + * @param[in] address The starting address of the address in memory to + * be unmapped. + * @param[in] length The length of the region to unmap. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion of Unmap(). + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t Unmap([in] PP_Instance instance, + [in] mem_t address, + [in] int64_t length, + [in] PP_CompletionCallback callback); + + /** + * GetMapPageSize() retrieves the size of pages that Map() uses. + * + * @param[in] instance A <code>PP_Instance</code> identifying the instance. + * + * @return The size of pages that Map() uses. Returns 0 on failure. + */ + [on_failure=0] + int64_t GetMapPageSize(PP_Instance instance); +}; + |