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