OLD | NEW |
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" | |
16 #include "mojo/edk/system/child_broker_host.h" | 14 #include "mojo/edk/system/child_broker_host.h" |
17 #include "mojo/edk/system/message_pipe_dispatcher.h" | 15 #include "mojo/edk/system/message_pipe_dispatcher.h" |
18 #include "mojo/edk/system/routed_raw_channel.h" | 16 #include "mojo/edk/system/routed_raw_channel.h" |
19 | 17 |
20 namespace mojo { | 18 namespace mojo { |
21 namespace edk { | 19 namespace edk { |
22 | 20 |
23 BrokerState* BrokerState::GetInstance() { | 21 BrokerState* BrokerState::GetInstance() { |
24 return base::Singleton< | 22 return base::Singleton< |
25 BrokerState, base::LeakySingletonTraits<BrokerState>>::get(); | 23 BrokerState, base::LeakySingletonTraits<BrokerState>>::get(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 for (size_t i = 0; i < count; ++i) { | 58 for (size_t i = 0; i < count; ++i) { |
61 auto it = token_map_.find(tokens[i]); | 59 auto it = token_map_.find(tokens[i]); |
62 if (it == token_map_.end()) { | 60 if (it == token_map_.end()) { |
63 DLOG(WARNING) << "TokenToHandle didn't find token."; | 61 DLOG(WARNING) << "TokenToHandle didn't find token."; |
64 } else { | 62 } else { |
65 handles[i].handle = it->second; | 63 handles[i].handle = it->second; |
66 token_map_.erase(it); | 64 token_map_.erase(it); |
67 } | 65 } |
68 } | 66 } |
69 } | 67 } |
70 #else | |
71 scoped_refptr<PlatformSharedBuffer> BrokerState::CreateSharedBuffer( | |
72 size_t num_bytes) { | |
73 return internal::g_platform_support->CreateSharedBuffer(num_bytes); | |
74 } | |
75 #endif | 68 #endif |
76 | 69 |
77 void BrokerState::ConnectMessagePipe(uint64_t pipe_id, | 70 void BrokerState::ConnectMessagePipe(uint64_t pipe_id, |
78 MessagePipeDispatcher* message_pipe) { | 71 MessagePipeDispatcher* message_pipe) { |
79 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread()); | 72 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread()); |
80 base::AutoLock auto_lock(lock_); | 73 base::AutoLock auto_lock(lock_); |
81 if (pending_connects_.find(pipe_id) != pending_connects_.end()) { | 74 if (pending_connects_.find(pipe_id) != pending_connects_.end()) { |
82 // Both ends of the message pipe are in this process. | 75 // Both ends of the message pipe are in this process. |
83 if (!in_process_pipes_channel1_) { | 76 if (!in_process_pipes_channel1_) { |
84 PlatformChannelPair channel_pair; | 77 PlatformChannelPair channel_pair; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // then when it's read it returns no messages because it doesn't have the | 244 // then when it's read it returns no messages because it doesn't have the |
252 // channel yet. | 245 // channel yet. |
253 message_pipe->GotNonTransferableChannel(raw_channel->channel()); | 246 message_pipe->GotNonTransferableChannel(raw_channel->channel()); |
254 // The above call could have caused |CloseMessagePipe| to be called. | 247 // The above call could have caused |CloseMessagePipe| to be called. |
255 if (connected_pipes_.find(message_pipe) != connected_pipes_.end()) | 248 if (connected_pipes_.find(message_pipe) != connected_pipes_.end()) |
256 raw_channel->AddRoute(pipe_id, message_pipe); | 249 raw_channel->AddRoute(pipe_id, message_pipe); |
257 } | 250 } |
258 | 251 |
259 } // namespace edk | 252 } // namespace edk |
260 } // namespace mojo | 253 } // namespace mojo |
OLD | NEW |