| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extension_message_service.h" | 5 #include "chrome/browser/extensions/extension_message_service.h" |
| 6 | 6 |
| 7 #include "base/json_writer.h" | 7 #include "base/json_writer.h" |
| 8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 // Since ExtensionMessageService is a collection of Singletons, we don't need to | 83 // Since ExtensionMessageService is a collection of Singletons, we don't need to |
| 84 // grab a reference to it when creating Tasks involving it. | 84 // grab a reference to it when creating Tasks involving it. |
| 85 template <> struct RunnableMethodTraits<ExtensionMessageService> { | 85 template <> struct RunnableMethodTraits<ExtensionMessageService> { |
| 86 static void RetainCallee(ExtensionMessageService*) {} | 86 static void RetainCallee(ExtensionMessageService*) {} |
| 87 static void ReleaseCallee(ExtensionMessageService*) {} | 87 static void ReleaseCallee(ExtensionMessageService*) {} |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 | 90 |
| 91 const char ExtensionMessageService::kDispatchOnConnect[] = | 91 const char ExtensionMessageService::kDispatchOnConnect[] = |
| 92 "chrome.Port.dispatchOnConnect_"; | 92 "Port.dispatchOnConnect"; |
| 93 const char ExtensionMessageService::kDispatchOnDisconnect[] = | 93 const char ExtensionMessageService::kDispatchOnDisconnect[] = |
| 94 "chrome.Port.dispatchOnDisconnect_"; | 94 "Port.dispatchOnDisconnect"; |
| 95 const char ExtensionMessageService::kDispatchOnMessage[] = | 95 const char ExtensionMessageService::kDispatchOnMessage[] = |
| 96 "chrome.Port.dispatchOnMessage_"; | 96 "Port.dispatchOnMessage"; |
| 97 const char ExtensionMessageService::kDispatchEvent[] = | 97 const char ExtensionMessageService::kDispatchEvent[] = |
| 98 "chrome.Event.dispatchJSON_"; | 98 "Event.dispatchJSON"; |
| 99 | 99 |
| 100 // static | 100 // static |
| 101 ExtensionMessageService* ExtensionMessageService::GetInstance( | 101 ExtensionMessageService* ExtensionMessageService::GetInstance( |
| 102 URLRequestContext* context) { | 102 URLRequestContext* context) { |
| 103 SingletonData* data = Singleton<SingletonData>::get(); | 103 SingletonData* data = Singleton<SingletonData>::get(); |
| 104 AutoLock lock(data->lock); | 104 AutoLock lock(data->lock); |
| 105 | 105 |
| 106 ExtensionMessageService* instance = data->map[context]; | 106 ExtensionMessageService* instance = data->map[context]; |
| 107 if (!instance) { | 107 if (!instance) { |
| 108 instance = new ExtensionMessageService(); | 108 instance = new ExtensionMessageService(); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 DispatchOnDisconnect(current->second.port2, | 368 DispatchOnDisconnect(current->second.port2, |
| 369 GET_CHANNEL_PORT1(current->first)); | 369 GET_CHANNEL_PORT1(current->first)); |
| 370 channels_.erase(current); | 370 channels_.erase(current); |
| 371 } else if (current->second.port2 == renderer) { | 371 } else if (current->second.port2 == renderer) { |
| 372 DispatchOnDisconnect(current->second.port1, | 372 DispatchOnDisconnect(current->second.port1, |
| 373 GET_CHANNEL_PORT2(current->first)); | 373 GET_CHANNEL_PORT2(current->first)); |
| 374 channels_.erase(current); | 374 channels_.erase(current); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 } | 377 } |
| OLD | NEW |