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" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return file_util::LocaleAwareCompareFilenames(FilePath(a.filename), | 48 return file_util::LocaleAwareCompareFilenames(FilePath(a.filename), |
49 FilePath(b.filename)); | 49 FilePath(b.filename)); |
50 #endif | 50 #endif |
51 } | 51 } |
52 | 52 |
53 DirectoryLister::DirectoryLister(const FilePath& dir, | 53 DirectoryLister::DirectoryLister(const FilePath& dir, |
54 DirectoryListerDelegate* delegate) | 54 DirectoryListerDelegate* delegate) |
55 : dir_(dir), | 55 : dir_(dir), |
56 delegate_(delegate), | 56 delegate_(delegate), |
57 message_loop_(NULL), | 57 message_loop_(NULL), |
58 thread_(NULL), | 58 thread_(kNullThreadHandle), |
59 canceled_(false) { | 59 canceled_(false) { |
60 DCHECK(!dir.value().empty()); | 60 DCHECK(!dir.value().empty()); |
61 } | 61 } |
62 | 62 |
63 DirectoryLister::~DirectoryLister() { | 63 DirectoryLister::~DirectoryLister() { |
64 if (thread_) { | 64 if (thread_) { |
65 PlatformThread::Join(thread_); | 65 PlatformThread::Join(thread_); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
(...skipping 12 matching lines...) Expand all Loading... |
81 } | 81 } |
82 | 82 |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 void DirectoryLister::Cancel() { | 86 void DirectoryLister::Cancel() { |
87 canceled_ = true; | 87 canceled_ = true; |
88 | 88 |
89 if (thread_) { | 89 if (thread_) { |
90 PlatformThread::Join(thread_); | 90 PlatformThread::Join(thread_); |
91 thread_ = NULL; | 91 thread_ = kNullThreadHandle; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void DirectoryLister::ThreadMain() { | 95 void DirectoryLister::ThreadMain() { |
96 DirectoryDataEvent* e = new DirectoryDataEvent(this); | 96 DirectoryDataEvent* e = new DirectoryDataEvent(this); |
97 | 97 |
98 if (!file_util::DirectoryExists(dir_)) { | 98 if (!file_util::DirectoryExists(dir_)) { |
99 e->error = net::ERR_FILE_NOT_FOUND; | 99 e->error = net::ERR_FILE_NOT_FOUND; |
100 message_loop_->PostTask(FROM_HERE, e); | 100 message_loop_->PostTask(FROM_HERE, e); |
101 Release(); | 101 Release(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // If canceled, we need to report some kind of error, but don't overwrite the | 151 // If canceled, we need to report some kind of error, but don't overwrite the |
152 // error condition if it is already set. | 152 // error condition if it is already set. |
153 if (!error && canceled_) | 153 if (!error && canceled_) |
154 error = net::ERR_ABORTED; | 154 error = net::ERR_ABORTED; |
155 | 155 |
156 if (delegate_) | 156 if (delegate_) |
157 delegate_->OnListDone(error); | 157 delegate_->OnListDone(error); |
158 } | 158 } |
159 | 159 |
160 } // namespace net | 160 } // namespace net |
OLD | NEW |