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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 MessageService::~MessageService() { | 176 MessageService::~MessageService() { |
177 STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); | 177 STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); |
178 channels_.clear(); | 178 channels_.clear(); |
179 } | 179 } |
180 | 180 |
181 static base::LazyInstance<ProfileKeyedAPIFactory<MessageService> > | 181 static base::LazyInstance<ProfileKeyedAPIFactory<MessageService> > |
182 g_factory = LAZY_INSTANCE_INITIALIZER; | 182 g_factory = LAZY_INSTANCE_INITIALIZER; |
183 | 183 |
184 // static | 184 // static |
185 ProfileKeyedAPIFactory<MessageService>* MessageService::GetFactoryInstance() { | 185 ProfileKeyedAPIFactory<MessageService>* MessageService::GetFactoryInstance() { |
186 return &g_factory.Get(); | 186 return g_factory.Pointer(); |
187 } | 187 } |
188 | 188 |
189 // static | 189 // static |
190 MessageService* MessageService::Get(content::BrowserContext* context) { | 190 MessageService* MessageService::Get(content::BrowserContext* context) { |
191 Profile* profile = Profile::FromBrowserContext(context); | 191 Profile* profile = Profile::FromBrowserContext(context); |
192 return ProfileKeyedAPIFactory<MessageService>::GetForProfile(profile); | 192 return ProfileKeyedAPIFactory<MessageService>::GetForProfile(profile); |
193 } | 193 } |
194 | 194 |
195 void MessageService::OpenChannelToExtension( | 195 void MessageService::OpenChannelToExtension( |
196 int source_process_id, int source_routing_id, int receiver_port_id, | 196 int source_process_id, int source_routing_id, int receiver_port_id, |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 } | 754 } |
755 | 755 |
756 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, | 756 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, |
757 int port_id, | 757 int port_id, |
758 const std::string& error_message) { | 758 const std::string& error_message) { |
759 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); | 759 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); |
760 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); | 760 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); |
761 } | 761 } |
762 | 762 |
763 } // namespace extensions | 763 } // namespace extensions |
OLD | NEW |