| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 "ui/app_list/views/search_result_container_view.h" | 5 #include "ui/app_list/views/search_result_container_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 | 9 |
| 10 namespace app_list { | 10 namespace app_list { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // When search results are added one by one, each addition generates an update | 54 // When search results are added one by one, each addition generates an update |
| 55 // request. Consolidates those update requests into one Update call. | 55 // request. Consolidates those update requests into one Update call. |
| 56 if (!update_factory_.HasWeakPtrs()) { | 56 if (!update_factory_.HasWeakPtrs()) { |
| 57 base::MessageLoop::current()->PostTask( | 57 base::MessageLoop::current()->PostTask( |
| 58 FROM_HERE, | 58 FROM_HERE, |
| 59 base::Bind(&SearchResultContainerView::DoUpdate, | 59 base::Bind(&SearchResultContainerView::DoUpdate, |
| 60 update_factory_.GetWeakPtr())); | 60 update_factory_.GetWeakPtr())); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool SearchResultContainerView::UpdateScheduled() { |
| 65 return update_factory_.HasWeakPtrs(); |
| 66 } |
| 67 |
| 64 void SearchResultContainerView::ListItemsAdded(size_t start, size_t count) { | 68 void SearchResultContainerView::ListItemsAdded(size_t start, size_t count) { |
| 65 ScheduleUpdate(); | 69 ScheduleUpdate(); |
| 66 } | 70 } |
| 67 | 71 |
| 68 void SearchResultContainerView::ListItemsRemoved(size_t start, size_t count) { | 72 void SearchResultContainerView::ListItemsRemoved(size_t start, size_t count) { |
| 69 ScheduleUpdate(); | 73 ScheduleUpdate(); |
| 70 } | 74 } |
| 71 | 75 |
| 72 void SearchResultContainerView::ListItemMoved(size_t index, | 76 void SearchResultContainerView::ListItemMoved(size_t index, |
| 73 size_t target_index) { | 77 size_t target_index) { |
| 74 ScheduleUpdate(); | 78 ScheduleUpdate(); |
| 75 } | 79 } |
| 76 | 80 |
| 77 void SearchResultContainerView::ListItemsChanged(size_t start, size_t count) { | 81 void SearchResultContainerView::ListItemsChanged(size_t start, size_t count) { |
| 78 ScheduleUpdate(); | 82 ScheduleUpdate(); |
| 79 } | 83 } |
| 80 | 84 |
| 81 void SearchResultContainerView::DoUpdate() { | 85 void SearchResultContainerView::DoUpdate() { |
| 86 update_factory_.InvalidateWeakPtrs(); |
| 82 num_results_ = Update(); | 87 num_results_ = Update(); |
| 83 Layout(); | 88 Layout(); |
| 84 PreferredSizeChanged(); | 89 PreferredSizeChanged(); |
| 85 update_factory_.InvalidateWeakPtrs(); | |
| 86 } | 90 } |
| 87 | 91 |
| 88 } // namespace app_list | 92 } // namespace app_list |
| OLD | NEW |