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

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

Issue 2001673003: EDK: Add Core::DuplicateHandleWithReducedRights(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
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/dispatcher_unittest.cc » ('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"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 MojoResult Dispatcher::Close() { 102 MojoResult Dispatcher::Close() {
103 MutexLocker locker(&mutex_); 103 MutexLocker locker(&mutex_);
104 if (is_closed_) 104 if (is_closed_)
105 return MOJO_RESULT_INVALID_ARGUMENT; 105 return MOJO_RESULT_INVALID_ARGUMENT;
106 106
107 CloseNoLock(); 107 CloseNoLock();
108 return MOJO_RESULT_OK; 108 return MOJO_RESULT_OK;
109 } 109 }
110 110
111 MojoResult Dispatcher::DuplicateDispatcher(
112 util::RefPtr<Dispatcher>* new_dispatcher) {
113 MutexLocker locker(&mutex_);
114 if (is_closed_)
115 return MOJO_RESULT_INVALID_ARGUMENT;
116
117 return DuplicateDispatcherImplNoLock(new_dispatcher);
118 }
119
111 MojoResult Dispatcher::WriteMessage(UserPointer<const void> bytes, 120 MojoResult Dispatcher::WriteMessage(UserPointer<const void> bytes,
112 uint32_t num_bytes, 121 uint32_t num_bytes,
113 std::vector<HandleTransport>* transports, 122 std::vector<HandleTransport>* transports,
114 MojoWriteMessageFlags flags) { 123 MojoWriteMessageFlags flags) {
115 DCHECK(!transports || 124 DCHECK(!transports ||
116 (transports->size() > 0 && 125 (transports->size() > 0 &&
117 transports->size() < GetConfiguration().max_message_num_handles)); 126 transports->size() < GetConfiguration().max_message_num_handles));
118 127
119 MutexLocker locker(&mutex_); 128 MutexLocker locker(&mutex_);
120 if (is_closed_) 129 if (is_closed_)
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // will do something nontrivial. 320 // will do something nontrivial.
312 } 321 }
313 322
314 void Dispatcher::CloseImplNoLock() { 323 void Dispatcher::CloseImplNoLock() {
315 mutex_.AssertHeld(); 324 mutex_.AssertHeld();
316 DCHECK(is_closed_); 325 DCHECK(is_closed_);
317 // This may not need to do anything. Dispatchers should override this to do 326 // This may not need to do anything. Dispatchers should override this to do
318 // any actual close-time cleanup necessary. 327 // any actual close-time cleanup necessary.
319 } 328 }
320 329
330 MojoResult Dispatcher::DuplicateDispatcherImplNoLock(
331 util::RefPtr<Dispatcher>* new_dispatcher) {
332 mutex_.AssertHeld();
333 DCHECK(!is_closed_);
334 // By default, this is not supported. However, this should only be reachable
335 // if a handle has the |MOJO_HANDLE_RIGHT_DUPLICATE| right, which it should
336 // only have if it is supported.
337 NOTREACHED();
338 return MOJO_RESULT_INTERNAL;
339 }
340
321 MojoResult Dispatcher::WriteMessageImplNoLock( 341 MojoResult Dispatcher::WriteMessageImplNoLock(
322 UserPointer<const void> /*bytes*/, 342 UserPointer<const void> /*bytes*/,
323 uint32_t /*num_bytes*/, 343 uint32_t /*num_bytes*/,
324 std::vector<HandleTransport>* /*transports*/, 344 std::vector<HandleTransport>* /*transports*/,
325 MojoWriteMessageFlags /*flags*/) { 345 MojoWriteMessageFlags /*flags*/) {
326 mutex_.AssertHeld(); 346 mutex_.AssertHeld();
327 DCHECK(!is_closed_); 347 DCHECK(!is_closed_);
328 // By default, not supported. Only needed for message pipe dispatchers. 348 // By default, not supported. Only needed for message pipe dispatchers.
329 return MOJO_RESULT_INVALID_ARGUMENT; 349 return MOJO_RESULT_INVALID_ARGUMENT;
330 } 350 }
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 // want to remove or weaken). 584 // want to remove or weaken).
565 MutexLocker locker(&mutex_); 585 MutexLocker locker(&mutex_);
566 #endif 586 #endif
567 587
568 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size, 588 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size,
569 platform_handles); 589 platform_handles);
570 } 590 }
571 591
572 } // namespace system 592 } // namespace system
573 } // namespace mojo 593 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/dispatcher.h ('k') | mojo/edk/system/dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698