| 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 16 matching lines...) Expand all Loading... |
| 27 class ExtensionHost; | 27 class ExtensionHost; |
| 28 class LazyBackgroundTaskQueue; | 28 class LazyBackgroundTaskQueue; |
| 29 | 29 |
| 30 // This class manages message and event passing between renderer processes. | 30 // This class manages message and event passing between renderer processes. |
| 31 // It maintains a list of processes that are listening to events and a set of | 31 // It maintains a list of processes that are listening to events and a set of |
| 32 // open channels. | 32 // open channels. |
| 33 // | 33 // |
| 34 // Messaging works this way: | 34 // Messaging works this way: |
| 35 // - An extension-owned script context (like a background page or a content | 35 // - An extension-owned script context (like a background page or a content |
| 36 // script) adds an event listener to the "onConnect" event. | 36 // script) adds an event listener to the "onConnect" event. |
| 37 // - Another context calls "extension.connect()" to open a channel to the | 37 // - Another context calls "runtime.connect()" to open a channel to the |
| 38 // extension process, or an extension context calls "tabs.connect(tabId)" to | 38 // extension process, or an extension context calls "tabs.connect(tabId)" to |
| 39 // open a channel to the content scripts for the given tab. The EMS notifies | 39 // open a channel to the content scripts for the given tab. The EMS notifies |
| 40 // the target process/tab, which then calls the onConnect event in every | 40 // the target process/tab, which then calls the onConnect event in every |
| 41 // context owned by the connecting extension in that process/tab. | 41 // context owned by the connecting extension in that process/tab. |
| 42 // - Once the channel is established, either side can call postMessage to send | 42 // - Once the channel is established, either side can call postMessage to send |
| 43 // a message to the opposite side of the channel, which may have multiple | 43 // a message to the opposite side of the channel, which may have multiple |
| 44 // listeners. | 44 // listeners. |
| 45 // | 45 // |
| 46 // Terminology: | 46 // Terminology: |
| 47 // channel: connection between two ports | 47 // channel: connection between two ports |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 LazyBackgroundTaskQueue* lazy_background_task_queue_; | 207 LazyBackgroundTaskQueue* lazy_background_task_queue_; |
| 208 | 208 |
| 209 base::WeakPtrFactory<MessageService> weak_factory_; | 209 base::WeakPtrFactory<MessageService> weak_factory_; |
| 210 | 210 |
| 211 DISALLOW_COPY_AND_ASSIGN(MessageService); | 211 DISALLOW_COPY_AND_ASSIGN(MessageService); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 } // namespace extensions | 214 } // namespace extensions |
| 215 | 215 |
| 216 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ | 216 #endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_MESSAGE_SERVICE_H_ |
| OLD | NEW |