OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef PermissionCallbacks_h | 5 #ifndef PermissionCallbacks_h |
6 #define PermissionCallbacks_h | 6 #define PermissionCallbacks_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "wtf/Functional.h" | 9 #include "wtf/Functional.h" |
10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
| 11 #include "wtf/OwnPtr.h" |
11 #include "wtf/PassOwnPtr.h" | 12 #include "wtf/PassOwnPtr.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 class PLATFORM_EXPORT PermissionCallbacks { | 16 class PLATFORM_EXPORT PermissionCallbacks { |
16 WTF_MAKE_NONCOPYABLE(PermissionCallbacks); | 17 WTF_MAKE_NONCOPYABLE(PermissionCallbacks); |
17 public: | 18 public: |
18 static PassOwnPtr<PermissionCallbacks> create(const Closure& allowed, const
Closure& denied); | 19 static PassOwnPtr<PermissionCallbacks> create(PassOwnPtr<Closure> allowed, P
assOwnPtr<Closure> denied); |
19 virtual ~PermissionCallbacks() { } | 20 virtual ~PermissionCallbacks() { } |
20 | 21 |
21 void onAllowed() { m_allowed(); } | 22 void onAllowed() { (*m_allowed)(); } |
22 void onDenied() { m_denied(); } | 23 void onDenied() { (*m_denied)(); } |
23 | 24 |
24 private: | 25 private: |
25 PermissionCallbacks(const Closure& allowed, const Closure& denied); | 26 PermissionCallbacks(PassOwnPtr<Closure> allowed, PassOwnPtr<Closure> denied)
; |
26 | 27 |
27 Closure m_allowed; | 28 OwnPtr<Closure> m_allowed; |
28 Closure m_denied; | 29 OwnPtr<Closure> m_denied; |
29 }; | 30 }; |
30 | 31 |
31 } // namespace blink | 32 } // namespace blink |
32 | 33 |
33 #endif // PermissionCallbacks_h | 34 #endif // PermissionCallbacks_h |
OLD | NEW |