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

Unified Diff: chrome/browser/extensions/user_script_master.cc

Issue 27265002: Implement SharedMemory::NewAnonymousReadOnly(contents). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mark's comments Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/shared_memory_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/user_script_master.cc
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc
index 3c3dc69add5e3bf677cf8ebbf272218d5dedf560..80b6bf72064591efc1fec7e6e53c8dc154543cbf 100644
--- a/chrome/browser/extensions/user_script_master.cc
+++ b/chrome/browser/extensions/user_script_master.cc
@@ -285,15 +285,20 @@ static base::SharedMemory* Serialize(const UserScriptList& scripts) {
}
// Create the shared memory object.
- scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory());
+ base::SharedMemory shared_memory;
- if (!shared_memory->CreateAndMapAnonymous(pickle.size()))
+ if (!shared_memory.CreateAndMapAnonymous(pickle.size()))
return NULL;
// Copy the pickle to shared memory.
- memcpy(shared_memory->memory(), pickle.data(), pickle.size());
+ memcpy(shared_memory.memory(), pickle.data(), pickle.size());
- return shared_memory.release();
+ base::SharedMemoryHandle readonly_handle;
+ if (!shared_memory.ShareReadOnlyToProcess(base::GetCurrentProcessHandle(),
+ &readonly_handle))
+ return NULL;
+
+ return new base::SharedMemory(readonly_handle, /*read_only=*/true);
}
// This method will be called on the file thread.
« no previous file with comments | « base/memory/shared_memory_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698