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_EXTENSION_MESSAGE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // to open a channel. Returns true if a task was queued. | 119 // to open a channel. Returns true if a task was queued. |
120 bool MaybeAddPendingOpenChannelTask(Profile* profile, | 120 bool MaybeAddPendingOpenChannelTask(Profile* profile, |
121 const OpenChannelParams& params); | 121 const OpenChannelParams& params); |
122 | 122 |
123 // Callbacks for LazyBackgroundTaskQueue tasks. The queue passes in an | 123 // Callbacks for LazyBackgroundTaskQueue tasks. The queue passes in an |
124 // ExtensionHost to its task callbacks, though some of our callbacks don't | 124 // ExtensionHost to its task callbacks, though some of our callbacks don't |
125 // use that argument. | 125 // use that argument. |
126 void PendingOpenChannel(const OpenChannelParams& params, | 126 void PendingOpenChannel(const OpenChannelParams& params, |
127 int source_process_id, | 127 int source_process_id, |
128 ExtensionHost* host); | 128 ExtensionHost* host); |
129 void PendingCloseChannel(int port_id, bool connection_error, ExtensionHost*) { | 129 void PendingCloseChannel(int port_id, |
130 CloseChannel(port_id, connection_error); | 130 bool connection_error, |
| 131 ExtensionHost* host) { |
| 132 if (host) |
| 133 CloseChannel(port_id, connection_error); |
131 } | 134 } |
132 void PendingPostMessage(int port_id, | 135 void PendingPostMessage(int port_id, |
133 const std::string& message, | 136 const std::string& message, |
134 ExtensionHost*) { | 137 ExtensionHost* host) { |
135 PostMessageFromRenderer(port_id, message); | 138 if (host) |
| 139 PostMessageFromRenderer(port_id, message); |
136 } | 140 } |
137 | 141 |
138 content::NotificationRegistrar registrar_; | 142 content::NotificationRegistrar registrar_; |
139 MessageChannelMap channels_; | 143 MessageChannelMap channels_; |
140 PendingChannelMap pending_channels_; | 144 PendingChannelMap pending_channels_; |
141 | 145 |
142 // Weak pointer. Guaranteed to outlive this class. | 146 // Weak pointer. Guaranteed to outlive this class. |
143 extensions::LazyBackgroundTaskQueue* lazy_background_task_queue_; | 147 extensions::LazyBackgroundTaskQueue* lazy_background_task_queue_; |
144 | 148 |
145 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService); | 149 DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService); |
146 }; | 150 }; |
147 | 151 |
148 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ | 152 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MESSAGE_SERVICE_H_ |
OLD | NEW |