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

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

Issue 705003002: Change the return type of WTF::bind() to |OwnPtr<Function>| (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Reflect comments from yhirano Created 6 years, 1 month 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 : m_observedType(blink::ConnectionTypeNone) 46 : m_observedType(blink::ConnectionTypeNone)
47 , m_callbackCount(0) 47 , m_callbackCount(0)
48 { 48 {
49 } 49 }
50 50
51 virtual void connectionTypeChange(blink::WebConnectionType type) 51 virtual void connectionTypeChange(blink::WebConnectionType type)
52 { 52 {
53 m_observedType = type; 53 m_observedType = type;
54 m_callbackCount += 1; 54 m_callbackCount += 1;
55 55
56 if (!m_closure.isNull()) 56 if (m_closure && !m_closure->isNull())
57 m_closure(); 57 (*m_closure)();
58 } 58 }
59 59
60 blink::WebConnectionType observedType() const 60 blink::WebConnectionType observedType() const
61 { 61 {
62 return m_observedType; 62 return m_observedType;
63 } 63 }
64 64
65 int callbackCount() const 65 int callbackCount() const
66 { 66 {
67 return m_callbackCount; 67 return m_callbackCount;
68 } 68 }
69 69
70 void setNotificationCallback(const Closure& closure) 70 void setNotificationCallback(PassOwnPtr<Closure> closure)
71 { 71 {
72 m_closure = closure; 72 m_closure = closure;
73 } 73 }
74 74
75 private: 75 private:
76 Closure m_closure; 76 OwnPtr<Closure> m_closure;
77 blink::WebConnectionType m_observedType; 77 blink::WebConnectionType m_observedType;
78 int m_callbackCount; 78 int m_callbackCount;
79 }; 79 };
80 80
81 class ExitTask 81 class ExitTask
82 : public blink::WebThread::Task { 82 : public blink::WebThread::Task {
83 public: 83 public:
84 ExitTask(blink::WebThread* thread) 84 ExitTask(blink::WebThread* thread)
85 : m_thread(thread) 85 : m_thread(thread)
86 { 86 {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 m_notifier.addObserver(&observer2, executionContext2()); 271 m_notifier.addObserver(&observer2, executionContext2());
272 m_notifier.removeObserver(&observer1, executionContext()); 272 m_notifier.removeObserver(&observer1, executionContext());
273 m_notifier.removeObserver(&observer2, executionContext2()); 273 m_notifier.removeObserver(&observer2, executionContext2());
274 274
275 setType(blink::ConnectionTypeBluetooth); 275 setType(blink::ConnectionTypeBluetooth);
276 EXPECT_EQ(observer1.observedType(), blink::ConnectionTypeNone); 276 EXPECT_EQ(observer1.observedType(), blink::ConnectionTypeNone);
277 EXPECT_EQ(observer2.observedType(), blink::ConnectionTypeNone); 277 EXPECT_EQ(observer2.observedType(), blink::ConnectionTypeNone);
278 } 278 }
279 279
280 } // namespace blink 280 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/WorkerLoaderClientBridgeSyncHelper.cpp ('k') | Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698