| 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "public/platform/WebTaskRunner.h" | 34 #include "public/platform/WebTaskRunner.h" |
| 35 #include "wtf/Allocator.h" | 35 #include "wtf/Allocator.h" |
| 36 #include "wtf/Functional.h" | 36 #include "wtf/Functional.h" |
| 37 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
| 38 #include "wtf/OwnPtr.h" | 38 #include "wtf/OwnPtr.h" |
| 39 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class Task : public WebTaskRunner::Task { | 43 // Please use WTF::SameThreadClosure or WTF::CrossThreadClosure directly, |
| 44 USING_FAST_MALLOC(Task); | 44 // instead of wrapping them by blink::SameThreadTask/CrossThreadTask here. |
| 45 WTF_MAKE_NONCOPYABLE(Task); | 45 |
| 46 // TODO(hiroshige): Make these classes internal to |
| 47 // Source/platform/WebTaskRunner.cpp. |
| 48 class SameThreadTask : public WebTaskRunner::Task { |
| 49 USING_FAST_MALLOC(SameThreadTask); |
| 50 WTF_MAKE_NONCOPYABLE(SameThreadTask); |
| 46 public: | 51 public: |
| 47 explicit Task(PassOwnPtr<Closure> closure) | 52 explicit SameThreadTask(PassOwnPtr<SameThreadClosure> closure) |
| 48 : m_closure(std::move(closure)) | 53 : m_closure(std::move(closure)) |
| 49 { | 54 { |
| 50 } | 55 } |
| 56 |
| 57 void run() override |
| 58 { |
| 59 (*m_closure)(); |
| 60 } |
| 61 |
| 62 private: |
| 63 OwnPtr<SameThreadClosure> m_closure; |
| 64 }; |
| 65 |
| 66 class CrossThreadTask : public WebTaskRunner::Task { |
| 67 USING_FAST_MALLOC(CrossThreadTask); |
| 68 WTF_MAKE_NONCOPYABLE(CrossThreadTask); |
| 69 public: |
| 70 explicit CrossThreadTask(PassOwnPtr<CrossThreadClosure> closure) |
| 71 : m_closure(std::move(closure)) |
| 72 { |
| 73 } |
| 51 | 74 |
| 52 void run() override | 75 void run() override |
| 53 { | 76 { |
| 54 (*m_closure)(); | 77 (*m_closure)(); |
| 55 } | 78 } |
| 56 | 79 |
| 57 private: | 80 private: |
| 58 OwnPtr<Closure> m_closure; | 81 OwnPtr<CrossThreadClosure> m_closure; |
| 59 }; | 82 }; |
| 60 | 83 |
| 61 } // namespace blink | 84 } // namespace blink |
| 62 | 85 |
| 63 #endif // Task_h | 86 #endif // Task_h |
| OLD | NEW |