| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 class ExecutionContext; | 41 class ExecutionContext; |
| 42 | 42 |
| 43 class CORE_EXPORT ExecutionContextTask { | 43 class CORE_EXPORT ExecutionContextTask { |
| 44 WTF_MAKE_NONCOPYABLE(ExecutionContextTask); | 44 WTF_MAKE_NONCOPYABLE(ExecutionContextTask); |
| 45 USING_FAST_MALLOC(ExecutionContextTask); | 45 USING_FAST_MALLOC(ExecutionContextTask); |
| 46 | 46 |
| 47 public: | 47 public: |
| 48 ExecutionContextTask() {} | 48 ExecutionContextTask() {} |
| 49 virtual ~ExecutionContextTask() {} | 49 virtual ~ExecutionContextTask() {} |
| 50 virtual void performTask(ExecutionContext*) = 0; | 50 virtual void performTask(ExecutionContext*) = 0; |
| 51 |
| 52 void performTaskIfContextIsValid(ExecutionContext* context) { |
| 53 if (context) |
| 54 performTask(context); |
| 55 } |
| 51 }; | 56 }; |
| 52 | 57 |
| 53 namespace internal { | 58 namespace internal { |
| 54 | 59 |
| 55 template <WTF::FunctionThreadAffinity threadAffinity> | 60 template <WTF::FunctionThreadAffinity threadAffinity> |
| 56 void runCallClosureTask( | 61 void runCallClosureTask( |
| 57 std::unique_ptr<Function<void(), threadAffinity>> closure, | 62 std::unique_ptr<Function<void(), threadAffinity>> closure, |
| 58 ExecutionContext*) { | 63 ExecutionContext*) { |
| 59 (*closure)(); | 64 (*closure)(); |
| 60 } | 65 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 std::unique_ptr<ExecutionContextTask> createCrossThreadTask( | 162 std::unique_ptr<ExecutionContextTask> createCrossThreadTask( |
| 158 FunctionType function, | 163 FunctionType function, |
| 159 P&&... parameters) { | 164 P&&... parameters) { |
| 160 return internal::createCallClosureTask( | 165 return internal::createCallClosureTask( |
| 161 crossThreadBind(function, std::forward<P>(parameters)...)); | 166 crossThreadBind(function, std::forward<P>(parameters)...)); |
| 162 } | 167 } |
| 163 | 168 |
| 164 } // namespace blink | 169 } // namespace blink |
| 165 | 170 |
| 166 #endif | 171 #endif |
| OLD | NEW |