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

Side by Side Diff: mojo/edk/system/dispatcher.cc

Issue 1946763002: EDK: Add MojoHandleRights to DispatcherTransport. (Closed) Base URL: https://github.com/domokit/mojo.git@work788_edk_handle_10
Patch Set: Created 4 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 | « mojo/edk/system/dispatcher.h ('k') | mojo/edk/system/handle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/edk/system/dispatcher.h" 5 #include "mojo/edk/system/dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/edk/system/configuration.h" 8 #include "mojo/edk/system/configuration.h"
9 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" 9 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" 10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h"
11 #include "mojo/edk/system/handle.h"
11 #include "mojo/edk/system/handle_transport.h" 12 #include "mojo/edk/system/handle_transport.h"
12 #include "mojo/edk/system/message_pipe_dispatcher.h" 13 #include "mojo/edk/system/message_pipe_dispatcher.h"
13 #include "mojo/edk/system/platform_handle_dispatcher.h" 14 #include "mojo/edk/system/platform_handle_dispatcher.h"
14 #include "mojo/edk/system/shared_buffer_dispatcher.h" 15 #include "mojo/edk/system/shared_buffer_dispatcher.h"
15 16
16 using mojo::platform::PlatformSharedBufferMapping; 17 using mojo::platform::PlatformSharedBufferMapping;
17 using mojo::platform::ScopedPlatformHandle; 18 using mojo::platform::ScopedPlatformHandle;
18 using mojo::util::MutexLocker; 19 using mojo::util::MutexLocker;
19 using mojo::util::RefPtr; 20 using mojo::util::RefPtr;
20 21
21 namespace mojo { 22 namespace mojo {
22 namespace system { 23 namespace system {
23 24
24 namespace test { 25 namespace test {
25 26
26 // TODO(vtl): Maybe this should be defined in a test-only file instead. 27 // TODO(vtl): Maybe this should be defined in a test-only file instead.
27 DispatcherTransport DispatcherTryStartTransport(Dispatcher* dispatcher) { 28 DispatcherTransport HandleTryStartTransport(const Handle& handle) {
28 return Dispatcher::HandleTableAccess::TryStartTransport(dispatcher); 29 return Dispatcher::HandleTableAccess::TryStartTransport(handle);
29 } 30 }
30 31
31 } // namespace test 32 } // namespace test
32 33
33 // TODO(vtl): The thread-safety analyzer isn't smart enough to deal with the 34 // TODO(vtl): The thread-safety analyzer isn't smart enough to deal with the
34 // fact that we give up if |TryLock()| fails. 35 // fact that we give up if |TryLock()| fails.
35 // static 36 // static
36 DispatcherTransport Dispatcher::HandleTableAccess::TryStartTransport( 37 DispatcherTransport Dispatcher::HandleTableAccess::TryStartTransport(
37 Dispatcher* dispatcher) MOJO_NO_THREAD_SAFETY_ANALYSIS { 38 const Handle& handle) MOJO_NO_THREAD_SAFETY_ANALYSIS {
38 DCHECK(dispatcher); 39 DCHECK(handle.dispatcher);
39 40
40 if (!dispatcher->mutex_.TryLock()) 41 if (!handle.dispatcher->mutex_.TryLock())
41 return DispatcherTransport(); 42 return DispatcherTransport();
42 43
43 // We shouldn't race with things that close dispatchers, since closing can 44 // We shouldn't race with things that close dispatchers, since closing can
44 // only take place either under |handle_table_mutex_| or when the handle is 45 // only take place either under |handle_table_mutex_| or when the handle is
45 // marked as busy. 46 // marked as busy.
46 DCHECK(!dispatcher->is_closed_); 47 DCHECK(!handle.dispatcher->is_closed_);
47 48
48 return DispatcherTransport(dispatcher); 49 return DispatcherTransport(handle);
49 } 50 }
50 51
51 // static 52 // static
52 void Dispatcher::TransportDataAccess::StartSerialize( 53 void Dispatcher::TransportDataAccess::StartSerialize(
53 Dispatcher* dispatcher, 54 Dispatcher* dispatcher,
54 Channel* channel, 55 Channel* channel,
55 size_t* max_size, 56 size_t* max_size,
56 size_t* max_platform_handles) { 57 size_t* max_platform_handles) {
57 DCHECK(dispatcher); 58 DCHECK(dispatcher);
58 dispatcher->StartSerialize(channel, max_size, max_platform_handles); 59 dispatcher->StartSerialize(channel, max_size, max_platform_handles);
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // want to remove or weaken). 567 // want to remove or weaken).
567 MutexLocker locker(&mutex_); 568 MutexLocker locker(&mutex_);
568 #endif 569 #endif
569 570
570 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size, 571 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size,
571 platform_handles); 572 platform_handles);
572 } 573 }
573 574
574 } // namespace system 575 } // namespace system
575 } // namespace mojo 576 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/dispatcher.h ('k') | mojo/edk/system/handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698