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

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
« no previous file with comments | « no previous file | base/memory/shared_memory_posix.cc » ('j') | base/memory/shared_memory_tracker.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 // Returns a read-only handle to this shared memory region. The caller takes 228 // Returns a read-only handle to this shared memory region. The caller takes
229 // ownership of the handle. For POSIX handles, CHECK-fails if the region 229 // ownership of the handle. For POSIX handles, CHECK-fails if the region
230 // wasn't Created or Opened with share_read_only=true, which is required to 230 // wasn't Created or Opened with share_read_only=true, which is required to
231 // make the handle read-only. When the handle is passed to the IPC subsystem, 231 // make the handle read-only. When the handle is passed to the IPC subsystem,
232 // that takes ownership of the handle. As such, it's not valid to pass the 232 // that takes ownership of the handle. As such, it's not valid to pass the
233 // sample handle to the IPC subsystem twice. Returns an invalid handle on 233 // sample handle to the IPC subsystem twice. Returns an invalid handle on
234 // failure. 234 // failure.
235 SharedMemoryHandle GetReadOnlyHandle(); 235 SharedMemoryHandle GetReadOnlyHandle();
236 236
237 #if defined(OS_POSIX) && (!defined(OS_MACOSX) || defined(OS_IOS)) && \
238 !defined(OS_NACL)
239 using UniqueId = std::pair<dev_t, ino_t>;
240
241 struct UniqueIdHash {
242 size_t operator()(const UniqueId& id) const {
243 return HashInts(id.first, id.second);
244 }
245 };
246
247 // Returns a unique ID for this shared memory's handle. Note this function may
248 // access file system and be slow.
249 bool GetUniqueId(UniqueId* id) const;
250 #endif
251
252 // Returns the last error encountered as a result of a call to Create() or 237 // Returns the last error encountered as a result of a call to Create() or
253 // Map(). Note: Currently only errors from Mac POSIX shared memory 238 // Map(). Note: Currently only errors from Mac POSIX shared memory
254 // implementation are fully instrumented. 239 // implementation are fully instrumented.
255 // TODO(asvitkine): Evaluate whether we want to keep this ability after 240 // TODO(asvitkine): Evaluate whether we want to keep this ability after
256 // crbug.com/703649 is fixed and expand to all platforms or remove. 241 // crbug.com/703649 is fixed and expand to all platforms or remove.
257 SharedMemoryError get_last_error() const { return last_error_; } 242 SharedMemoryError get_last_error() const { return last_error_; }
258 243
259 private: 244 private:
260 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \ 245 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \
261 (!defined(OS_MACOSX) || defined(OS_IOS)) 246 (!defined(OS_MACOSX) || defined(OS_IOS))
(...skipping 25 matching lines...) Expand all
287 bool read_only_ = false; 272 bool read_only_ = false;
288 size_t requested_size_ = 0; 273 size_t requested_size_ = 0;
289 SharedMemoryError last_error_ = SharedMemoryError::NO_ERRORS; 274 SharedMemoryError last_error_ = SharedMemoryError::NO_ERRORS;
290 275
291 DISALLOW_COPY_AND_ASSIGN(SharedMemory); 276 DISALLOW_COPY_AND_ASSIGN(SharedMemory);
292 }; 277 };
293 278
294 } // namespace base 279 } // namespace base
295 280
296 #endif // BASE_MEMORY_SHARED_MEMORY_H_ 281 #endif // BASE_MEMORY_SHARED_MEMORY_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/shared_memory_posix.cc » ('j') | base/memory/shared_memory_tracker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698