OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "tools/gn/item_node.h" | |
6 | |
7 #include <algorithm> | |
8 | |
9 #include "base/callback.h" | |
10 #include "base/logging.h" | |
11 #include "tools/gn/item.h" | |
12 | |
13 ItemNode::ItemNode(Item* i) | |
14 : state_(REFERENCED), | |
15 item_(i) { | |
16 } | |
17 | |
18 ItemNode::~ItemNode() { | |
19 } | |
20 | |
21 void ItemNode::AddDependency(ItemNode* node) { | |
22 if (direct_dependencies_.find(node) != direct_dependencies_.end()) | |
23 return; // Already have this dep. | |
24 direct_dependencies_.insert(node); | |
25 | |
26 if (node->state() != RESOLVED) { | |
27 // Wire up the pending resolution info. | |
28 unresolved_dependencies_.insert(node); | |
29 node->waiting_on_resolution_.insert(this); | |
30 } | |
31 } | |
32 | |
33 void ItemNode::MarkDirectDependencyResolved(ItemNode* node) { | |
34 DCHECK(unresolved_dependencies_.find(node) != unresolved_dependencies_.end()); | |
35 unresolved_dependencies_.erase(node); | |
36 } | |
37 | |
38 void ItemNode::SwapOutWaitingDependencySet(ItemNodeSet* out_set) { | |
39 waiting_on_resolution_.swap(*out_set); | |
40 } | |
41 | |
42 void ItemNode::SetGenerated() { | |
43 state_ = GENERATED; | |
44 } | |
45 | |
46 void ItemNode::SetResolved() { | |
47 state_ = RESOLVED; | |
48 | |
49 if (!resolved_closure_.is_null()) | |
50 resolved_closure_.Run(); | |
51 } | |
OLD | NEW |