| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef GCTaskRunner_h | 31 #ifndef GCTaskRunner_h |
| 32 #define GCTaskRunner_h | 32 #define GCTaskRunner_h |
| 33 | 33 |
| 34 #include "platform/ThreadSafeFunctional.h" | 34 #include "platform/ThreadSafeFunctional.h" |
| 35 #include "platform/heap/ThreadState.h" | 35 #include "platform/heap/ThreadState.h" |
| 36 #include "public/platform/WebTaskRunner.h" | 36 #include "public/platform/WebTaskRunner.h" |
| 37 #include "public/platform/WebThread.h" | 37 #include "public/platform/WebThread.h" |
| 38 #include "public/platform/WebTraceLocation.h" | 38 #include "public/platform/WebTraceLocation.h" |
| 39 #include "wtf/PtrUtil.h" |
| 40 #include <memory> |
| 39 | 41 |
| 40 namespace blink { | 42 namespace blink { |
| 41 | 43 |
| 42 class MessageLoopInterruptor final : public BlinkGCInterruptor { | 44 class MessageLoopInterruptor final : public BlinkGCInterruptor { |
| 43 public: | 45 public: |
| 44 explicit MessageLoopInterruptor(WebTaskRunner* taskRunner) : m_taskRunner(ta
skRunner) { } | 46 explicit MessageLoopInterruptor(WebTaskRunner* taskRunner) : m_taskRunner(ta
skRunner) { } |
| 45 | 47 |
| 46 void requestInterrupt() override | 48 void requestInterrupt() override |
| 47 { | 49 { |
| 48 // GCTask has an empty run() method. Its only purpose is to guarantee | 50 // GCTask has an empty run() method. Its only purpose is to guarantee |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 95 } |
| 94 | 96 |
| 95 private: | 97 private: |
| 96 int m_nesting; | 98 int m_nesting; |
| 97 }; | 99 }; |
| 98 | 100 |
| 99 class GCTaskRunner final { | 101 class GCTaskRunner final { |
| 100 USING_FAST_MALLOC(GCTaskRunner); | 102 USING_FAST_MALLOC(GCTaskRunner); |
| 101 public: | 103 public: |
| 102 explicit GCTaskRunner(WebThread* thread) | 104 explicit GCTaskRunner(WebThread* thread) |
| 103 : m_gcTaskObserver(adoptPtr(new GCTaskObserver)) | 105 : m_gcTaskObserver(wrapUnique(new GCTaskObserver)) |
| 104 , m_thread(thread) | 106 , m_thread(thread) |
| 105 { | 107 { |
| 106 m_thread->addTaskObserver(m_gcTaskObserver.get()); | 108 m_thread->addTaskObserver(m_gcTaskObserver.get()); |
| 107 ThreadState::current()->addInterruptor(adoptPtr(new MessageLoopInterrupt
or(thread->getWebTaskRunner()))); | 109 ThreadState::current()->addInterruptor(wrapUnique(new MessageLoopInterru
ptor(thread->getWebTaskRunner()))); |
| 108 } | 110 } |
| 109 | 111 |
| 110 ~GCTaskRunner() | 112 ~GCTaskRunner() |
| 111 { | 113 { |
| 112 m_thread->removeTaskObserver(m_gcTaskObserver.get()); | 114 m_thread->removeTaskObserver(m_gcTaskObserver.get()); |
| 113 } | 115 } |
| 114 | 116 |
| 115 private: | 117 private: |
| 116 OwnPtr<GCTaskObserver> m_gcTaskObserver; | 118 std::unique_ptr<GCTaskObserver> m_gcTaskObserver; |
| 117 WebThread* m_thread; | 119 WebThread* m_thread; |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 } // namespace blink | 122 } // namespace blink |
| 121 | 123 |
| 122 #endif | 124 #endif |
| OLD | NEW |