OLD | NEW |
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 #include "chrome/browser/chromeos/drive/search_metadata.h" | 5 #include "chrome/browser/chromeos/drive/search_metadata.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::Bind(&SearchMetadataHelper::DidReadDirectoryByPath, | 106 base::Bind(&SearchMetadataHelper::DidReadDirectoryByPath, |
107 weak_ptr_factory_.GetWeakPtr(), | 107 weak_ptr_factory_.GetWeakPtr(), |
108 current_path)); | 108 current_path)); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 if (num_pending_reads_ == 0) { | 112 if (num_pending_reads_ == 0) { |
113 // Search is complete. Send the result to the callback. | 113 // Search is complete. Send the result to the callback. |
114 std::sort(results_->begin(), results_->end(), &CompareByTimestamp); | 114 std::sort(results_->begin(), results_->end(), &CompareByTimestamp); |
115 if (results_->size() > static_cast<size_t>(at_most_num_matches_)) { | 115 if (results_->size() > static_cast<size_t>(at_most_num_matches_)) { |
116 // Don't use resize() as it requres a default constructor. | 116 // Don't use resize() as it requires a default constructor. |
117 results_->erase(results_->begin() + at_most_num_matches_, | 117 results_->erase(results_->begin() + at_most_num_matches_, |
118 results_->end()); | 118 results_->end()); |
119 } | 119 } |
120 callback_.Run(DRIVE_FILE_OK, results_.Pass()); | 120 callback_.Run(DRIVE_FILE_OK, results_.Pass()); |
121 delete this; | 121 delete this; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 DriveFileSystemInterface* file_system_; | 125 DriveFileSystemInterface* file_system_; |
126 const std::string query_; | 126 const std::string query_; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (num_matches == 0) | 186 if (num_matches == 0) |
187 return false; | 187 return false; |
188 | 188 |
189 std::string remaining_piece = text.substr(cursor); | 189 std::string remaining_piece = text.substr(cursor); |
190 highlighted_text->append(net::EscapeForHTML(remaining_piece)); | 190 highlighted_text->append(net::EscapeForHTML(remaining_piece)); |
191 | 191 |
192 return true; | 192 return true; |
193 } | 193 } |
194 | 194 |
195 } // namespace drive | 195 } // namespace drive |
OLD | NEW |