| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_ | 5 #ifndef PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_ |
| 6 #define PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_ | 6 #define PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_ |
| 7 | 7 |
| 8 #include "ppapi/cpp/completion_callback.h" | 8 #include "ppapi/cpp/completion_callback.h" |
| 9 #include "ppapi/utility/completion_callback_factory_thread_traits.h" | 9 #include "ppapi/utility/completion_callback_factory_thread_traits.h" |
| 10 | 10 |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 }; | 721 }; |
| 722 | 722 |
| 723 template <typename Traits, typename Output, typename Method> | 723 template <typename Traits, typename Output, typename Method> |
| 724 class DispatcherWithOutput0 { | 724 class DispatcherWithOutput0 { |
| 725 public: | 725 public: |
| 726 typedef Output OutputType; | 726 typedef Output OutputType; |
| 727 | 727 |
| 728 DispatcherWithOutput0() | 728 DispatcherWithOutput0() |
| 729 : method_(NULL), | 729 : method_(NULL), |
| 730 output_() { | 730 output_() { |
| 731 Traits::Initialize(&output_); |
| 731 } | 732 } |
| 732 DispatcherWithOutput0(Method method) | 733 DispatcherWithOutput0(Method method) |
| 733 : method_(method), | 734 : method_(method), |
| 734 output_() { | 735 output_() { |
| 736 Traits::Initialize(&output_); |
| 735 } | 737 } |
| 736 void operator()(T* object, int32_t result) { | 738 void operator()(T* object, int32_t result) { |
| 737 // We must call Traits::StorageToPluginArg() even if we don't need to call | 739 // We must call Traits::StorageToPluginArg() even if we don't need to call |
| 738 // the callback anymore, otherwise we may leak resource or var references. | 740 // the callback anymore, otherwise we may leak resource or var references. |
| 739 if (object) | 741 if (object) |
| 740 (object->*method_)(result, Traits::StorageToPluginArg(output_)); | 742 (object->*method_)(result, Traits::StorageToPluginArg(output_)); |
| 741 else | 743 else |
| 742 Traits::StorageToPluginArg(output_); | 744 Traits::StorageToPluginArg(output_); |
| 743 } | 745 } |
| 744 typename Traits::StorageType* output() { | 746 typename Traits::StorageType* output() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 772 | 774 |
| 773 template <typename Traits, typename Output, typename Method, typename A> | 775 template <typename Traits, typename Output, typename Method, typename A> |
| 774 class DispatcherWithOutput1 { | 776 class DispatcherWithOutput1 { |
| 775 public: | 777 public: |
| 776 typedef Output OutputType; | 778 typedef Output OutputType; |
| 777 | 779 |
| 778 DispatcherWithOutput1() | 780 DispatcherWithOutput1() |
| 779 : method_(NULL), | 781 : method_(NULL), |
| 780 a_(), | 782 a_(), |
| 781 output_() { | 783 output_() { |
| 784 Traits::Initialize(&output_); |
| 782 } | 785 } |
| 783 DispatcherWithOutput1(Method method, const A& a) | 786 DispatcherWithOutput1(Method method, const A& a) |
| 784 : method_(method), | 787 : method_(method), |
| 785 a_(a), | 788 a_(a), |
| 786 output_() { | 789 output_() { |
| 790 Traits::Initialize(&output_); |
| 787 } | 791 } |
| 788 void operator()(T* object, int32_t result) { | 792 void operator()(T* object, int32_t result) { |
| 789 // We must call Traits::StorageToPluginArg() even if we don't need to call | 793 // We must call Traits::StorageToPluginArg() even if we don't need to call |
| 790 // the callback anymore, otherwise we may leak resource or var references. | 794 // the callback anymore, otherwise we may leak resource or var references. |
| 791 if (object) | 795 if (object) |
| 792 (object->*method_)(result, Traits::StorageToPluginArg(output_), a_); | 796 (object->*method_)(result, Traits::StorageToPluginArg(output_), a_); |
| 793 else | 797 else |
| 794 Traits::StorageToPluginArg(output_); | 798 Traits::StorageToPluginArg(output_); |
| 795 } | 799 } |
| 796 typename Traits::StorageType* output() { | 800 typename Traits::StorageType* output() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 typename B> | 837 typename B> |
| 834 class DispatcherWithOutput2 { | 838 class DispatcherWithOutput2 { |
| 835 public: | 839 public: |
| 836 typedef Output OutputType; | 840 typedef Output OutputType; |
| 837 | 841 |
| 838 DispatcherWithOutput2() | 842 DispatcherWithOutput2() |
| 839 : method_(NULL), | 843 : method_(NULL), |
| 840 a_(), | 844 a_(), |
| 841 b_(), | 845 b_(), |
| 842 output_() { | 846 output_() { |
| 847 Traits::Initialize(&output_); |
| 843 } | 848 } |
| 844 DispatcherWithOutput2(Method method, const A& a, const B& b) | 849 DispatcherWithOutput2(Method method, const A& a, const B& b) |
| 845 : method_(method), | 850 : method_(method), |
| 846 a_(a), | 851 a_(a), |
| 847 b_(b), | 852 b_(b), |
| 848 output_() { | 853 output_() { |
| 854 Traits::Initialize(&output_); |
| 849 } | 855 } |
| 850 void operator()(T* object, int32_t result) { | 856 void operator()(T* object, int32_t result) { |
| 851 // We must call Traits::StorageToPluginArg() even if we don't need to call | 857 // We must call Traits::StorageToPluginArg() even if we don't need to call |
| 852 // the callback anymore, otherwise we may leak resource or var references. | 858 // the callback anymore, otherwise we may leak resource or var references. |
| 853 if (object) | 859 if (object) |
| 854 (object->*method_)(result, Traits::StorageToPluginArg(output_), a_, b_); | 860 (object->*method_)(result, Traits::StorageToPluginArg(output_), a_, b_); |
| 855 else | 861 else |
| 856 Traits::StorageToPluginArg(output_); | 862 Traits::StorageToPluginArg(output_); |
| 857 } | 863 } |
| 858 typename Traits::StorageType* output() { | 864 typename Traits::StorageType* output() { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 class DispatcherWithOutput3 { | 907 class DispatcherWithOutput3 { |
| 902 public: | 908 public: |
| 903 typedef Output OutputType; | 909 typedef Output OutputType; |
| 904 | 910 |
| 905 DispatcherWithOutput3() | 911 DispatcherWithOutput3() |
| 906 : method_(NULL), | 912 : method_(NULL), |
| 907 a_(), | 913 a_(), |
| 908 b_(), | 914 b_(), |
| 909 c_(), | 915 c_(), |
| 910 output_() { | 916 output_() { |
| 917 Traits::Initialize(&output_); |
| 911 } | 918 } |
| 912 DispatcherWithOutput3(Method method, const A& a, const B& b, const C& c) | 919 DispatcherWithOutput3(Method method, const A& a, const B& b, const C& c) |
| 913 : method_(method), | 920 : method_(method), |
| 914 a_(a), | 921 a_(a), |
| 915 b_(b), | 922 b_(b), |
| 916 c_(c), | 923 c_(c), |
| 917 output_() { | 924 output_() { |
| 925 Traits::Initialize(&output_); |
| 918 } | 926 } |
| 919 void operator()(T* object, int32_t result) { | 927 void operator()(T* object, int32_t result) { |
| 920 // We must call Traits::StorageToPluginArg() even if we don't need to call | 928 // We must call Traits::StorageToPluginArg() even if we don't need to call |
| 921 // the callback anymore, otherwise we may leak resource or var references. | 929 // the callback anymore, otherwise we may leak resource or var references. |
| 922 if (object) { | 930 if (object) { |
| 923 (object->*method_)(result, Traits::StorageToPluginArg(output_), | 931 (object->*method_)(result, Traits::StorageToPluginArg(output_), |
| 924 a_, b_, c_); | 932 a_, b_, c_); |
| 925 } else { | 933 } else { |
| 926 Traits::StorageToPluginArg(output_); | 934 Traits::StorageToPluginArg(output_); |
| 927 } | 935 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 typename ThreadTraits::Lock lock_; | 997 typename ThreadTraits::Lock lock_; |
| 990 | 998 |
| 991 // Protected by the lock. This will get reset when you do CancelAll, for | 999 // Protected by the lock. This will get reset when you do CancelAll, for |
| 992 // example. | 1000 // example. |
| 993 BackPointer* back_pointer_; | 1001 BackPointer* back_pointer_; |
| 994 }; | 1002 }; |
| 995 | 1003 |
| 996 } // namespace pp | 1004 } // namespace pp |
| 997 | 1005 |
| 998 #endif // PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_ | 1006 #endif // PPAPI_UTILITY_COMPLETION_CALLBACK_FACTORY_H_ |
| OLD | NEW |