OLD | NEW |
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 #if defined(OS_POSIX) && (!defined(OS_MACOSX) || defined(OS_IOS)) && \ | 258 #if defined(OS_POSIX) && (!defined(OS_MACOSX) || defined(OS_IOS)) && \ |
259 !defined(OS_NACL) | 259 !defined(OS_NACL) |
260 using UniqueId = std::pair<dev_t, ino_t>; | 260 using UniqueId = std::pair<dev_t, ino_t>; |
261 | 261 |
262 struct UniqueIdHash { | 262 struct UniqueIdHash { |
263 size_t operator()(const UniqueId& id) const { | 263 size_t operator()(const UniqueId& id) const { |
264 return HashInts(id.first, id.second); | 264 return HashInts(id.first, id.second); |
265 } | 265 } |
266 }; | 266 }; |
267 | 267 |
268 // Returns a unique ID for this shared memory's handle. Note this function may | 268 // Returns a unique ID for the shared memory |handle|. Note this function may |
269 // access file system and be slow. | 269 // access file system and be slow. |
270 bool GetUniqueId(UniqueId* id) const; | 270 static bool GetUniqueId(const SharedMemoryHandle& handle, UniqueId* id); |
| 271 #else |
| 272 // TODO(hajimehoshi): On platforms other than POSIX, UniqueId and its getter |
| 273 // are work in progress. |
| 274 using UniqueId = int; |
| 275 |
| 276 struct UniqueIdHash { |
| 277 size_t operator()(const UniqueId& id) const { return id; } |
| 278 }; |
| 279 |
| 280 static bool GetUniqueId(const SharedMemoryHandle& handle, UniqueId* id) { |
| 281 *id = 0; |
| 282 return true; |
| 283 } |
271 #endif | 284 #endif |
272 | 285 |
273 private: | 286 private: |
274 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \ | 287 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \ |
275 (!defined(OS_MACOSX) || defined(OS_IOS)) | 288 (!defined(OS_MACOSX) || defined(OS_IOS)) |
276 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path); | 289 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path); |
277 #endif | 290 #endif |
278 | 291 |
279 enum ShareMode { | 292 enum ShareMode { |
280 SHARE_READONLY, | 293 SHARE_READONLY, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 void* memory_; | 326 void* memory_; |
314 bool read_only_; | 327 bool read_only_; |
315 size_t requested_size_; | 328 size_t requested_size_; |
316 | 329 |
317 DISALLOW_COPY_AND_ASSIGN(SharedMemory); | 330 DISALLOW_COPY_AND_ASSIGN(SharedMemory); |
318 }; | 331 }; |
319 | 332 |
320 } // namespace base | 333 } // namespace base |
321 | 334 |
322 #endif // BASE_MEMORY_SHARED_MEMORY_H_ | 335 #endif // BASE_MEMORY_SHARED_MEMORY_H_ |
OLD | NEW |