Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: chrome/browser/extensions/api/messaging/message_service.cc

Issue 2230203002: chrome: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed accidental components/ change Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 MessageService::MessageService(BrowserContext* context) 226 MessageService::MessageService(BrowserContext* context)
227 : lazy_background_task_queue_( 227 : lazy_background_task_queue_(
228 LazyBackgroundTaskQueue::Get(context)), 228 LazyBackgroundTaskQueue::Get(context)),
229 weak_factory_(this) { 229 weak_factory_(this) {
230 DCHECK_CURRENTLY_ON(BrowserThread::UI); 230 DCHECK_CURRENTLY_ON(BrowserThread::UI);
231 } 231 }
232 232
233 MessageService::~MessageService() { 233 MessageService::~MessageService() {
234 DCHECK_CURRENTLY_ON(BrowserThread::UI); 234 DCHECK_CURRENTLY_ON(BrowserThread::UI);
235 235
236 STLDeleteContainerPairSecondPointers(channels_.begin(), channels_.end()); 236 base::STLDeleteContainerPairSecondPointers(channels_.begin(),
237 channels_.end());
237 channels_.clear(); 238 channels_.clear();
238 } 239 }
239 240
240 static base::LazyInstance<BrowserContextKeyedAPIFactory<MessageService> > 241 static base::LazyInstance<BrowserContextKeyedAPIFactory<MessageService> >
241 g_factory = LAZY_INSTANCE_INITIALIZER; 242 g_factory = LAZY_INSTANCE_INITIALIZER;
242 243
243 // static 244 // static
244 BrowserContextKeyedAPIFactory<MessageService>* 245 BrowserContextKeyedAPIFactory<MessageService>*
245 MessageService::GetFactoryInstance() { 246 MessageService::GetFactoryInstance() {
246 return g_factory.Pointer(); 247 return g_factory.Pointer();
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 const Message& message) { 766 const Message& message) {
766 DCHECK_CURRENTLY_ON(BrowserThread::UI); 767 DCHECK_CURRENTLY_ON(BrowserThread::UI);
767 768
768 PendingChannelMap::iterator pending_for_incognito = 769 PendingChannelMap::iterator pending_for_incognito =
769 pending_incognito_channels_.find(channel_id); 770 pending_incognito_channels_.find(channel_id);
770 if (pending_for_incognito != pending_incognito_channels_.end()) { 771 if (pending_for_incognito != pending_incognito_channels_.end()) {
771 pending_for_incognito->second.push_back( 772 pending_for_incognito->second.push_back(
772 PendingMessage(source_port_id, message)); 773 PendingMessage(source_port_id, message));
773 // A channel should only be holding pending messages because it is in one 774 // A channel should only be holding pending messages because it is in one
774 // of these states. 775 // of these states.
775 DCHECK(!ContainsKey(pending_tls_channel_id_channels_, channel_id)); 776 DCHECK(!base::ContainsKey(pending_tls_channel_id_channels_, channel_id));
776 DCHECK(!ContainsKey(pending_lazy_background_page_channels_, channel_id)); 777 DCHECK(
778 !base::ContainsKey(pending_lazy_background_page_channels_, channel_id));
777 return; 779 return;
778 } 780 }
779 PendingChannelMap::iterator pending_for_tls_channel_id = 781 PendingChannelMap::iterator pending_for_tls_channel_id =
780 pending_tls_channel_id_channels_.find(channel_id); 782 pending_tls_channel_id_channels_.find(channel_id);
781 if (pending_for_tls_channel_id != pending_tls_channel_id_channels_.end()) { 783 if (pending_for_tls_channel_id != pending_tls_channel_id_channels_.end()) {
782 pending_for_tls_channel_id->second.push_back( 784 pending_for_tls_channel_id->second.push_back(
783 PendingMessage(source_port_id, message)); 785 PendingMessage(source_port_id, message));
784 // A channel should only be holding pending messages because it is in one 786 // A channel should only be holding pending messages because it is in one
785 // of these states. 787 // of these states.
786 DCHECK(!ContainsKey(pending_lazy_background_page_channels_, channel_id)); 788 DCHECK(
789 !base::ContainsKey(pending_lazy_background_page_channels_, channel_id));
787 return; 790 return;
788 } 791 }
789 EnqueuePendingMessageForLazyBackgroundLoad(source_port_id, 792 EnqueuePendingMessageForLazyBackgroundLoad(source_port_id,
790 channel_id, 793 channel_id,
791 message); 794 message);
792 } 795 }
793 796
794 void MessageService::EnqueuePendingMessageForLazyBackgroundLoad( 797 void MessageService::EnqueuePendingMessageForLazyBackgroundLoad(
795 int source_port_id, 798 int source_port_id,
796 int channel_id, 799 int channel_id,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 1018
1016 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); 1019 MessageChannelMap::iterator channel_iter = channels_.find(channel_id);
1017 if (channel_iter != channels_.end()) { 1020 if (channel_iter != channels_.end()) {
1018 for (const PendingMessage& message : queue) { 1021 for (const PendingMessage& message : queue) {
1019 DispatchMessage(message.first, channel_iter->second, message.second); 1022 DispatchMessage(message.first, channel_iter->second, message.second);
1020 } 1023 }
1021 } 1024 }
1022 } 1025 }
1023 1026
1024 } // namespace extensions 1027 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698