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

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

Issue 2093603002: Wrap non-GCed raw pointer parameters of WTF::bind with WTF::unretained (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unretained_wrapper
Patch Set: rebase Created 4 years, 6 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) 2014, Google Inc. All rights reserved. 2 * Copyright (c) 2014, Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 protected: 113 protected:
114 void setConnection(WebConnectionType type, double maxBandwidthMbps) 114 void setConnection(WebConnectionType type, double maxBandwidthMbps)
115 { 115 {
116 m_notifier.setWebConnection(type, maxBandwidthMbps); 116 m_notifier.setWebConnection(type, maxBandwidthMbps);
117 testing::runPendingTasks(); 117 testing::runPendingTasks();
118 } 118 }
119 119
120 void addObserverOnNotification(StateObserver* observer, StateObserver* obser verToAdd) 120 void addObserverOnNotification(StateObserver* observer, StateObserver* obser verToAdd)
121 { 121 {
122 observer->setNotificationCallback(bind(&NetworkStateNotifier::addObserve r, &m_notifier, observerToAdd, wrapPersistent(getExecutionContext()))); 122 observer->setNotificationCallback(bind(&NetworkStateNotifier::addObserve r, WTF::unretained(&m_notifier), WTF::unretained(observerToAdd), wrapPersistent( getExecutionContext())));
123 } 123 }
124 124
125 void removeObserverOnNotification(StateObserver* observer, StateObserver* ob serverToRemove) 125 void removeObserverOnNotification(StateObserver* observer, StateObserver* ob serverToRemove)
126 { 126 {
127 observer->setNotificationCallback(bind(&NetworkStateNotifier::removeObse rver, &m_notifier, observerToRemove, wrapPersistent(getExecutionContext()))); 127 observer->setNotificationCallback(bind(&NetworkStateNotifier::removeObse rver, WTF::unretained(&m_notifier), WTF::unretained(observerToRemove), wrapPersi stent(getExecutionContext())));
128 } 128 }
129 129
130 bool verifyObservations(const StateObserver& observer, WebConnectionType typ e, double maxBandwidthMbps) 130 bool verifyObservations(const StateObserver& observer, WebConnectionType typ e, double maxBandwidthMbps)
131 { 131 {
132 EXPECT_EQ(observer.observedType(), type); 132 EXPECT_EQ(observer.observedType(), type);
133 EXPECT_EQ(observer.observedMaxBandwidth(), maxBandwidthMbps); 133 EXPECT_EQ(observer.observedMaxBandwidth(), maxBandwidthMbps);
134 return observer.observedType() == type && observer.observedMaxBandwidth( ) == maxBandwidthMbps; 134 return observer.observedType() == type && observer.observedMaxBandwidth( ) == maxBandwidthMbps;
135 } 135 }
136 136
137 Persistent<Document> m_document; 137 Persistent<Document> m_document;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 m_notifier.addObserver(&observer2, executionContext2()); 272 m_notifier.addObserver(&observer2, executionContext2());
273 m_notifier.removeObserver(&observer1, getExecutionContext()); 273 m_notifier.removeObserver(&observer1, getExecutionContext());
274 m_notifier.removeObserver(&observer2, executionContext2()); 274 m_notifier.removeObserver(&observer2, executionContext2());
275 275
276 setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps); 276 setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps);
277 EXPECT_TRUE(verifyObservations(observer1, WebConnectionTypeNone, kNoneMaxBan dwidthMbps)); 277 EXPECT_TRUE(verifyObservations(observer1, WebConnectionTypeNone, kNoneMaxBan dwidthMbps));
278 EXPECT_TRUE(verifyObservations(observer2, WebConnectionTypeNone, kNoneMaxBan dwidthMbps)); 278 EXPECT_TRUE(verifyObservations(observer2, WebConnectionTypeNone, kNoneMaxBan dwidthMbps));
279 } 279 }
280 280
281 } // namespace blink 281 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698