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

Side by Side Diff: extensions/browser/user_script_loader.cc

Issue 2845113005: Replace base::SharedMemory read-only methods with GetReadOnlyHandle. (Closed)
Patch Set: Comments from thakis. 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "extensions/browser/user_script_loader.h" 5 #include "extensions/browser/user_script_loader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 options.share_read_only = true; 325 options.share_read_only = true;
326 if (!shared_memory.Create(options)) 326 if (!shared_memory.Create(options))
327 return std::unique_ptr<base::SharedMemory>(); 327 return std::unique_ptr<base::SharedMemory>();
328 328
329 if (!shared_memory.Map(pickle.size())) 329 if (!shared_memory.Map(pickle.size()))
330 return std::unique_ptr<base::SharedMemory>(); 330 return std::unique_ptr<base::SharedMemory>();
331 331
332 // Copy the pickle to shared memory. 332 // Copy the pickle to shared memory.
333 memcpy(shared_memory.memory(), pickle.data(), pickle.size()); 333 memcpy(shared_memory.memory(), pickle.data(), pickle.size());
334 334
335 base::SharedMemoryHandle readonly_handle; 335 base::SharedMemoryHandle readonly_handle = shared_memory.GetReadOnlyHandle();
336 if (!shared_memory.ShareReadOnlyToProcess(base::GetCurrentProcessHandle(), 336 if (!readonly_handle.IsValid())
337 &readonly_handle))
338 return std::unique_ptr<base::SharedMemory>(); 337 return std::unique_ptr<base::SharedMemory>();
339 338
340 return base::MakeUnique<base::SharedMemory>(readonly_handle, 339 return base::MakeUnique<base::SharedMemory>(readonly_handle,
341 /*read_only=*/true); 340 /*read_only=*/true);
342 } 341 }
343 342
344 void UserScriptLoader::AddObserver(Observer* observer) { 343 void UserScriptLoader::AddObserver(Observer* observer) {
345 observers_.AddObserver(observer); 344 observers_.AddObserver(observer);
346 } 345 }
347 346
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 if (!shared_memory->ShareToProcess(handle, &handle_for_process)) 420 if (!shared_memory->ShareToProcess(handle, &handle_for_process))
422 return; // This can legitimately fail if the renderer asserts at startup. 421 return; // This can legitimately fail if the renderer asserts at startup.
423 422
424 if (base::SharedMemory::IsHandleValid(handle_for_process)) { 423 if (base::SharedMemory::IsHandleValid(handle_for_process)) {
425 process->Send(new ExtensionMsg_UpdateUserScripts( 424 process->Send(new ExtensionMsg_UpdateUserScripts(
426 handle_for_process, host_id(), changed_hosts, whitelisted_only)); 425 handle_for_process, host_id(), changed_hosts, whitelisted_only));
427 } 426 }
428 } 427 }
429 428
430 } // namespace extensions 429 } // namespace extensions
OLDNEW
« no previous file with comments | « content/browser/renderer_host/clipboard_message_filter_unittest.cc ('k') | mojo/edk/embedder/platform_shared_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698