Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: base/memory/shared_memory.h

Issue 2873433004: Replace SharedMemory::UniqueID usages with SharedMemoryHandle's guid (Closed)
Patch Set: Address on reviews Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MEMORY_SHARED_MEMORY_H_ 5 #ifndef BASE_MEMORY_SHARED_MEMORY_H_
6 #define BASE_MEMORY_SHARED_MEMORY_H_ 6 #define BASE_MEMORY_SHARED_MEMORY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 // Returns a read-only handle to this shared memory region. The caller takes 211 // Returns a read-only handle to this shared memory region. The caller takes
212 // ownership of the handle. For POSIX handles, CHECK-fails if the region 212 // ownership of the handle. For POSIX handles, CHECK-fails if the region
213 // wasn't Created or Opened with share_read_only=true, which is required to 213 // wasn't Created or Opened with share_read_only=true, which is required to
214 // make the handle read-only. When the handle is passed to the IPC subsystem, 214 // make the handle read-only. When the handle is passed to the IPC subsystem,
215 // that takes ownership of the handle. As such, it's not valid to pass the 215 // that takes ownership of the handle. As such, it's not valid to pass the
216 // sample handle to the IPC subsystem twice. Returns an invalid handle on 216 // sample handle to the IPC subsystem twice. Returns an invalid handle on
217 // failure. 217 // failure.
218 SharedMemoryHandle GetReadOnlyHandle(); 218 SharedMemoryHandle GetReadOnlyHandle();
219 219
220 #if defined(OS_POSIX) && (!defined(OS_MACOSX) || defined(OS_IOS)) && \ 220 // Uniques identifies the shared memory region that the underlying OS resource
221 !defined(OS_NACL) 221 // points to. This just returns its handler's GUID.
222 using UniqueId = std::pair<dev_t, ino_t>; 222 base::UnguessableToken GetGUID() const;
erikchen 2017/05/10 20:14:16 Please avoid adding this method to SharedMemory -
hajimehoshi 2017/05/11 10:26:00 Done.
223
224 struct UniqueIdHash {
225 size_t operator()(const UniqueId& id) const {
226 return HashInts(id.first, id.second);
227 }
228 };
229
230 // Returns a unique ID for this shared memory's handle. Note this function may
231 // access file system and be slow.
232 bool GetUniqueId(UniqueId* id) const;
233 #endif
234 223
235 private: 224 private:
236 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \ 225 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \
237 (!defined(OS_MACOSX) || defined(OS_IOS)) 226 (!defined(OS_MACOSX) || defined(OS_IOS))
238 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path); 227 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path);
239 #endif 228 #endif
240 229
241 #if defined(OS_WIN) 230 #if defined(OS_WIN)
242 // If true indicates this came from an external source so needs extra checks 231 // If true indicates this came from an external source so needs extra checks
243 // before being mapped. 232 // before being mapped.
(...skipping 19 matching lines...) Expand all
263 void* memory_; 252 void* memory_;
264 bool read_only_; 253 bool read_only_;
265 size_t requested_size_; 254 size_t requested_size_;
266 255
267 DISALLOW_COPY_AND_ASSIGN(SharedMemory); 256 DISALLOW_COPY_AND_ASSIGN(SharedMemory);
268 }; 257 };
269 258
270 } // namespace base 259 } // namespace base
271 260
272 #endif // BASE_MEMORY_SHARED_MEMORY_H_ 261 #endif // BASE_MEMORY_SHARED_MEMORY_H_
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/memory/shared_memory.cc » ('j') | base/memory/shared_memory.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698