| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 | 12 |
| 13 #include "webrtc/base/taskparent.h" | 13 #include "webrtc/base/taskparent.h" |
| 14 | 14 |
| 15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
| 16 #include "webrtc/base/task.h" | 16 #include "webrtc/base/task.h" |
| 17 #include "webrtc/base/taskrunner.h" | 17 #include "webrtc/base/taskrunner.h" |
| 18 | 18 |
| 19 namespace rtc { | 19 namespace rtc { |
| 20 | 20 |
| 21 TaskParent::TaskParent(Task* derived_instance, TaskParent *parent) | 21 TaskParent::TaskParent(Task* derived_instance, TaskParent *parent) |
| 22 : parent_(parent) { | 22 : parent_(parent) { |
| 23 RTC_DCHECK(derived_instance != NULL); | 23 RTC_DCHECK(derived_instance != nullptr); |
| 24 RTC_DCHECK(parent != NULL); | 24 RTC_DCHECK(parent != nullptr); |
| 25 runner_ = parent->GetRunner(); | 25 runner_ = parent->GetRunner(); |
| 26 parent_->AddChild(derived_instance); | 26 parent_->AddChild(derived_instance); |
| 27 Initialize(); | 27 Initialize(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 TaskParent::TaskParent(TaskRunner *derived_instance) | 30 TaskParent::TaskParent(TaskRunner* derived_instance) |
| 31 : parent_(NULL), | 31 : parent_(nullptr), runner_(derived_instance) { |
| 32 runner_(derived_instance) { | 32 RTC_DCHECK(derived_instance != nullptr); |
| 33 RTC_DCHECK(derived_instance != NULL); | |
| 34 Initialize(); | 33 Initialize(); |
| 35 } | 34 } |
| 36 | 35 |
| 37 TaskParent::~TaskParent() = default; | 36 TaskParent::~TaskParent() = default; |
| 38 | 37 |
| 39 // Does common initialization of member variables | 38 // Does common initialization of member variables |
| 40 void TaskParent::Initialize() { | 39 void TaskParent::Initialize() { |
| 41 children_.reset(new ChildSet()); | 40 children_.reset(new ChildSet()); |
| 42 child_error_ = false; | 41 child_error_ = false; |
| 43 } | 42 } |
| 44 | 43 |
| 45 void TaskParent::AddChild(Task *child) { | 44 void TaskParent::AddChild(Task *child) { |
| 46 children_->insert(child); | 45 children_->insert(child); |
| 47 } | 46 } |
| 48 | 47 |
| 49 #if RTC_DCHECK_IS_ON | 48 #if RTC_DCHECK_IS_ON |
| 50 bool TaskParent::IsChildTask(Task *task) { | 49 bool TaskParent::IsChildTask(Task *task) { |
| 51 RTC_DCHECK(task != NULL); | 50 RTC_DCHECK(task != nullptr); |
| 52 return task->parent_ == this && children_->find(task) != children_->end(); | 51 return task->parent_ == this && children_->find(task) != children_->end(); |
| 53 } | 52 } |
| 54 #endif | 53 #endif |
| 55 | 54 |
| 56 bool TaskParent::AllChildrenDone() { | 55 bool TaskParent::AllChildrenDone() { |
| 57 for (ChildSet::iterator it = children_->begin(); | 56 for (ChildSet::iterator it = children_->begin(); |
| 58 it != children_->end(); | 57 it != children_->end(); |
| 59 ++it) { | 58 ++it) { |
| 60 if (!(*it)->IsDone()) | 59 if (!(*it)->IsDone()) |
| 61 return false; | 60 return false; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 89 parent_->OnChildStopped(task); | 88 parent_->OnChildStopped(task); |
| 90 } | 89 } |
| 91 | 90 |
| 92 void TaskParent::OnChildStopped(Task *child) { | 91 void TaskParent::OnChildStopped(Task *child) { |
| 93 if (child->HasError()) | 92 if (child->HasError()) |
| 94 child_error_ = true; | 93 child_error_ = true; |
| 95 children_->erase(child); | 94 children_->erase(child); |
| 96 } | 95 } |
| 97 | 96 |
| 98 } // namespace rtc | 97 } // namespace rtc |
| OLD | NEW |