OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_BASE_TASKPARENT_H__ |
| 12 #define WEBRTC_BASE_TASKPARENT_H__ |
| 13 |
| 14 #include <memory> |
| 15 #include <set> |
| 16 |
| 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/base/constructormagic.h" |
| 19 |
| 20 namespace rtc { |
| 21 |
| 22 class Task; |
| 23 class TaskRunner; |
| 24 |
| 25 class TaskParent { |
| 26 public: |
| 27 TaskParent(Task *derived_instance, TaskParent *parent); |
| 28 explicit TaskParent(TaskRunner *derived_instance); |
| 29 virtual ~TaskParent(); |
| 30 |
| 31 TaskParent *GetParent() { return parent_; } |
| 32 TaskRunner *GetRunner() { return runner_; } |
| 33 |
| 34 bool AllChildrenDone(); |
| 35 bool AnyChildError(); |
| 36 #if RTC_DCHECK_IS_ON |
| 37 bool IsChildTask(Task *task); |
| 38 #endif |
| 39 |
| 40 protected: |
| 41 void OnStopped(Task *task); |
| 42 void AbortAllChildren(); |
| 43 TaskParent *parent() { |
| 44 return parent_; |
| 45 } |
| 46 |
| 47 private: |
| 48 void Initialize(); |
| 49 void OnChildStopped(Task *child); |
| 50 void AddChild(Task *child); |
| 51 |
| 52 TaskParent *parent_; |
| 53 TaskRunner *runner_; |
| 54 bool child_error_; |
| 55 typedef std::set<Task *> ChildSet; |
| 56 std::unique_ptr<ChildSet> children_; |
| 57 RTC_DISALLOW_COPY_AND_ASSIGN(TaskParent); |
| 58 }; |
| 59 |
| 60 |
| 61 } // namespace rtc |
| 62 |
| 63 #endif // WEBRTC_BASE_TASKPARENT_H__ |
OLD | NEW |