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 // Classifies the given entry as trashed if it's placed under the trash. | 95 // Classifies the given entry as trashed if it's placed under the trash. |
92 class TrashedEntryClassifier { | 96 class TrashedEntryClassifier { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); | 334 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); |
331 highlighted_text->append("<b>"); | 335 highlighted_text->append("<b>"); |
332 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); | 336 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); |
333 highlighted_text->append("</b>"); | 337 highlighted_text->append("</b>"); |
334 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); | 338 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); |
335 return true; | 339 return true; |
336 } | 340 } |
337 | 341 |
338 } // namespace internal | 342 } // namespace internal |
339 } // namespace drive | 343 } // namespace drive |
OLD | NEW |