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

Side by Side Diff: components/drive/search_metadata.h

Issue 1321553003: Files.app: split query into AND conditioned keywords in metadata search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | components/drive/search_metadata.cc » ('j') | components/drive/search_metadata.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef COMPONENTS_DRIVE_SEARCH_METADATA_H_ 5 #ifndef COMPONENTS_DRIVE_SEARCH_METADATA_H_
6 #define COMPONENTS_DRIVE_SEARCH_METADATA_H_ 6 #define COMPONENTS_DRIVE_SEARCH_METADATA_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "components/drive/file_system_interface.h" 10 #include "components/drive/file_system_interface.h"
hashimoto 2015/09/02 03:24:11 #include "base/memory/scoped_vector.h" should be h
yawano 2015/09/04 09:33:55 Done.
11 11
12 namespace base { 12 namespace base {
13 namespace i18n { 13 namespace i18n {
14 class FixedPatternStringSearchIgnoringCaseAndAccents; 14 class FixedPatternStringSearchIgnoringCaseAndAccents;
15 } // namespace i18n 15 } // namespace i18n
16 } // namespace base 16 } // namespace base
17 17
18 namespace drive { 18 namespace drive {
19 namespace internal { 19 namespace internal {
20 20
21 class ResourceMetadata; 21 class ResourceMetadata;
22 22
23 typedef base::Callback<bool(const ResourceEntry&)> SearchMetadataPredicate; 23 typedef base::Callback<bool(const ResourceEntry&)> SearchMetadataPredicate;
24 24
25 // Searches the local resource metadata, and returns the entries 25 // Searches the local resource metadata, and returns the entries
26 // |at_most_num_matches| that contain |query| in their base names. Search is 26 // |at_most_num_matches| that contain |query| in their base names. Search is
27 // done in a case-insensitive fashion. The eligible entries are selected based 27 // done in a case-insensitive fashion. |query| is splitted into keywords by
28 // on the given |options|, which is a bit-wise OR of SearchMetadataOptions. 28 // whitespace. All keywords are considered as AND condition. The eligible
29 // |callback| must not be null. Must be called on UI thread. Empty |query| 29 // entries are selected based on the given |options|, which is a bit-wise OR of
30 // matches any base name. i.e. returns everything. |blocking_task_runner| must 30 // SearchMetadataOptions. |callback| must not be null. Must be called on UI
31 // be the same one as |resource_metadata| uses. 31 // thread. Empty |query| matches any base name. i.e. returns everything.
32 // |blocking_task_runner| must be the same one as |resource_metadata| uses.
32 void SearchMetadata( 33 void SearchMetadata(
33 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner, 34 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner,
34 ResourceMetadata* resource_metadata, 35 ResourceMetadata* resource_metadata,
35 const std::string& query, 36 const std::string& query,
36 const SearchMetadataPredicate& predicate, 37 const SearchMetadataPredicate& predicate,
37 size_t at_most_num_matches, 38 size_t at_most_num_matches,
38 const SearchMetadataCallback& callback); 39 const SearchMetadataCallback& callback);
39 40
40 // Returns true if |entry| is eligible for the search |options| and should be 41 // Returns true if |entry| is eligible for the search |options| and should be
41 // tested for the match with the query. If 42 // tested for the match with the query. If
42 // SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS is requested, the hosted documents 43 // SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS is requested, the hosted documents
43 // are skipped. If SEARCH_METADATA_EXCLUDE_DIRECTORIES is requested, the 44 // are skipped. If SEARCH_METADATA_EXCLUDE_DIRECTORIES is requested, the
44 // directories are skipped. If SEARCH_METADATA_SHARED_WITH_ME is requested, only 45 // directories are skipped. If SEARCH_METADATA_SHARED_WITH_ME is requested, only
45 // the entries with shared-with-me label will be tested. If 46 // the entries with shared-with-me label will be tested. If
46 // SEARCH_METADATA_OFFLINE is requested, only hosted documents and cached files 47 // SEARCH_METADATA_OFFLINE is requested, only hosted documents and cached files
47 // match with the query. This option can not be used with other options. 48 // match with the query. This option can not be used with other options.
48 bool MatchesType(int options, const ResourceEntry& entry); 49 bool MatchesType(int options, const ResourceEntry& entry);
49 50
50 // Finds |query| in |text| while ignoring cases or accents. Cases of non-ASCII 51 // Finds |queries| in |text| while ignoring cases or accents. Cases of non-ASCII
51 // characters are also ignored; they are compared in the 'Primary Level' of 52 // characters are also ignored; they are compared in the 'Primary Level' of
52 // http://userguide.icu-project.org/collation/concepts. 53 // http://userguide.icu-project.org/collation/concepts.
53 // Returns true if |query| is found. |highlighted_text| will have the original 54 // Returns true if |queries| are found. |highlighted_text| will have the
55 // original
54 // text with matched portions highlighted with <b> tag (only the first match 56 // text with matched portions highlighted with <b> tag (only the first match
55 // is highlighted). Meta characters are escaped like &lt;. The original 57 // is highlighted). Meta characters are escaped like &lt;. The original
56 // contents of |highlighted_text| will be lost. 58 // contents of |highlighted_text| will be lost.
57 bool FindAndHighlight( 59 bool FindAndHighlight(
58 const std::string& text, 60 const std::string& text,
59 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents* query, 61 const ScopedVector<
62 base::i18n::FixedPatternStringSearchIgnoringCaseAndAccents>& queries,
60 std::string* highlighted_text); 63 std::string* highlighted_text);
61 64
62 } // namespace internal 65 } // namespace internal
63 } // namespace drive 66 } // namespace drive
64 67
65 #endif // COMPONENTS_DRIVE_SEARCH_METADATA_H_ 68 #endif // COMPONENTS_DRIVE_SEARCH_METADATA_H_
OLDNEW
« no previous file with comments | « no previous file | components/drive/search_metadata.cc » ('j') | components/drive/search_metadata.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698