| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 BASE_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_ | 5 #ifndef BASE_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_ |
| 6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_ | 6 #define BASE_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/task_scheduler/task_tracker.h" | 12 #include "base/task_scheduler/task_tracker.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 | 15 |
| 16 class MessageLoopForIO; | 16 class MessageLoopForIO; |
| 17 | 17 |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 struct Task; | 20 struct Task; |
| 21 | 21 |
| 22 // A TaskTracker that instantiates a FileDescriptorWatcher in the scope in which | 22 // A TaskTracker that instantiates a FileDescriptorWatcher in the scope in which |
| 23 // a task runs. Used on all POSIX platforms except NaCl SFI. | 23 // a task runs. Used on all POSIX platforms except NaCl SFI. |
| 24 // set_watch_file_descriptor_message_loop() must be called before the |
| 25 // TaskTracker can run tasks. |
| 24 class BASE_EXPORT TaskTrackerPosix : public TaskTracker { | 26 class BASE_EXPORT TaskTrackerPosix : public TaskTracker { |
| 25 public: | 27 public: |
| 26 // |watch_file_descriptor_message_loop| is used to setup FileDescriptorWatcher | 28 TaskTrackerPosix(); |
| 27 // in the scope in which a Task runs. | |
| 28 TaskTrackerPosix(MessageLoopForIO* watch_file_descriptor_message_loop); | |
| 29 ~TaskTrackerPosix(); | 29 ~TaskTrackerPosix(); |
| 30 | 30 |
| 31 // Sets the MessageLoopForIO with which to setup FileDescriptorWatcher in the |
| 32 // scope in which tasks run. Must be called before starting to run tasks. |
| 33 // External synchronization is required between a call to this and a call to |
| 34 // RunTask(). |
| 35 void set_watch_file_descriptor_message_loop( |
| 36 MessageLoopForIO* watch_file_descriptor_message_loop) { |
| 37 watch_file_descriptor_message_loop_ = watch_file_descriptor_message_loop; |
| 38 } |
| 39 |
| 31 private: | 40 private: |
| 32 // TaskTracker: | 41 // TaskTracker: |
| 33 void PerformRunTask(std::unique_ptr<Task> task) override; | 42 void PerformRunTask(std::unique_ptr<Task> task) override; |
| 34 | 43 |
| 35 MessageLoopForIO* const watch_file_descriptor_message_loop_; | 44 MessageLoopForIO* watch_file_descriptor_message_loop_ = nullptr; |
| 36 | 45 |
| 37 DISALLOW_COPY_AND_ASSIGN(TaskTrackerPosix); | 46 DISALLOW_COPY_AND_ASSIGN(TaskTrackerPosix); |
| 38 }; | 47 }; |
| 39 | 48 |
| 40 } // namespace internal | 49 } // namespace internal |
| 41 } // namespace base | 50 } // namespace base |
| 42 | 51 |
| 43 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_ | 52 #endif // BASE_TASK_SCHEDULER_TASK_TRACKER_POSIX_H_ |
| OLD | NEW |