OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/platform_thread.h" | 9 #include "base/platform_thread.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 | 11 |
(...skipping 18 matching lines...) Expand all Loading... |
30 scoped_refptr<DirectoryLister> lister; | 30 scoped_refptr<DirectoryLister> lister; |
31 file_util::FileEnumerator::FindInfo data[kFilesPerEvent]; | 31 file_util::FileEnumerator::FindInfo data[kFilesPerEvent]; |
32 int count, error; | 32 int count, error; |
33 }; | 33 }; |
34 | 34 |
35 DirectoryLister::DirectoryLister(const FilePath& dir, | 35 DirectoryLister::DirectoryLister(const FilePath& dir, |
36 DirectoryListerDelegate* delegate) | 36 DirectoryListerDelegate* delegate) |
37 : dir_(dir), | 37 : dir_(dir), |
38 delegate_(delegate), | 38 delegate_(delegate), |
39 message_loop_(NULL), | 39 message_loop_(NULL), |
40 thread_(0), | 40 thread_(NULL), |
41 canceled_(false) { | 41 canceled_(false) { |
42 DCHECK(!dir.value().empty()); | 42 DCHECK(!dir.value().empty()); |
43 } | 43 } |
44 | 44 |
45 DirectoryLister::~DirectoryLister() { | 45 DirectoryLister::~DirectoryLister() { |
46 if (thread_) { | 46 if (thread_) { |
47 PlatformThread::Join(thread_); | 47 PlatformThread::Join(thread_); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
(...skipping 12 matching lines...) Expand all Loading... |
63 } | 63 } |
64 | 64 |
65 return true; | 65 return true; |
66 } | 66 } |
67 | 67 |
68 void DirectoryLister::Cancel() { | 68 void DirectoryLister::Cancel() { |
69 canceled_ = true; | 69 canceled_ = true; |
70 | 70 |
71 if (thread_) { | 71 if (thread_) { |
72 PlatformThread::Join(thread_); | 72 PlatformThread::Join(thread_); |
73 thread_ = 0; | 73 thread_ = NULL; |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 void DirectoryLister::ThreadMain() { | 77 void DirectoryLister::ThreadMain() { |
78 DirectoryDataEvent* e = new DirectoryDataEvent(this); | 78 DirectoryDataEvent* e = new DirectoryDataEvent(this); |
79 | 79 |
80 if (!file_util::DirectoryExists(dir_)) { | 80 if (!file_util::DirectoryExists(dir_)) { |
81 e->error = net::ERR_FILE_NOT_FOUND; | 81 e->error = net::ERR_FILE_NOT_FOUND; |
82 message_loop_->PostTask(FROM_HERE, e); | 82 message_loop_->PostTask(FROM_HERE, e); |
83 Release(); | 83 Release(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // If canceled, we need to report some kind of error, but don't overwrite the | 123 // If canceled, we need to report some kind of error, but don't overwrite the |
124 // error condition if it is already set. | 124 // error condition if it is already set. |
125 if (!error && canceled_) | 125 if (!error && canceled_) |
126 error = net::ERR_ABORTED; | 126 error = net::ERR_ABORTED; |
127 | 127 |
128 if (delegate_) | 128 if (delegate_) |
129 delegate_->OnListDone(error); | 129 delegate_->OnListDone(error); |
130 } | 130 } |
131 | 131 |
132 } // namespace net | 132 } // namespace net |
OLD | NEW |