| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/history/android/android_history_provider_service.h" | 5 #include "chrome/browser/history/android/android_history_provider_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/history/history_backend.h" | 7 #include "chrome/browser/history/history_backend.h" |
| 8 #include "chrome/browser/history/history_service.h" | 8 #include "chrome/browser/history/history_service.h" |
| 9 #include "chrome/browser/history/history_service_factory.h" | 9 #include "chrome/browser/history/history_service_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 if (hs) { | 119 if (hs) { |
| 120 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 120 hs->Schedule(HistoryService::PRIORITY_NORMAL, |
| 121 &HistoryBackend::DeleteHistory, NULL, request, selection, | 121 &HistoryBackend::DeleteHistory, NULL, request, selection, |
| 122 selection_args); | 122 selection_args); |
| 123 } else { | 123 } else { |
| 124 request->ForwardResultAsync(request->handle(), false, 0); | 124 request->ForwardResultAsync(request->handle(), false, 0); |
| 125 } | 125 } |
| 126 return request->handle(); | 126 return request->handle(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 AndroidHistoryProviderService::Handle | 129 base::CancelableTaskTracker::TaskId |
| 130 AndroidHistoryProviderService::MoveStatement( | 130 AndroidHistoryProviderService::MoveStatement( |
| 131 history::AndroidStatement* statement, | 131 history::AndroidStatement* statement, |
| 132 int current_pos, | 132 int current_pos, |
| 133 int destination, | 133 int destination, |
| 134 CancelableRequestConsumerBase* consumer, | 134 const MoveStatementCallback& callback, |
| 135 const MoveStatementCallback& callback) { | 135 base::CancelableTaskTracker* tracker) { |
| 136 MoveStatementRequest* request = new MoveStatementRequest(callback); | |
| 137 AddRequest(request, consumer); | |
| 138 HistoryService* hs = | 136 HistoryService* hs = |
| 139 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 137 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 140 if (hs) { | 138 if (hs) { |
| 141 hs->Schedule(HistoryService::PRIORITY_NORMAL, | 139 DCHECK(hs->thread_) << "History service being called after cleanup"; |
| 142 &HistoryBackend::MoveStatement, NULL, request, statement, | 140 DCHECK(hs->thread_checker_.CalledOnValidThread()); |
| 143 current_pos, destination); | 141 return tracker->PostTaskAndReplyWithResult( |
| 142 hs->thread_->message_loop_proxy().get(), |
| 143 FROM_HERE, |
| 144 base::Bind(&HistoryBackend::MoveStatement, |
| 145 hs->history_backend_.get(), |
| 146 statement, |
| 147 current_pos, |
| 148 destination), |
| 149 callback); |
| 144 } else { | 150 } else { |
| 145 request->ForwardResultAsync(request->handle(), current_pos); | 151 callback.Run(current_pos); |
| 152 return base::CancelableTaskTracker::kBadTaskId; |
| 146 } | 153 } |
| 147 return request->handle(); | |
| 148 } | 154 } |
| 149 | 155 |
| 150 void AndroidHistoryProviderService::CloseStatement( | 156 void AndroidHistoryProviderService::CloseStatement( |
| 151 history::AndroidStatement* statement) { | 157 history::AndroidStatement* statement) { |
| 152 HistoryService* hs = | 158 HistoryService* hs = |
| 153 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 159 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 154 if (hs) { | 160 if (hs) { |
| 155 hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL, | 161 hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL, |
| 156 &HistoryBackend::CloseStatement, statement); | 162 &HistoryBackend::CloseStatement, statement); |
| 157 } else { | 163 } else { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 projections, | 245 projections, |
| 240 selection, | 246 selection, |
| 241 selection_args, | 247 selection_args, |
| 242 sort_order), | 248 sort_order), |
| 243 callback); | 249 callback); |
| 244 } else { | 250 } else { |
| 245 callback.Run(NULL); | 251 callback.Run(NULL); |
| 246 return base::CancelableTaskTracker::kBadTaskId; | 252 return base::CancelableTaskTracker::kBadTaskId; |
| 247 } | 253 } |
| 248 } | 254 } |
| OLD | NEW |