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

Side by Side Diff: third_party/WebKit/Source/core/page/NetworkStateNotifier.cpp

Issue 1925583003: Replace AllowCrossThreadAccess() + non-GCed pointers with crossThreadUnretained() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_4
Patch Set: Rebase. Created 4 years, 5 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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 MutexLocker locker(m_mutex); 129 MutexLocker locker(m_mutex);
130 m_initialized = true; 130 m_initialized = true;
131 131
132 if (m_type == type && m_maxBandwidthMbps == maxBandwidthMbps) 132 if (m_type == type && m_maxBandwidthMbps == maxBandwidthMbps)
133 return; 133 return;
134 m_type = type; 134 m_type = type;
135 m_maxBandwidthMbps = maxBandwidthMbps; 135 m_maxBandwidthMbps = maxBandwidthMbps;
136 136
137 for (const auto& entry : m_observers) { 137 for (const auto& entry : m_observers) {
138 ExecutionContext* context = entry.key; 138 ExecutionContext* context = entry.key;
139 context->postTask(BLINK_FROM_HERE, createCrossThreadTask(&NetworkStateNo tifier::notifyObserversOfConnectionChangeOnContext, AllowCrossThreadAccess(this) , type, maxBandwidthMbps)); 139 context->postTask(BLINK_FROM_HERE, createCrossThreadTask(&NetworkStateNo tifier::notifyObserversOfConnectionChangeOnContext, crossThreadUnretained(this), type, maxBandwidthMbps));
140 } 140 }
141 } 141 }
142 142
143 void NetworkStateNotifier::notifyObserversOfConnectionChangeOnContext(WebConnect ionType type, double maxBandwidthMbps, ExecutionContext* context) 143 void NetworkStateNotifier::notifyObserversOfConnectionChangeOnContext(WebConnect ionType type, double maxBandwidthMbps, ExecutionContext* context)
144 { 144 {
145 ObserverList* observerList = lockAndFindObserverList(context); 145 ObserverList* observerList = lockAndFindObserverList(context);
146 146
147 // The context could have been removed before the notification task got to r un. 147 // The context could have been removed before the notification task got to r un.
148 if (!observerList) 148 if (!observerList)
149 return; 149 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 list->zeroedObservers.clear(); 184 list->zeroedObservers.clear();
185 185
186 if (list->observers.isEmpty()) { 186 if (list->observers.isEmpty()) {
187 MutexLocker locker(m_mutex); 187 MutexLocker locker(m_mutex);
188 m_observers.remove(context); // deletes list 188 m_observers.remove(context); // deletes list
189 } 189 }
190 } 190 }
191 191
192 } // namespace blink 192 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698