OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 void OpenChannelToTab( | 112 void OpenChannelToTab( |
113 int source_process_id, int source_routing_id, int receiver_port_id, | 113 int source_process_id, int source_routing_id, int receiver_port_id, |
114 int tab_id, const std::string& extension_id, | 114 int tab_id, const std::string& extension_id, |
115 const std::string& channel_name); | 115 const std::string& channel_name); |
116 | 116 |
117 void OpenChannelToNativeApp( | 117 void OpenChannelToNativeApp( |
118 int source_process_id, | 118 int source_process_id, |
119 int source_routing_id, | 119 int source_routing_id, |
120 int receiver_port_id, | 120 int receiver_port_id, |
121 const std::string& source_extension_id, | 121 const std::string& source_extension_id, |
122 const std::string& native_app_name, | 122 const std::string& native_app_name); |
123 const std::string& channel_name, | |
124 const std::string& connect_message); | |
125 | |
126 // Should be called on the UI thread. | |
127 void FinalizeOpenChannelToNativeApp( | |
128 int receiver_port_id, | |
129 const std::string& channel_name, | |
130 scoped_ptr<MessageChannel> channel, | |
131 const std::string& tab_json, | |
132 NativeMessageProcessHost::ScopedHost native_process); | |
133 | 123 |
134 // Closes the message channel associated with the given port, and notifies | 124 // Closes the message channel associated with the given port, and notifies |
135 // the other side. | 125 // the other side. |
136 virtual void CloseChannel(int port_id, bool connection_error) OVERRIDE; | 126 virtual void CloseChannel(int port_id, bool connection_error) OVERRIDE; |
137 | 127 |
138 // Sends a message to the given port. | 128 // Sends a message to the given port. |
139 void PostMessage(int port_id, const std::string& message); | 129 void PostMessage(int port_id, const std::string& message); |
140 | 130 |
141 // NativeMessageProcessHost::Client | 131 // NativeMessageProcessHost::Client |
142 virtual void PostMessageFromNativeProcess( | 132 virtual void PostMessageFromNativeProcess( |
143 int port_id, const std::string& message) OVERRIDE; | 133 int port_id, |
| 134 const std::string& message) OVERRIDE; |
144 | 135 |
145 private: | 136 private: |
146 friend class MockMessageService; | 137 friend class MockMessageService; |
147 struct OpenChannelParams; | 138 struct OpenChannelParams; |
148 | 139 |
149 // A map of channel ID to its channel object. | 140 // A map of channel ID to its channel object. |
150 typedef std::map<int, MessageChannel*> MessageChannelMap; | 141 typedef std::map<int, MessageChannel*> MessageChannelMap; |
151 | 142 |
152 // A map of channel ID to information about the extension that is waiting | 143 // A map of channel ID to information about the extension that is waiting |
153 // for that channel to open. Used for lazy background pages. | 144 // for that channel to open. Used for lazy background pages. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 198 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
208 | 199 |
209 base::WeakPtrFactory<MessageService> weak_factory_; | 200 base::WeakPtrFactory<MessageService> weak_factory_; |
210 | 201 |
211 DISALLOW_COPY_AND_ASSIGN(MessageService); | 202 DISALLOW_COPY_AND_ASSIGN(MessageService); |
212 }; | 203 }; |
213 | 204 |
214 } // namespace extensions | 205 } // namespace extensions |
215 | 206 |
216 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 207 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
OLD | NEW |