OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |