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

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

Issue 728043002: Revert of Update mojo sdk to rev afb4440fd5a10cba980878c326180b7ad7960480 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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/constants.h"
9 #include "mojo/edk/system/message_pipe_dispatcher.h" 9 #include "mojo/edk/system/message_pipe_dispatcher.h"
10 #include "mojo/edk/system/platform_handle_dispatcher.h" 10 #include "mojo/edk/system/platform_handle_dispatcher.h"
11 #include "mojo/edk/system/shared_buffer_dispatcher.h" 11 #include "mojo/edk/system/shared_buffer_dispatcher.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace system { 14 namespace system {
15 15
16 namespace test { 16 namespace test {
17 17
18 // TODO(vtl): Maybe this should be defined in a test-only file instead. 18 // TODO(vtl): Maybe this should be defined in a test-only file instead.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 // static 53 // static
54 bool Dispatcher::TransportDataAccess::EndSerializeAndClose( 54 bool Dispatcher::TransportDataAccess::EndSerializeAndClose(
55 Dispatcher* dispatcher, 55 Dispatcher* dispatcher,
56 Channel* channel, 56 Channel* channel,
57 void* destination, 57 void* destination,
58 size_t* actual_size, 58 size_t* actual_size,
59 embedder::PlatformHandleVector* platform_handles) { 59 embedder::PlatformHandleVector* platform_handles) {
60 DCHECK(dispatcher); 60 DCHECK(dispatcher);
61 return dispatcher->EndSerializeAndClose(channel, destination, actual_size, 61 return dispatcher->EndSerializeAndClose(
62 platform_handles); 62 channel, destination, actual_size, platform_handles);
63 } 63 }
64 64
65 // static 65 // static
66 scoped_refptr<Dispatcher> Dispatcher::TransportDataAccess::Deserialize( 66 scoped_refptr<Dispatcher> Dispatcher::TransportDataAccess::Deserialize(
67 Channel* channel, 67 Channel* channel,
68 int32_t type, 68 int32_t type,
69 const void* source, 69 const void* source,
70 size_t size, 70 size_t size,
71 embedder::PlatformHandleVector* platform_handles) { 71 embedder::PlatformHandleVector* platform_handles) {
72 switch (static_cast<int32_t>(type)) { 72 switch (static_cast<int32_t>(type)) {
(...skipping 27 matching lines...) Expand all
100 100
101 CloseNoLock(); 101 CloseNoLock();
102 return MOJO_RESULT_OK; 102 return MOJO_RESULT_OK;
103 } 103 }
104 104
105 MojoResult Dispatcher::WriteMessage( 105 MojoResult Dispatcher::WriteMessage(
106 UserPointer<const void> bytes, 106 UserPointer<const void> bytes,
107 uint32_t num_bytes, 107 uint32_t num_bytes,
108 std::vector<DispatcherTransport>* transports, 108 std::vector<DispatcherTransport>* transports,
109 MojoWriteMessageFlags flags) { 109 MojoWriteMessageFlags flags) {
110 DCHECK(!transports || 110 DCHECK(!transports || (transports->size() > 0 &&
111 (transports->size() > 0 && 111 transports->size() < kMaxMessageNumHandles));
112 transports->size() < GetConfiguration().max_message_num_handles));
113 112
114 base::AutoLock locker(lock_); 113 base::AutoLock locker(lock_);
115 if (is_closed_) 114 if (is_closed_)
116 return MOJO_RESULT_INVALID_ARGUMENT; 115 return MOJO_RESULT_INVALID_ARGUMENT;
117 116
118 return WriteMessageImplNoLock(bytes, num_bytes, transports, flags); 117 return WriteMessageImplNoLock(bytes, num_bytes, transports, flags);
119 } 118 }
120 119
121 MojoResult Dispatcher::ReadMessage(UserPointer<void> bytes, 120 MojoResult Dispatcher::ReadMessage(UserPointer<void> bytes,
122 UserPointer<uint32_t> num_bytes, 121 UserPointer<uint32_t> num_bytes,
123 DispatcherVector* dispatchers, 122 DispatcherVector* dispatchers,
124 uint32_t* num_dispatchers, 123 uint32_t* num_dispatchers,
125 MojoReadMessageFlags flags) { 124 MojoReadMessageFlags flags) {
126 DCHECK(!num_dispatchers || *num_dispatchers == 0 || 125 DCHECK(!num_dispatchers || *num_dispatchers == 0 ||
127 (dispatchers && dispatchers->empty())); 126 (dispatchers && dispatchers->empty()));
128 127
129 base::AutoLock locker(lock_); 128 base::AutoLock locker(lock_);
130 if (is_closed_) 129 if (is_closed_)
131 return MOJO_RESULT_INVALID_ARGUMENT; 130 return MOJO_RESULT_INVALID_ARGUMENT;
132 131
133 return ReadMessageImplNoLock(bytes, num_bytes, dispatchers, num_dispatchers, 132 return ReadMessageImplNoLock(
134 flags); 133 bytes, num_bytes, dispatchers, num_dispatchers, flags);
135 } 134 }
136 135
137 MojoResult Dispatcher::WriteData(UserPointer<const void> elements, 136 MojoResult Dispatcher::WriteData(UserPointer<const void> elements,
138 UserPointer<uint32_t> num_bytes, 137 UserPointer<uint32_t> num_bytes,
139 MojoWriteDataFlags flags) { 138 MojoWriteDataFlags flags) {
140 base::AutoLock locker(lock_); 139 base::AutoLock locker(lock_);
141 if (is_closed_) 140 if (is_closed_)
142 return MOJO_RESULT_INVALID_ARGUMENT; 141 return MOJO_RESULT_INVALID_ARGUMENT;
143 142
144 return WriteDataImplNoLock(elements, num_bytes, flags); 143 return WriteDataImplNoLock(elements, num_bytes, flags);
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 // shouldn't be in |Core|'s handle table. 466 // shouldn't be in |Core|'s handle table.
468 is_closed_ = true; 467 is_closed_ = true;
469 468
470 #if !defined(NDEBUG) 469 #if !defined(NDEBUG)
471 // See the comment above |EndSerializeAndCloseImplNoLock()|. In brief: Locking 470 // See the comment above |EndSerializeAndCloseImplNoLock()|. In brief: Locking
472 // isn't actually needed, but we need to satisfy assertions (which we don't 471 // isn't actually needed, but we need to satisfy assertions (which we don't
473 // want to remove or weaken). 472 // want to remove or weaken).
474 base::AutoLock locker(lock_); 473 base::AutoLock locker(lock_);
475 #endif 474 #endif
476 475
477 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size, 476 return EndSerializeAndCloseImplNoLock(
478 platform_handles); 477 channel, destination, actual_size, platform_handles);
479 } 478 }
480 479
481 // DispatcherTransport --------------------------------------------------------- 480 // DispatcherTransport ---------------------------------------------------------
482 481
483 void DispatcherTransport::End() { 482 void DispatcherTransport::End() {
484 DCHECK(dispatcher_); 483 DCHECK(dispatcher_);
485 dispatcher_->lock_.Release(); 484 dispatcher_->lock_.Release();
486 dispatcher_ = nullptr; 485 dispatcher_ = nullptr;
487 } 486 }
488 487
489 } // namespace system 488 } // namespace system
490 } // namespace mojo 489 } // 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