OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/i18n/file_util_icu.h" | 11 #include "base/i18n/file_util_icu.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/platform_thread.h" | 13 #include "base/platform_thread.h" |
| 14 #include "base/thread_restrictions.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 static const int kFilesPerEvent = 8; | 19 static const int kFilesPerEvent = 8; |
19 | 20 |
20 // A task which is used to signal the delegate asynchronously. | 21 // A task which is used to signal the delegate asynchronously. |
21 class DirectoryDataEvent : public Task { | 22 class DirectoryDataEvent : public Task { |
22 public: | 23 public: |
23 explicit DirectoryDataEvent(DirectoryLister* d) : lister(d), error(0) { | 24 explicit DirectoryDataEvent(DirectoryLister* d) : lister(d), error(0) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 recursive_(recursive), | 116 recursive_(recursive), |
116 delegate_(delegate), | 117 delegate_(delegate), |
117 sort_(sort), | 118 sort_(sort), |
118 message_loop_(NULL), | 119 message_loop_(NULL), |
119 thread_(kNullThreadHandle) { | 120 thread_(kNullThreadHandle) { |
120 DCHECK(!dir.value().empty()); | 121 DCHECK(!dir.value().empty()); |
121 } | 122 } |
122 | 123 |
123 DirectoryLister::~DirectoryLister() { | 124 DirectoryLister::~DirectoryLister() { |
124 if (thread_) { | 125 if (thread_) { |
| 126 // This is a bug and we should stop joining this thread. |
| 127 // http://crbug.com/65331 |
| 128 base::ThreadRestrictions::ScopedAllowIO allow_io; |
125 PlatformThread::Join(thread_); | 129 PlatformThread::Join(thread_); |
126 } | 130 } |
127 } | 131 } |
128 | 132 |
129 bool DirectoryLister::Start() { | 133 bool DirectoryLister::Start() { |
130 // spawn a thread to enumerate the specified directory | 134 // spawn a thread to enumerate the specified directory |
131 | 135 |
132 // pass events back to the current thread | 136 // pass events back to the current thread |
133 message_loop_ = MessageLoop::current(); | 137 message_loop_ = MessageLoop::current(); |
134 DCHECK(message_loop_) << "calling thread must have a message loop"; | 138 DCHECK(message_loop_) << "calling thread must have a message loop"; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // If canceled is set, we need to report some kind of error, | 227 // If canceled is set, we need to report some kind of error, |
224 // but don't overwrite the error condition if it is already set. | 228 // but don't overwrite the error condition if it is already set. |
225 if (!error && canceled_.IsSet()) | 229 if (!error && canceled_.IsSet()) |
226 error = net::ERR_ABORTED; | 230 error = net::ERR_ABORTED; |
227 | 231 |
228 if (delegate_) | 232 if (delegate_) |
229 delegate_->OnListDone(error); | 233 delegate_->OnListDone(error); |
230 } | 234 } |
231 | 235 |
232 } // namespace net | 236 } // namespace net |
OLD | NEW |