| 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 <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 if (error != FILE_ERROR_OK) | 267 if (error != FILE_ERROR_OK) |
| 268 return error; | 268 return error; |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Prepare the result. | 271 // Prepare the result. |
| 272 for (; !result_candidates.empty(); result_candidates.pop()) { | 272 for (; !result_candidates.empty(); result_candidates.pop()) { |
| 273 const ResultCandidate& candidate = *result_candidates.top(); | 273 const ResultCandidate& candidate = *result_candidates.top(); |
| 274 // The path field of entries in result_candidates are empty at this point, | 274 // The path field of entries in result_candidates are empty at this point, |
| 275 // because we don't want to run the expensive metadata DB look up except for | 275 // because we don't want to run the expensive metadata DB look up except for |
| 276 // the final results. Hence, here we fill the part. | 276 // the final results. Hence, here we fill the part. |
| 277 base::FilePath path = resource_metadata->GetFilePath(candidate.local_id); | 277 base::FilePath path; |
| 278 if (path.empty()) | 278 error = resource_metadata->GetFilePath(candidate.local_id, &path); |
| 279 return FILE_ERROR_FAILED; | 279 if (error != FILE_ERROR_OK) |
| 280 return error; |
| 280 bool is_directory = candidate.entry.file_info().is_directory(); | 281 bool is_directory = candidate.entry.file_info().is_directory(); |
| 281 results->push_back(MetadataSearchResult( | 282 results->push_back(MetadataSearchResult( |
| 282 path, is_directory, candidate.highlighted_base_name)); | 283 path, is_directory, candidate.highlighted_base_name)); |
| 283 } | 284 } |
| 284 | 285 |
| 285 // Reverse the order here because |result_candidates| puts the most | 286 // Reverse the order here because |result_candidates| puts the most |
| 286 // uninteresting candidate at the top. | 287 // uninteresting candidate at the top. |
| 287 std::reverse(results->begin(), results->end()); | 288 std::reverse(results->begin(), results->end()); |
| 288 | 289 |
| 289 return FILE_ERROR_OK; | 290 return FILE_ERROR_OK; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); | 355 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); |
| 355 highlighted_text->append("<b>"); | 356 highlighted_text->append("<b>"); |
| 356 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); | 357 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); |
| 357 highlighted_text->append("</b>"); | 358 highlighted_text->append("</b>"); |
| 358 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); | 359 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); |
| 359 return true; | 360 return true; |
| 360 } | 361 } |
| 361 | 362 |
| 362 } // namespace internal | 363 } // namespace internal |
| 363 } // namespace drive | 364 } // namespace drive |
| OLD | NEW |