| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 DCHECK_EQ(GET_CHANNEL_ID(port1_id), channel_id); | 211 DCHECK_EQ(GET_CHANNEL_ID(port1_id), channel_id); |
| 212 DCHECK_EQ(GET_CHANNEL_OPENER_ID(channel_id), port1_id); | 212 DCHECK_EQ(GET_CHANNEL_OPENER_ID(channel_id), port1_id); |
| 213 DCHECK_EQ(GET_CHANNEL_RECEIVERS_ID(channel_id), port2_id); | 213 DCHECK_EQ(GET_CHANNEL_RECEIVERS_ID(channel_id), port2_id); |
| 214 | 214 |
| 215 *port1 = port1_id; | 215 *port1 = port1_id; |
| 216 *port2 = port2_id; | 216 *port2 = port2_id; |
| 217 } | 217 } |
| 218 | 218 |
| 219 MessageService::MessageService(BrowserContext* context) | 219 MessageService::MessageService(BrowserContext* context) |
| 220 : lazy_background_task_queue_( | 220 : lazy_background_task_queue_( |
| 221 ExtensionSystem::Get(context)->lazy_background_task_queue()), | 221 LazyBackgroundTaskQueue::Get(context)), |
| 222 weak_factory_(this) { | 222 weak_factory_(this) { |
| 223 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 223 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 224 content::NotificationService::AllBrowserContextsAndSources()); | 224 content::NotificationService::AllBrowserContextsAndSources()); |
| 225 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 225 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 226 content::NotificationService::AllBrowserContextsAndSources()); | 226 content::NotificationService::AllBrowserContextsAndSources()); |
| 227 } | 227 } |
| 228 | 228 |
| 229 MessageService::~MessageService() { | 229 MessageService::~MessageService() { |
| 230 STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); | 230 STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); |
| 231 channels_.clear(); | 231 channels_.clear(); |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 int channel_id) { | 910 int channel_id) { |
| 911 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); | 911 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); |
| 912 if (channel_iter != channels_.end()) { | 912 if (channel_iter != channels_.end()) { |
| 913 for (const PendingMessage& message : queue) { | 913 for (const PendingMessage& message : queue) { |
| 914 DispatchMessage(message.first, channel_iter->second, message.second); | 914 DispatchMessage(message.first, channel_iter->second, message.second); |
| 915 } | 915 } |
| 916 } | 916 } |
| 917 } | 917 } |
| 918 | 918 |
| 919 } // namespace extensions | 919 } // namespace extensions |
| OLD | NEW |