Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: net/base/directory_lister.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef NET_BASE_DIRECTORY_LISTER_H_ 5 #ifndef NET_BASE_DIRECTORY_LISTER_H_
6 #define NET_BASE_DIRECTORY_LISTER_H_ 6 #define NET_BASE_DIRECTORY_LISTER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/message_loop/message_loop_proxy.h" 13 #include "base/message_loop/message_loop_proxy.h"
14 #include "net/base/net_export.h" 14 #include "net/base/net_export.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 // 18 //
19 // This class provides an API for listing the contents of a directory on the 19 // This class provides an API for listing the contents of a directory on the
20 // filesystem asynchronously. It spawns a background thread, and enumerates 20 // filesystem asynchronously. It spawns a background thread, and enumerates
21 // the specified directory on that thread. It marshalls WIN32_FIND_DATA 21 // the specified directory on that thread. It marshalls WIN32_FIND_DATA
22 // structs over to the main application thread. The consumer of this class 22 // structs over to the main application thread. The consumer of this class
23 // is insulated from any of the multi-threading details. 23 // is insulated from any of the multi-threading details.
24 // 24 //
25 class NET_EXPORT DirectoryLister { 25 class NET_EXPORT DirectoryLister {
26 public: 26 public:
27 // Represents one file found. 27 // Represents one file found.
28 struct DirectoryListerData { 28 struct DirectoryListerData {
29 base::FileEnumerator::FileInfo info; 29 base::FileEnumerator::FileInfo info;
30 base::FilePath path; 30 base::FilePath path;
31 }; 31 };
32 32
33 // Implement this class to receive directory entries. 33 // Implement this class to receive directory entries.
34 class DirectoryListerDelegate { 34 class DirectoryListerDelegate {
35 public: 35 public:
36 // Called for each file found by the lister. 36 // Called for each file found by the lister.
37 virtual void OnListFile(const DirectoryListerData& data) = 0; 37 virtual void OnListFile(const DirectoryListerData& data) = 0;
38 38
39 // Called when the listing is complete. 39 // Called when the listing is complete.
40 virtual void OnListDone(int error) = 0; 40 virtual void OnListDone(int error) = 0;
41 41
42 protected: 42 protected:
43 virtual ~DirectoryListerDelegate() {} 43 virtual ~DirectoryListerDelegate() {}
44 }; 44 };
45 45
46 // Sort options 46 // Sort options
47 // ALPHA_DIRS_FIRST is the default sort : 47 // ALPHA_DIRS_FIRST is the default sort :
48 // directories first in name order, then files by name order 48 // directories first in name order, then files by name order
49 // FULL_PATH sorts by paths as strings, ignoring files v. directories 49 // FULL_PATH sorts by paths as strings, ignoring files v. directories
50 // DATE sorts by last modified date 50 // DATE sorts by last modified date
51 enum SortType { 51 enum SortType { NO_SORT, DATE, ALPHA_DIRS_FIRST, FULL_PATH };
52 NO_SORT,
53 DATE,
54 ALPHA_DIRS_FIRST,
55 FULL_PATH
56 };
57 52
58 DirectoryLister(const base::FilePath& dir, 53 DirectoryLister(const base::FilePath& dir, DirectoryListerDelegate* delegate);
59 DirectoryListerDelegate* delegate);
60 54
61 DirectoryLister(const base::FilePath& dir, 55 DirectoryLister(const base::FilePath& dir,
62 bool recursive, 56 bool recursive,
63 SortType sort, 57 SortType sort,
64 DirectoryListerDelegate* delegate); 58 DirectoryListerDelegate* delegate);
65 59
66 // Will invoke Cancel(). 60 // Will invoke Cancel().
67 ~DirectoryLister(); 61 ~DirectoryLister();
68 62
69 // Call this method to start the directory enumeration thread. 63 // Call this method to start the directory enumeration thread.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 108
115 const scoped_refptr<Core> core_; 109 const scoped_refptr<Core> core_;
116 DirectoryListerDelegate* const delegate_; 110 DirectoryListerDelegate* const delegate_;
117 111
118 DISALLOW_COPY_AND_ASSIGN(DirectoryLister); 112 DISALLOW_COPY_AND_ASSIGN(DirectoryLister);
119 }; 113 };
120 114
121 } // namespace net 115 } // namespace net
122 116
123 #endif // NET_BASE_DIRECTORY_LISTER_H_ 117 #endif // NET_BASE_DIRECTORY_LISTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698