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

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

Issue 1555273002: [mojo] Add CreateSharedBuffer method to Broker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 4 years, 11 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/broker_state.h ('k') | mojo/edk/system/child_broker.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/broker_state.h" 5 #include "mojo/edk/system/broker_state.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "mojo/edk/embedder/embedder_internal.h" 12 #include "mojo/edk/embedder/embedder_internal.h"
13 #include "mojo/edk/embedder/platform_channel_pair.h" 13 #include "mojo/edk/embedder/platform_channel_pair.h"
14 #include "mojo/edk/embedder/platform_shared_buffer.h"
15 #include "mojo/edk/embedder/platform_support.h"
14 #include "mojo/edk/system/child_broker_host.h" 16 #include "mojo/edk/system/child_broker_host.h"
15 #include "mojo/edk/system/message_pipe_dispatcher.h" 17 #include "mojo/edk/system/message_pipe_dispatcher.h"
16 #include "mojo/edk/system/routed_raw_channel.h" 18 #include "mojo/edk/system/routed_raw_channel.h"
17 19
18 namespace mojo { 20 namespace mojo {
19 namespace edk { 21 namespace edk {
20 22
21 BrokerState* BrokerState::GetInstance() { 23 BrokerState* BrokerState::GetInstance() {
22 return base::Singleton< 24 return base::Singleton<
23 BrokerState, base::LeakySingletonTraits<BrokerState>>::get(); 25 BrokerState, base::LeakySingletonTraits<BrokerState>>::get();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 for (size_t i = 0; i < count; ++i) { 60 for (size_t i = 0; i < count; ++i) {
59 auto it = token_map_.find(tokens[i]); 61 auto it = token_map_.find(tokens[i]);
60 if (it == token_map_.end()) { 62 if (it == token_map_.end()) {
61 DLOG(WARNING) << "TokenToHandle didn't find token."; 63 DLOG(WARNING) << "TokenToHandle didn't find token.";
62 } else { 64 } else {
63 handles[i].handle = it->second; 65 handles[i].handle = it->second;
64 token_map_.erase(it); 66 token_map_.erase(it);
65 } 67 }
66 } 68 }
67 } 69 }
70 #else
71 scoped_refptr<PlatformSharedBuffer> BrokerState::CreateSharedBuffer(
72 size_t num_bytes) {
73 return internal::g_platform_support->CreateSharedBuffer(num_bytes);
74 }
68 #endif 75 #endif
69 76
70 void BrokerState::ConnectMessagePipe(uint64_t pipe_id, 77 void BrokerState::ConnectMessagePipe(uint64_t pipe_id,
71 MessagePipeDispatcher* message_pipe) { 78 MessagePipeDispatcher* message_pipe) {
72 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread()); 79 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread());
73 base::AutoLock auto_lock(lock_); 80 base::AutoLock auto_lock(lock_);
74 if (pending_connects_.find(pipe_id) != pending_connects_.end()) { 81 if (pending_connects_.find(pipe_id) != pending_connects_.end()) {
75 // Both ends of the message pipe are in this process. 82 // Both ends of the message pipe are in this process.
76 if (!in_process_pipes_channel1_) { 83 if (!in_process_pipes_channel1_) {
77 PlatformChannelPair channel_pair; 84 PlatformChannelPair channel_pair;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // then when it's read it returns no messages because it doesn't have the 251 // then when it's read it returns no messages because it doesn't have the
245 // channel yet. 252 // channel yet.
246 message_pipe->GotNonTransferableChannel(raw_channel->channel()); 253 message_pipe->GotNonTransferableChannel(raw_channel->channel());
247 // The above call could have caused |CloseMessagePipe| to be called. 254 // The above call could have caused |CloseMessagePipe| to be called.
248 if (connected_pipes_.find(message_pipe) != connected_pipes_.end()) 255 if (connected_pipes_.find(message_pipe) != connected_pipes_.end())
249 raw_channel->AddRoute(pipe_id, message_pipe); 256 raw_channel->AddRoute(pipe_id, message_pipe);
250 } 257 }
251 258
252 } // namespace edk 259 } // namespace edk
253 } // namespace mojo 260 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/broker_state.h ('k') | mojo/edk/system/child_broker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698