Chromium Code Reviews| 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::Closure and WTF::CrossThreadClosure directly, instead of |
|
haraken
2016/03/02 09:27:35
Nit: I might prefer renaming WTF::Closure to WTF::
hiroshige
2016/03/03 02:21:07
Should we also rename bind() to sameThreadBind()?
haraken
2016/03/03 02:38:06
I'd prefer having sameThreadBind & sameThreadCallb
tzik
2016/03/03 04:49:30
It's up to you. :p
Since bind() in Blink is mostly
hiroshige
2016/03/04 02:02:46
Thanks for suggestions!
I renamed WTF::Closure to
| |
| 44 USING_FAST_MALLOC(Task); | 44 // 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<Closure> closure) |
| 48 : m_closure(std::move(closure)) | 53 : m_closure(std::move(closure)) |
| 49 { | 54 { |
| 50 } | 55 } |
| 51 | 56 |
| 52 void run() override | 57 void run() override |
| 53 { | 58 { |
| 54 (*m_closure)(); | 59 (*m_closure)(); |
| 55 } | 60 } |
| 56 | 61 |
| 57 private: | 62 private: |
| 58 OwnPtr<Closure> m_closure; | 63 OwnPtr<Closure> m_closure; |
| 59 }; | 64 }; |
| 60 | 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 } | |
| 74 | |
| 75 void run() override | |
| 76 { | |
| 77 (*m_closure)(); | |
| 78 } | |
| 79 | |
| 80 private: | |
| 81 OwnPtr<CrossThreadClosure> m_closure; | |
| 82 }; | |
| 83 | |
| 61 } // namespace blink | 84 } // namespace blink |
| 62 | 85 |
| 63 #endif // Task_h | 86 #endif // Task_h |
| OLD | NEW |