Home | History | Annotate | Download | only in memory
      1 // Copyright 2016 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 #ifndef BASE_MEMORY_SHARED_MEMORY_HELPER_H_
      6 #define BASE_MEMORY_SHARED_MEMORY_HELPER_H_
      7 
      8 #include "base/memory/shared_memory.h"
      9 
     10 #include <fcntl.h>
     11 
     12 namespace base {
     13 
     14 #if !defined(OS_ANDROID)
     15 // Makes a temporary file, fdopens it, and then unlinks it. |fp| is populated
     16 // with the fdopened FILE. |readonly_fd| is populated with the opened fd if
     17 // options.share_read_only is true. |path| is populated with the location of
     18 // the file before it was unlinked.
     19 // Returns false if there's an unhandled failure.
     20 bool CreateAnonymousSharedMemory(const SharedMemoryCreateOptions& options,
     21                                  ScopedFILE* fp,
     22                                  ScopedFD* readonly_fd,
     23                                  FilePath* path);
     24 
     25 // Takes the outputs of CreateAnonymousSharedMemory and maps them properly to
     26 // |mapped_file| or |readonly_mapped_file|, depending on which one is populated.
     27 bool PrepareMapFile(ScopedFILE fp, ScopedFD readonly_fd, int* mapped_file,
     28                     int* readonly_mapped_file);
     29 #endif
     30 
     31 }  // namespace base
     32 
     33 #endif  // BASE_MEMORY_SHARED_MEMORY_HELPER_H_
     34