OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "net/base/directory_lister.h" | 5 #include "net/base/directory_lister.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/files/file_enumerator.h" | 11 #include "base/files/file_enumerator.h" |
11 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
12 #include "base/i18n/file_util_icu.h" | 13 #include "base/i18n/file_util_icu.h" |
13 #include "base/location.h" | 14 #include "base/location.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
17 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // have been destroyed. Setting |lister_| to NULL ensures any such access will | 115 // have been destroyed. Setting |lister_| to NULL ensures any such access will |
115 // cause a crash. | 116 // cause a crash. |
116 lister_ = nullptr; | 117 lister_ = nullptr; |
117 } | 118 } |
118 | 119 |
119 void DirectoryLister::Core::Start() { | 120 void DirectoryLister::Core::Start() { |
120 scoped_ptr<DirectoryList> directory_list(new DirectoryList()); | 121 scoped_ptr<DirectoryList> directory_list(new DirectoryList()); |
121 | 122 |
122 if (!base::DirectoryExists(dir_)) { | 123 if (!base::DirectoryExists(dir_)) { |
123 origin_task_runner_->PostTask( | 124 origin_task_runner_->PostTask( |
124 FROM_HERE, | 125 FROM_HERE, base::Bind(&Core::DoneOnOriginThread, this, |
125 base::Bind(&Core::DoneOnOriginThread, this, | 126 base::Passed(std::move(directory_list)), |
126 base::Passed(directory_list.Pass()), ERR_FILE_NOT_FOUND)); | 127 ERR_FILE_NOT_FOUND)); |
127 return; | 128 return; |
128 } | 129 } |
129 | 130 |
130 int types = base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES; | 131 int types = base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES; |
131 bool recursive; | 132 bool recursive; |
132 if (NO_SORT_RECURSIVE != type_) { | 133 if (NO_SORT_RECURSIVE != type_) { |
133 types |= base::FileEnumerator::INCLUDE_DOT_DOT; | 134 types |= base::FileEnumerator::INCLUDE_DOT_DOT; |
134 recursive = false; | 135 recursive = false; |
135 } else { | 136 } else { |
136 recursive = true; | 137 recursive = true; |
(...skipping 25 matching lines...) Expand all Loading... |
162 FROM_HERE, | 163 FROM_HERE, |
163 base::Bind(&DirectoryLister::Core::SendData, file_data)); | 164 base::Bind(&DirectoryLister::Core::SendData, file_data)); |
164 file_data.clear(); | 165 file_data.clear(); |
165 */ | 166 */ |
166 } | 167 } |
167 | 168 |
168 SortData(directory_list.get(), type_); | 169 SortData(directory_list.get(), type_); |
169 | 170 |
170 origin_task_runner_->PostTask( | 171 origin_task_runner_->PostTask( |
171 FROM_HERE, base::Bind(&Core::DoneOnOriginThread, this, | 172 FROM_HERE, base::Bind(&Core::DoneOnOriginThread, this, |
172 base::Passed(directory_list.Pass()), OK)); | 173 base::Passed(std::move(directory_list)), OK)); |
173 } | 174 } |
174 | 175 |
175 bool DirectoryLister::Core::IsCancelled() const { | 176 bool DirectoryLister::Core::IsCancelled() const { |
176 return !!base::subtle::NoBarrier_Load(&cancelled_); | 177 return !!base::subtle::NoBarrier_Load(&cancelled_); |
177 } | 178 } |
178 | 179 |
179 void DirectoryLister::Core::DoneOnOriginThread( | 180 void DirectoryLister::Core::DoneOnOriginThread( |
180 scoped_ptr<DirectoryList> directory_list, int error) const { | 181 scoped_ptr<DirectoryList> directory_list, int error) const { |
181 DCHECK(origin_task_runner_->BelongsToCurrentThread()); | 182 DCHECK(origin_task_runner_->BelongsToCurrentThread()); |
182 | 183 |
(...skipping 12 matching lines...) Expand all Loading... |
195 | 196 |
196 void DirectoryLister::OnListFile(const DirectoryListerData& data) { | 197 void DirectoryLister::OnListFile(const DirectoryListerData& data) { |
197 delegate_->OnListFile(data); | 198 delegate_->OnListFile(data); |
198 } | 199 } |
199 | 200 |
200 void DirectoryLister::OnListDone(int error) { | 201 void DirectoryLister::OnListDone(int error) { |
201 delegate_->OnListDone(error); | 202 delegate_->OnListDone(error); |
202 } | 203 } |
203 | 204 |
204 } // namespace net | 205 } // namespace net |
OLD | NEW |