Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: ui/app_list/views/search_result_container_view.cc

Issue 2049493004: Remove use of deprecated MessageLoop methods in ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/aura/gestures/gesture_recognizer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h"
9 11
10 namespace app_list { 12 namespace app_list {
11 13
12 SearchResultContainerView::SearchResultContainerView() 14 SearchResultContainerView::SearchResultContainerView()
13 : delegate_(nullptr), 15 : delegate_(nullptr),
14 selected_index_(-1), 16 selected_index_(-1),
15 num_results_(0), 17 num_results_(0),
16 results_(NULL), 18 results_(NULL),
17 update_factory_(this) { 19 update_factory_(this) {
18 } 20 }
(...skipping 29 matching lines...) Expand all
48 } 50 }
49 51
50 bool SearchResultContainerView::IsValidSelectionIndex(int index) const { 52 bool SearchResultContainerView::IsValidSelectionIndex(int index) const {
51 return index >= 0 && index <= num_results() - 1; 53 return index >= 0 && index <= num_results() - 1;
52 } 54 }
53 55
54 void SearchResultContainerView::ScheduleUpdate() { 56 void SearchResultContainerView::ScheduleUpdate() {
55 // When search results are added one by one, each addition generates an update 57 // When search results are added one by one, each addition generates an update
56 // request. Consolidates those update requests into one Update call. 58 // request. Consolidates those update requests into one Update call.
57 if (!update_factory_.HasWeakPtrs()) { 59 if (!update_factory_.HasWeakPtrs()) {
58 base::MessageLoop::current()->PostTask( 60 base::ThreadTaskRunnerHandle::Get()->PostTask(
59 FROM_HERE, 61 FROM_HERE, base::Bind(&SearchResultContainerView::DoUpdate,
60 base::Bind(&SearchResultContainerView::DoUpdate, 62 update_factory_.GetWeakPtr()));
61 update_factory_.GetWeakPtr()));
62 } 63 }
63 } 64 }
64 65
65 bool SearchResultContainerView::UpdateScheduled() { 66 bool SearchResultContainerView::UpdateScheduled() {
66 return update_factory_.HasWeakPtrs(); 67 return update_factory_.HasWeakPtrs();
67 } 68 }
68 69
69 void SearchResultContainerView::ListItemsAdded(size_t start, size_t count) { 70 void SearchResultContainerView::ListItemsAdded(size_t start, size_t count) {
70 ScheduleUpdate(); 71 ScheduleUpdate();
71 } 72 }
(...skipping 13 matching lines...) Expand all
85 86
86 void SearchResultContainerView::DoUpdate() { 87 void SearchResultContainerView::DoUpdate() {
87 update_factory_.InvalidateWeakPtrs(); 88 update_factory_.InvalidateWeakPtrs();
88 num_results_ = Update(); 89 num_results_ = Update();
89 Layout(); 90 Layout();
90 if (delegate_) 91 if (delegate_)
91 delegate_->OnSearchResultContainerResultsChanged(); 92 delegate_->OnSearchResultContainerResultsChanged();
92 } 93 }
93 94
94 } // namespace app_list 95 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | ui/aura/gestures/gesture_recognizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698