| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 bool empty() const { return queue_.empty(); } | 72 bool empty() const { return queue_.empty(); } |
| 73 | 73 |
| 74 size_t size() const { return queue_.size(); } | 74 size_t size() const { return queue_.size(); } |
| 75 | 75 |
| 76 const T* top() const { return queue_.top(); } | 76 const T* top() const { return queue_.top(); } |
| 77 | 77 |
| 78 void push(T* x) { queue_.push(x); } | 78 void push(T* x) { queue_.push(x); } |
| 79 | 79 |
| 80 void pop() { | 80 void pop() { |
| 81 delete queue_.top(); | 81 // Keep top alive for the pop() call so that debug checks can access |
| 82 // underlying data (e.g. validating heap property of the priority queue |
| 83 // will call the comparator). |
| 84 T* saved_top = queue_.top(); |
| 82 queue_.pop(); | 85 queue_.pop(); |
| 86 delete saved_top; |
| 83 } | 87 } |
| 84 | 88 |
| 85 private: | 89 private: |
| 86 std::priority_queue<T*, std::vector<T*>, Compare> queue_; | 90 std::priority_queue<T*, std::vector<T*>, Compare> queue_; |
| 87 | 91 |
| 88 DISALLOW_COPY_AND_ASSIGN(ScopedPriorityQueue); | 92 DISALLOW_COPY_AND_ASSIGN(ScopedPriorityQueue); |
| 89 }; | 93 }; |
| 90 | 94 |
| 91 // Returns true if |entry| is eligible for the search |options| and should be | 95 // Returns true if |entry| is eligible for the search |options| and should be |
| 92 // tested for the match with the query. If | 96 // tested for the match with the query. If |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); | 275 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); |
| 272 highlighted_text->append("<b>"); | 276 highlighted_text->append("<b>"); |
| 273 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); | 277 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); |
| 274 highlighted_text->append("</b>"); | 278 highlighted_text->append("</b>"); |
| 275 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); | 279 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); |
| 276 return true; | 280 return true; |
| 277 } | 281 } |
| 278 | 282 |
| 279 } // namespace internal | 283 } // namespace internal |
| 280 } // namespace drive | 284 } // namespace drive |
| OLD | NEW |