| 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/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 num_results_ = DoUpdate(); | 58 num_results_ = DoUpdate(); |
| 59 Layout(); | 59 Layout(); |
| 60 if (delegate_) | 60 if (delegate_) |
| 61 delegate_->OnSearchResultContainerResultsChanged(); | 61 delegate_->OnSearchResultContainerResultsChanged(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool SearchResultContainerView::UpdateScheduled() { | 64 bool SearchResultContainerView::UpdateScheduled() { |
| 65 return update_factory_.HasWeakPtrs(); | 65 return update_factory_.HasWeakPtrs(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 const char* SearchResultContainerView::GetClassName() const { |
| 69 return "SearchResultContainerView"; |
| 70 } |
| 71 |
| 68 void SearchResultContainerView::ListItemsAdded(size_t start, size_t count) { | 72 void SearchResultContainerView::ListItemsAdded(size_t start, size_t count) { |
| 69 ScheduleUpdate(); | 73 ScheduleUpdate(); |
| 70 } | 74 } |
| 71 | 75 |
| 72 void SearchResultContainerView::ListItemsRemoved(size_t start, size_t count) { | 76 void SearchResultContainerView::ListItemsRemoved(size_t start, size_t count) { |
| 73 ScheduleUpdate(); | 77 ScheduleUpdate(); |
| 74 } | 78 } |
| 75 | 79 |
| 76 void SearchResultContainerView::ListItemMoved(size_t index, | 80 void SearchResultContainerView::ListItemMoved(size_t index, |
| 77 size_t target_index) { | 81 size_t target_index) { |
| 78 ScheduleUpdate(); | 82 ScheduleUpdate(); |
| 79 } | 83 } |
| 80 | 84 |
| 81 void SearchResultContainerView::ListItemsChanged(size_t start, size_t count) { | 85 void SearchResultContainerView::ListItemsChanged(size_t start, size_t count) { |
| 82 ScheduleUpdate(); | 86 ScheduleUpdate(); |
| 83 } | 87 } |
| 84 | 88 |
| 85 void SearchResultContainerView::ScheduleUpdate() { | 89 void SearchResultContainerView::ScheduleUpdate() { |
| 86 // When search results are added one by one, each addition generates an update | 90 // When search results are added one by one, each addition generates an update |
| 87 // request. Consolidates those update requests into one Update call. | 91 // request. Consolidates those update requests into one Update call. |
| 88 if (!update_factory_.HasWeakPtrs()) { | 92 if (!update_factory_.HasWeakPtrs()) { |
| 89 base::ThreadTaskRunnerHandle::Get()->PostTask( | 93 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 90 FROM_HERE, base::Bind(&SearchResultContainerView::Update, | 94 FROM_HERE, base::Bind(&SearchResultContainerView::Update, |
| 91 update_factory_.GetWeakPtr())); | 95 update_factory_.GetWeakPtr())); |
| 92 } | 96 } |
| 93 } | 97 } |
| 94 | 98 |
| 95 } // namespace app_list | 99 } // namespace app_list |
| OLD | NEW |