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

Side by Side Diff: mojo/system/core.cc

Issue 471773002: Mojo: Add a platform interface for shared memory (embedder::PlatformSharedBuffer). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "mojo/system/core.h" 5 #include "mojo/system/core.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "mojo/embedder/platform_shared_buffer.h"
11 #include "mojo/public/c/system/macros.h" 12 #include "mojo/public/c/system/macros.h"
12 #include "mojo/system/constants.h" 13 #include "mojo/system/constants.h"
13 #include "mojo/system/data_pipe.h" 14 #include "mojo/system/data_pipe.h"
14 #include "mojo/system/data_pipe_consumer_dispatcher.h" 15 #include "mojo/system/data_pipe_consumer_dispatcher.h"
15 #include "mojo/system/data_pipe_producer_dispatcher.h" 16 #include "mojo/system/data_pipe_producer_dispatcher.h"
16 #include "mojo/system/dispatcher.h" 17 #include "mojo/system/dispatcher.h"
17 #include "mojo/system/handle_signals_state.h" 18 #include "mojo/system/handle_signals_state.h"
18 #include "mojo/system/local_data_pipe.h" 19 #include "mojo/system/local_data_pipe.h"
19 #include "mojo/system/memory.h" 20 #include "mojo/system/memory.h"
20 #include "mojo/system/message_pipe.h" 21 #include "mojo/system/message_pipe.h"
21 #include "mojo/system/message_pipe_dispatcher.h" 22 #include "mojo/system/message_pipe_dispatcher.h"
22 #include "mojo/system/raw_shared_buffer.h"
23 #include "mojo/system/shared_buffer_dispatcher.h" 23 #include "mojo/system/shared_buffer_dispatcher.h"
24 #include "mojo/system/waiter.h" 24 #include "mojo/system/waiter.h"
25 25
26 namespace mojo { 26 namespace mojo {
27 namespace system { 27 namespace system {
28 28
29 // Implementation notes 29 // Implementation notes
30 // 30 //
31 // Mojo primitives are implemented by the singleton |Core| object. Most calls 31 // Mojo primitives are implemented by the singleton |Core| object. Most calls
32 // are for a "primary" handle (the first argument). |Core::GetDispatcher()| is 32 // are for a "primary" handle (the first argument). |Core::GetDispatcher()| is
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 509
510 MojoResult Core::MapBuffer(MojoHandle buffer_handle, 510 MojoResult Core::MapBuffer(MojoHandle buffer_handle,
511 uint64_t offset, 511 uint64_t offset,
512 uint64_t num_bytes, 512 uint64_t num_bytes,
513 UserPointer<void*> buffer, 513 UserPointer<void*> buffer,
514 MojoMapBufferFlags flags) { 514 MojoMapBufferFlags flags) {
515 scoped_refptr<Dispatcher> dispatcher(GetDispatcher(buffer_handle)); 515 scoped_refptr<Dispatcher> dispatcher(GetDispatcher(buffer_handle));
516 if (!dispatcher) 516 if (!dispatcher)
517 return MOJO_RESULT_INVALID_ARGUMENT; 517 return MOJO_RESULT_INVALID_ARGUMENT;
518 518
519 scoped_ptr<RawSharedBufferMapping> mapping; 519 scoped_ptr<embedder::PlatformSharedBufferMapping> mapping;
520 MojoResult result = dispatcher->MapBuffer(offset, num_bytes, flags, &mapping); 520 MojoResult result = dispatcher->MapBuffer(offset, num_bytes, flags, &mapping);
521 if (result != MOJO_RESULT_OK) 521 if (result != MOJO_RESULT_OK)
522 return result; 522 return result;
523 523
524 DCHECK(mapping); 524 DCHECK(mapping);
525 void* address = mapping->base(); 525 void* address = mapping->GetBase();
526 { 526 {
527 base::AutoLock locker(mapping_table_lock_); 527 base::AutoLock locker(mapping_table_lock_);
528 result = mapping_table_.AddMapping(mapping.Pass()); 528 result = mapping_table_.AddMapping(mapping.Pass());
529 } 529 }
530 if (result != MOJO_RESULT_OK) 530 if (result != MOJO_RESULT_OK)
531 return result; 531 return result;
532 532
533 buffer.Put(address); 533 buffer.Put(address);
534 return MOJO_RESULT_OK; 534 return MOJO_RESULT_OK;
535 } 535 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 if (signals_states) { 594 if (signals_states) {
595 for (; i < num_handles; i++) 595 for (; i < num_handles; i++)
596 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); 596 signals_states[i] = dispatchers[i]->GetHandleSignalsState();
597 } 597 }
598 598
599 return rv; 599 return rv;
600 } 600 }
601 601
602 } // namespace system 602 } // namespace system
603 } // namespace mojo 603 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698