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 #include "chrome/browser/extensions/api/messaging/message_service.h" | 5 #include "chrome/browser/extensions/api/messaging/message_service.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 content::NotificationService::AllBrowserContextsAndSources()); | 170 content::NotificationService::AllBrowserContextsAndSources()); |
171 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 171 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
172 content::NotificationService::AllBrowserContextsAndSources()); | 172 content::NotificationService::AllBrowserContextsAndSources()); |
173 } | 173 } |
174 | 174 |
175 MessageService::~MessageService() { | 175 MessageService::~MessageService() { |
176 STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); | 176 STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); |
177 channels_.clear(); | 177 channels_.clear(); |
178 } | 178 } |
179 | 179 |
180 static base::LazyInstance<ProfileKeyedAPIFactory<MessageService> > | 180 static base::LazyInstance<BrowserContextKeyedAPIFactory<MessageService> > |
181 g_factory = LAZY_INSTANCE_INITIALIZER; | 181 g_factory = LAZY_INSTANCE_INITIALIZER; |
182 | 182 |
183 // static | 183 // static |
184 ProfileKeyedAPIFactory<MessageService>* MessageService::GetFactoryInstance() { | 184 BrowserContextKeyedAPIFactory<MessageService>* |
| 185 MessageService::GetFactoryInstance() { |
185 return g_factory.Pointer(); | 186 return g_factory.Pointer(); |
186 } | 187 } |
187 | 188 |
188 // static | 189 // static |
189 MessageService* MessageService::Get(BrowserContext* context) { | 190 MessageService* MessageService::Get(BrowserContext* context) { |
190 return ProfileKeyedAPIFactory<MessageService>::GetForProfile(context); | 191 return BrowserContextKeyedAPIFactory<MessageService>::Get(context); |
191 } | 192 } |
192 | 193 |
193 void MessageService::OpenChannelToExtension( | 194 void MessageService::OpenChannelToExtension( |
194 int source_process_id, int source_routing_id, int receiver_port_id, | 195 int source_process_id, int source_routing_id, int receiver_port_id, |
195 const std::string& source_extension_id, | 196 const std::string& source_extension_id, |
196 const std::string& target_extension_id, | 197 const std::string& target_extension_id, |
197 const GURL& source_url, | 198 const GURL& source_url, |
198 const std::string& channel_name, | 199 const std::string& channel_name, |
199 bool include_tls_channel_id) { | 200 bool include_tls_channel_id) { |
200 content::RenderProcessHost* source = | 201 content::RenderProcessHost* source = |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 } | 757 } |
757 | 758 |
758 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, | 759 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, |
759 int port_id, | 760 int port_id, |
760 const std::string& error_message) { | 761 const std::string& error_message) { |
761 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); | 762 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); |
762 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); | 763 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); |
763 } | 764 } |
764 | 765 |
765 } // namespace extensions | 766 } // namespace extensions |
OLD | NEW |