OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 TOOLS_GN_INPUT_FILE_MANAGER_H_ | 5 #ifndef TOOLS_GN_INPUT_FILE_MANAGER_H_ |
6 #define TOOLS_GN_INPUT_FILE_MANAGER_H_ | 6 #define TOOLS_GN_INPUT_FILE_MANAGER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // | 75 // |
76 // This solves the problem that sometimes we need to execute something | 76 // This solves the problem that sometimes we need to execute something |
77 // dynamic and save the result, but the values all have references to the | 77 // dynamic and save the result, but the values all have references to the |
78 // nodes and file that created it. Either we need to reset the origin of | 78 // nodes and file that created it. Either we need to reset the origin of |
79 // the values and lose context for error reporting, or somehow keep the | 79 // the values and lose context for error reporting, or somehow keep the |
80 // associated parse nodes, tokens, and file data in memory. This function | 80 // associated parse nodes, tokens, and file data in memory. This function |
81 // allows the latter. | 81 // allows the latter. |
82 void AddDynamicInput(const SourceFile& name, | 82 void AddDynamicInput(const SourceFile& name, |
83 InputFile** file, | 83 InputFile** file, |
84 std::vector<Token>** tokens, | 84 std::vector<Token>** tokens, |
85 scoped_ptr<ParseNode>** parse_root); | 85 std::unique_ptr<ParseNode>** parse_root); |
86 | 86 |
87 // Does not count dynamic input. | 87 // Does not count dynamic input. |
88 int GetInputFileCount() const; | 88 int GetInputFileCount() const; |
89 | 89 |
90 // Fills the vector with all input files. | 90 // Fills the vector with all input files. |
91 void GetAllPhysicalInputFileNames(std::vector<base::FilePath>* result) const; | 91 void GetAllPhysicalInputFileNames(std::vector<base::FilePath>* result) const; |
92 | 92 |
93 private: | 93 private: |
94 friend class base::RefCountedThreadSafe<InputFileManager>; | 94 friend class base::RefCountedThreadSafe<InputFileManager>; |
95 | 95 |
96 struct InputFileData { | 96 struct InputFileData { |
97 explicit InputFileData(const SourceFile& file_name); | 97 explicit InputFileData(const SourceFile& file_name); |
98 ~InputFileData(); | 98 ~InputFileData(); |
99 | 99 |
100 // Don't touch this outside the lock until it's marked loaded. | 100 // Don't touch this outside the lock until it's marked loaded. |
101 InputFile file; | 101 InputFile file; |
102 | 102 |
103 bool loaded; | 103 bool loaded; |
104 | 104 |
105 bool sync_invocation; | 105 bool sync_invocation; |
106 | 106 |
107 // Lists all invocations that need to be executed when the file completes | 107 // Lists all invocations that need to be executed when the file completes |
108 // loading. | 108 // loading. |
109 std::vector<FileLoadCallback> scheduled_callbacks; | 109 std::vector<FileLoadCallback> scheduled_callbacks; |
110 | 110 |
111 // Event to signal when the load is complete (or fails). This is lazily | 111 // Event to signal when the load is complete (or fails). This is lazily |
112 // created only when a thread is synchronously waiting for this load (which | 112 // created only when a thread is synchronously waiting for this load (which |
113 // only happens for imports). | 113 // only happens for imports). |
114 scoped_ptr<base::WaitableEvent> completion_event; | 114 std::unique_ptr<base::WaitableEvent> completion_event; |
115 | 115 |
116 std::vector<Token> tokens; | 116 std::vector<Token> tokens; |
117 | 117 |
118 // Null before the file is loaded or if loading failed. | 118 // Null before the file is loaded or if loading failed. |
119 scoped_ptr<ParseNode> parsed_root; | 119 std::unique_ptr<ParseNode> parsed_root; |
120 Err parse_error; | 120 Err parse_error; |
121 }; | 121 }; |
122 | 122 |
123 virtual ~InputFileManager(); | 123 virtual ~InputFileManager(); |
124 | 124 |
125 void BackgroundLoadFile(const LocationRange& origin, | 125 void BackgroundLoadFile(const LocationRange& origin, |
126 const BuildSettings* build_settings, | 126 const BuildSettings* build_settings, |
127 const SourceFile& name, | 127 const SourceFile& name, |
128 InputFile* file); | 128 InputFile* file); |
129 | 129 |
(...skipping 17 matching lines...) Expand all Loading... |
147 // | 147 // |
148 // See AddDynamicInput(). | 148 // See AddDynamicInput(). |
149 // | 149 // |
150 // Owning pointers. | 150 // Owning pointers. |
151 std::vector<InputFileData*> dynamic_inputs_; | 151 std::vector<InputFileData*> dynamic_inputs_; |
152 | 152 |
153 DISALLOW_COPY_AND_ASSIGN(InputFileManager); | 153 DISALLOW_COPY_AND_ASSIGN(InputFileManager); |
154 }; | 154 }; |
155 | 155 |
156 #endif // TOOLS_GN_INPUT_FILE_MANAGER_H_ | 156 #endif // TOOLS_GN_INPUT_FILE_MANAGER_H_ |
OLD | NEW |