OLD | NEW |
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 #ifndef CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ | 5 #ifndef CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ |
6 #define CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ | 6 #define CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/common/message_port_types.h" | 16 #include "content/public/common/message_port_types.h" |
17 #include "ipc/ipc_message.h" | 17 #include "ipc/ipc_message.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class MessagePortDelegate; | 20 class MessagePortDelegate; |
21 | 21 |
22 class CONTENT_EXPORT MessagePortService { | 22 class CONTENT_EXPORT MessagePortService { |
23 public: | 23 public: |
24 typedef std::vector<std::pair<content::MessagePortMessage, std::vector<int>>> | 24 typedef std::vector<std::pair<content::MessagePortMessage, |
| 25 std::vector<TransferredMessagePort>>> |
25 QueuedMessages; | 26 QueuedMessages; |
26 | 27 |
27 // Returns the MessagePortService singleton. | 28 // Returns the MessagePortService singleton. |
28 static MessagePortService* GetInstance(); | 29 static MessagePortService* GetInstance(); |
29 | 30 |
30 // These methods correspond to the message port related IPCs. | 31 // These methods correspond to the message port related IPCs. |
31 void Create(int route_id, | 32 void Create(int route_id, |
32 MessagePortDelegate* delegate, | 33 MessagePortDelegate* delegate, |
33 int* message_port_id); | 34 int* message_port_id); |
34 void Destroy(int message_port_id); | 35 void Destroy(int message_port_id); |
35 void Entangle(int local_message_port_id, int remote_message_port_id); | 36 void Entangle(int local_message_port_id, int remote_message_port_id); |
36 void PostMessage(int sender_message_port_id, | 37 void PostMessage( |
37 const MessagePortMessage& message, | 38 int sender_message_port_id, |
38 const std::vector<int>& sent_message_port_ids); | 39 const MessagePortMessage& message, |
| 40 const std::vector<TransferredMessagePort>& sent_message_ports); |
39 void QueueMessages(int message_port_id); | 41 void QueueMessages(int message_port_id); |
40 void SendQueuedMessages(int message_port_id, | 42 void SendQueuedMessages(int message_port_id, |
41 const QueuedMessages& queued_messages); | 43 const QueuedMessages& queued_messages); |
42 void ReleaseMessages(int message_port_id); | 44 void ReleaseMessages(int message_port_id); |
43 | 45 |
44 // Updates the information needed to reach a message port when it's sent to a | 46 // Updates the information needed to reach a message port when it's sent to a |
45 // (possibly different) process. | 47 // (possibly different) process. |
46 void UpdateMessagePort(int message_port_id, | 48 void UpdateMessagePort(int message_port_id, |
47 MessagePortDelegate* delegate, | 49 MessagePortDelegate* delegate, |
48 int routing_id); | 50 int routing_id); |
(...skipping 16 matching lines...) Expand all Loading... |
65 | 67 |
66 // Attempts to send the queued messages for a message port. | 68 // Attempts to send the queued messages for a message port. |
67 void SendQueuedMessagesIfPossible(int message_port_id); | 69 void SendQueuedMessagesIfPossible(int message_port_id); |
68 | 70 |
69 private: | 71 private: |
70 friend struct DefaultSingletonTraits<MessagePortService>; | 72 friend struct DefaultSingletonTraits<MessagePortService>; |
71 | 73 |
72 MessagePortService(); | 74 MessagePortService(); |
73 ~MessagePortService(); | 75 ~MessagePortService(); |
74 | 76 |
75 void PostMessageTo(int message_port_id, | 77 void PostMessageTo( |
76 const MessagePortMessage& message, | 78 int message_port_id, |
77 const std::vector<int>& sent_message_port_ids); | 79 const MessagePortMessage& message, |
| 80 const std::vector<TransferredMessagePort>& sent_message_ports); |
78 | 81 |
79 // Handles the details of removing a message port id. Before calling this, | 82 // Handles the details of removing a message port id. Before calling this, |
80 // verify that the message port id exists. | 83 // verify that the message port id exists. |
81 void Erase(int message_port_id); | 84 void Erase(int message_port_id); |
82 | 85 |
83 struct MessagePort; | 86 struct MessagePort; |
84 typedef std::map<int, MessagePort> MessagePorts; | 87 typedef std::map<int, MessagePort> MessagePorts; |
85 MessagePorts message_ports_; | 88 MessagePorts message_ports_; |
86 | 89 |
87 // We need globally unique identifiers for each message port. | 90 // We need globally unique identifiers for each message port. |
88 int next_message_port_id_; | 91 int next_message_port_id_; |
89 | 92 |
90 DISALLOW_COPY_AND_ASSIGN(MessagePortService); | 93 DISALLOW_COPY_AND_ASSIGN(MessagePortService); |
91 }; | 94 }; |
92 | 95 |
93 } // namespace content | 96 } // namespace content |
94 | 97 |
95 #endif // CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ | 98 #endif // CONTENT_BROWSER_MESSAGE_PORT_SERVICE_H_ |
OLD | NEW |