OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/devtools/devtools_file_system_indexer.h" | 5 #include "chrome/browser/devtools/devtools_file_system_indexer.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <iterator> | 9 #include <iterator> |
8 | 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/callback.h" | 12 #include "base/callback.h" |
11 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
12 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
13 #include "base/files/file_util_proxy.h" | 15 #include "base/files/file_util_proxy.h" |
14 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
15 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" |
16 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
18 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
19 | 22 |
20 using base::Bind; | 23 using base::Bind; |
21 using base::Callback; | 24 using base::Callback; |
22 using base::FileEnumerator; | 25 using base::FileEnumerator; |
23 using base::FilePath; | 26 using base::FilePath; |
24 using base::Time; | 27 using base::Time; |
25 using base::TimeDelta; | 28 using base::TimeDelta; |
26 using base::TimeTicks; | 29 using base::TimeTicks; |
27 using content::BrowserThread; | 30 using content::BrowserThread; |
28 using std::map; | 31 using std::map; |
29 using std::set; | 32 using std::set; |
30 using std::string; | 33 using std::string; |
31 using std::vector; | 34 using std::vector; |
32 | 35 |
33 namespace { | 36 namespace { |
34 | 37 |
35 typedef int32 Trigram; | 38 typedef int32_t Trigram; |
36 typedef char TrigramChar; | 39 typedef char TrigramChar; |
37 typedef uint16 FileId; | 40 typedef uint16_t FileId; |
38 | 41 |
39 const int kMinTimeoutBetweenWorkedNitification = 200; | 42 const int kMinTimeoutBetweenWorkedNitification = 200; |
40 // Trigram characters include all ASCII printable characters (32-126) except for | 43 // Trigram characters include all ASCII printable characters (32-126) except for |
41 // the capital letters, because the index is case insensitive. | 44 // the capital letters, because the index is case insensitive. |
42 const size_t kTrigramCharacterCount = 126 - 'Z' - 1 + 'A' - ' ' + 1; | 45 const size_t kTrigramCharacterCount = 126 - 'Z' - 1 + 'A' - ' ' + 1; |
43 const size_t kTrigramCount = | 46 const size_t kTrigramCount = |
44 kTrigramCharacterCount * kTrigramCharacterCount * kTrigramCharacterCount; | 47 kTrigramCharacterCount * kTrigramCharacterCount * kTrigramCharacterCount; |
45 const int kMaxReadLength = 10 * 1024; | 48 const int kMaxReadLength = 10 * 1024; |
46 const TrigramChar kUndefinedTrigramChar = -1; | 49 const TrigramChar kUndefinedTrigramChar = -1; |
47 const TrigramChar kBinaryTrigramChar = -2; | 50 const TrigramChar kBinaryTrigramChar = -2; |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 vector<FilePath> file_paths = g_trigram_index.Get().Search(query); | 476 vector<FilePath> file_paths = g_trigram_index.Get().Search(query); |
474 vector<string> result; | 477 vector<string> result; |
475 FilePath path = FilePath::FromUTF8Unsafe(file_system_path); | 478 FilePath path = FilePath::FromUTF8Unsafe(file_system_path); |
476 vector<FilePath>::const_iterator it = file_paths.begin(); | 479 vector<FilePath>::const_iterator it = file_paths.begin(); |
477 for (; it != file_paths.end(); ++it) { | 480 for (; it != file_paths.end(); ++it) { |
478 if (path.IsParent(*it)) | 481 if (path.IsParent(*it)) |
479 result.push_back(it->AsUTF8Unsafe()); | 482 result.push_back(it->AsUTF8Unsafe()); |
480 } | 483 } |
481 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, Bind(callback, result)); | 484 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, Bind(callback, result)); |
482 } | 485 } |
OLD | NEW |