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

Side by Side Diff: chrome/browser/history/android/android_history_provider_service.cc

Issue 839193002: Move ServiceAccessType into //components/keyed_service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on android Created 5 years, 11 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
OLDNEW
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/favicon/favicon_service.h" 7 #include "chrome/browser/favicon/favicon_service.h"
8 #include "chrome/browser/favicon/favicon_service_factory.h" 8 #include "chrome/browser/favicon/favicon_service_factory.h"
9 #include "chrome/browser/history/history_backend.h" 9 #include "chrome/browser/history/history_backend.h"
10 #include "chrome/browser/history/history_service.h" 10 #include "chrome/browser/history/history_service.h"
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 base::CancelableTaskTracker::TaskId 23 base::CancelableTaskTracker::TaskId
24 AndroidHistoryProviderService::QueryHistoryAndBookmarks( 24 AndroidHistoryProviderService::QueryHistoryAndBookmarks(
25 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections, 25 const std::vector<history::HistoryAndBookmarkRow::ColumnID>& projections,
26 const std::string& selection, 26 const std::string& selection,
27 const std::vector<base::string16>& selection_args, 27 const std::vector<base::string16>& selection_args,
28 const std::string& sort_order, 28 const std::string& sort_order,
29 const QueryCallback& callback, 29 const QueryCallback& callback,
30 base::CancelableTaskTracker* tracker) { 30 base::CancelableTaskTracker* tracker) {
31 HistoryService* hs = 31 HistoryService* hs = HistoryServiceFactory::GetForProfile(
32 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 32 profile_, ServiceAccessType::EXPLICIT_ACCESS);
33 if (hs) { 33 if (hs) {
34 DCHECK(hs->thread_) << "History service being called after cleanup"; 34 DCHECK(hs->thread_) << "History service being called after cleanup";
35 DCHECK(hs->thread_checker_.CalledOnValidThread()); 35 DCHECK(hs->thread_checker_.CalledOnValidThread());
36 return tracker->PostTaskAndReplyWithResult( 36 return tracker->PostTaskAndReplyWithResult(
37 hs->thread_->message_loop_proxy().get(), 37 hs->thread_->message_loop_proxy().get(),
38 FROM_HERE, 38 FROM_HERE,
39 base::Bind(&HistoryBackend::QueryHistoryAndBookmarks, 39 base::Bind(&HistoryBackend::QueryHistoryAndBookmarks,
40 hs->history_backend_.get(), 40 hs->history_backend_.get(),
41 projections, 41 projections,
42 selection, 42 selection,
43 selection_args, 43 selection_args,
44 sort_order), 44 sort_order),
45 callback); 45 callback);
46 } else { 46 } else {
47 callback.Run(NULL); 47 callback.Run(NULL);
48 return base::CancelableTaskTracker::kBadTaskId; 48 return base::CancelableTaskTracker::kBadTaskId;
49 } 49 }
50 } 50 }
51 51
52 base::CancelableTaskTracker::TaskId 52 base::CancelableTaskTracker::TaskId
53 AndroidHistoryProviderService::UpdateHistoryAndBookmarks( 53 AndroidHistoryProviderService::UpdateHistoryAndBookmarks(
54 const history::HistoryAndBookmarkRow& row, 54 const history::HistoryAndBookmarkRow& row,
55 const std::string& selection, 55 const std::string& selection,
56 const std::vector<base::string16>& selection_args, 56 const std::vector<base::string16>& selection_args,
57 const UpdateCallback& callback, 57 const UpdateCallback& callback,
58 base::CancelableTaskTracker* tracker) { 58 base::CancelableTaskTracker* tracker) {
59 HistoryService* hs = 59 HistoryService* hs = HistoryServiceFactory::GetForProfile(
60 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 60 profile_, ServiceAccessType::EXPLICIT_ACCESS);
61 if (hs) { 61 if (hs) {
62 DCHECK(hs->thread_) << "History service being called after cleanup"; 62 DCHECK(hs->thread_) << "History service being called after cleanup";
63 DCHECK(hs->thread_checker_.CalledOnValidThread()); 63 DCHECK(hs->thread_checker_.CalledOnValidThread());
64 return tracker->PostTaskAndReplyWithResult( 64 return tracker->PostTaskAndReplyWithResult(
65 hs->thread_->message_loop_proxy().get(), 65 hs->thread_->message_loop_proxy().get(),
66 FROM_HERE, 66 FROM_HERE,
67 base::Bind(&HistoryBackend::UpdateHistoryAndBookmarks, 67 base::Bind(&HistoryBackend::UpdateHistoryAndBookmarks,
68 hs->history_backend_.get(), 68 hs->history_backend_.get(),
69 row, 69 row,
70 selection, 70 selection,
71 selection_args), 71 selection_args),
72 callback); 72 callback);
73 } else { 73 } else {
74 callback.Run(0); 74 callback.Run(0);
75 return base::CancelableTaskTracker::kBadTaskId; 75 return base::CancelableTaskTracker::kBadTaskId;
76 } 76 }
77 } 77 }
78 78
79 base::CancelableTaskTracker::TaskId 79 base::CancelableTaskTracker::TaskId
80 AndroidHistoryProviderService::DeleteHistoryAndBookmarks( 80 AndroidHistoryProviderService::DeleteHistoryAndBookmarks(
81 const std::string& selection, 81 const std::string& selection,
82 const std::vector<base::string16>& selection_args, 82 const std::vector<base::string16>& selection_args,
83 const DeleteCallback& callback, 83 const DeleteCallback& callback,
84 base::CancelableTaskTracker* tracker) { 84 base::CancelableTaskTracker* tracker) {
85 HistoryService* hs = 85 HistoryService* hs = HistoryServiceFactory::GetForProfile(
86 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 86 profile_, ServiceAccessType::EXPLICIT_ACCESS);
87 if (hs) { 87 if (hs) {
88 DCHECK(hs->thread_) << "History service being called after cleanup"; 88 DCHECK(hs->thread_) << "History service being called after cleanup";
89 DCHECK(hs->thread_checker_.CalledOnValidThread()); 89 DCHECK(hs->thread_checker_.CalledOnValidThread());
90 return tracker->PostTaskAndReplyWithResult( 90 return tracker->PostTaskAndReplyWithResult(
91 hs->thread_->message_loop_proxy().get(), 91 hs->thread_->message_loop_proxy().get(),
92 FROM_HERE, 92 FROM_HERE,
93 base::Bind(&HistoryBackend::DeleteHistoryAndBookmarks, 93 base::Bind(&HistoryBackend::DeleteHistoryAndBookmarks,
94 hs->history_backend_.get(), 94 hs->history_backend_.get(),
95 selection, 95 selection,
96 selection_args), 96 selection_args),
97 callback); 97 callback);
98 } else { 98 } else {
99 callback.Run(0); 99 callback.Run(0);
100 return base::CancelableTaskTracker::kBadTaskId; 100 return base::CancelableTaskTracker::kBadTaskId;
101 } 101 }
102 } 102 }
103 103
104 base::CancelableTaskTracker::TaskId 104 base::CancelableTaskTracker::TaskId
105 AndroidHistoryProviderService::InsertHistoryAndBookmark( 105 AndroidHistoryProviderService::InsertHistoryAndBookmark(
106 const history::HistoryAndBookmarkRow& values, 106 const history::HistoryAndBookmarkRow& values,
107 const InsertCallback& callback, 107 const InsertCallback& callback,
108 base::CancelableTaskTracker* tracker) { 108 base::CancelableTaskTracker* tracker) {
109 HistoryService* hs = 109 HistoryService* hs = HistoryServiceFactory::GetForProfile(
110 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 110 profile_, ServiceAccessType::EXPLICIT_ACCESS);
111 if (hs) { 111 if (hs) {
112 DCHECK(hs->thread_) << "History service being called after cleanup"; 112 DCHECK(hs->thread_) << "History service being called after cleanup";
113 DCHECK(hs->thread_checker_.CalledOnValidThread()); 113 DCHECK(hs->thread_checker_.CalledOnValidThread());
114 return tracker->PostTaskAndReplyWithResult( 114 return tracker->PostTaskAndReplyWithResult(
115 hs->thread_->message_loop_proxy().get(), 115 hs->thread_->message_loop_proxy().get(),
116 FROM_HERE, 116 FROM_HERE,
117 base::Bind(&HistoryBackend::InsertHistoryAndBookmark, 117 base::Bind(&HistoryBackend::InsertHistoryAndBookmark,
118 hs->history_backend_.get(), 118 hs->history_backend_.get(),
119 values), 119 values),
120 callback); 120 callback);
121 } else { 121 } else {
122 callback.Run(0); 122 callback.Run(0);
123 return base::CancelableTaskTracker::kBadTaskId; 123 return base::CancelableTaskTracker::kBadTaskId;
124 } 124 }
125 } 125 }
126 126
127 base::CancelableTaskTracker::TaskId 127 base::CancelableTaskTracker::TaskId
128 AndroidHistoryProviderService::DeleteHistory( 128 AndroidHistoryProviderService::DeleteHistory(
129 const std::string& selection, 129 const std::string& selection,
130 const std::vector<base::string16>& selection_args, 130 const std::vector<base::string16>& selection_args,
131 const DeleteCallback& callback, 131 const DeleteCallback& callback,
132 base::CancelableTaskTracker* tracker) { 132 base::CancelableTaskTracker* tracker) {
133 HistoryService* hs = 133 HistoryService* hs = HistoryServiceFactory::GetForProfile(
134 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 134 profile_, ServiceAccessType::EXPLICIT_ACCESS);
135 if (hs) { 135 if (hs) {
136 DCHECK(hs->thread_) << "History service being called after cleanup"; 136 DCHECK(hs->thread_) << "History service being called after cleanup";
137 DCHECK(hs->thread_checker_.CalledOnValidThread()); 137 DCHECK(hs->thread_checker_.CalledOnValidThread());
138 return tracker->PostTaskAndReplyWithResult( 138 return tracker->PostTaskAndReplyWithResult(
139 hs->thread_->message_loop_proxy().get(), 139 hs->thread_->message_loop_proxy().get(),
140 FROM_HERE, 140 FROM_HERE,
141 base::Bind(&HistoryBackend::DeleteHistory, 141 base::Bind(&HistoryBackend::DeleteHistory,
142 hs->history_backend_.get(), 142 hs->history_backend_.get(),
143 selection, 143 selection,
144 selection_args), 144 selection_args),
145 callback); 145 callback);
146 } else { 146 } else {
147 callback.Run(0); 147 callback.Run(0);
148 return base::CancelableTaskTracker::kBadTaskId; 148 return base::CancelableTaskTracker::kBadTaskId;
149 } 149 }
150 } 150 }
151 151
152 base::CancelableTaskTracker::TaskId 152 base::CancelableTaskTracker::TaskId
153 AndroidHistoryProviderService::MoveStatement( 153 AndroidHistoryProviderService::MoveStatement(
154 history::AndroidStatement* statement, 154 history::AndroidStatement* statement,
155 int current_pos, 155 int current_pos,
156 int destination, 156 int destination,
157 const MoveStatementCallback& callback, 157 const MoveStatementCallback& callback,
158 base::CancelableTaskTracker* tracker) { 158 base::CancelableTaskTracker* tracker) {
159 HistoryService* hs = 159 HistoryService* hs = HistoryServiceFactory::GetForProfile(
160 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 160 profile_, ServiceAccessType::EXPLICIT_ACCESS);
161 if (hs) { 161 if (hs) {
162 DCHECK(hs->thread_) << "History service being called after cleanup"; 162 DCHECK(hs->thread_) << "History service being called after cleanup";
163 DCHECK(hs->thread_checker_.CalledOnValidThread()); 163 DCHECK(hs->thread_checker_.CalledOnValidThread());
164 return tracker->PostTaskAndReplyWithResult( 164 return tracker->PostTaskAndReplyWithResult(
165 hs->thread_->message_loop_proxy().get(), 165 hs->thread_->message_loop_proxy().get(),
166 FROM_HERE, 166 FROM_HERE,
167 base::Bind(&HistoryBackend::MoveStatement, 167 base::Bind(&HistoryBackend::MoveStatement,
168 hs->history_backend_.get(), 168 hs->history_backend_.get(),
169 statement, 169 statement,
170 current_pos, 170 current_pos,
171 destination), 171 destination),
172 callback); 172 callback);
173 } else { 173 } else {
174 callback.Run(current_pos); 174 callback.Run(current_pos);
175 return base::CancelableTaskTracker::kBadTaskId; 175 return base::CancelableTaskTracker::kBadTaskId;
176 } 176 }
177 } 177 }
178 178
179 void AndroidHistoryProviderService::CloseStatement( 179 void AndroidHistoryProviderService::CloseStatement(
180 history::AndroidStatement* statement) { 180 history::AndroidStatement* statement) {
181 HistoryService* hs = 181 HistoryService* hs = HistoryServiceFactory::GetForProfile(
182 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 182 profile_, ServiceAccessType::EXPLICIT_ACCESS);
183 if (hs) { 183 if (hs) {
184 hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL, 184 hs->ScheduleAndForget(HistoryService::PRIORITY_NORMAL,
185 &HistoryBackend::CloseStatement, statement); 185 &HistoryBackend::CloseStatement, statement);
186 } else { 186 } else {
187 delete statement; 187 delete statement;
188 } 188 }
189 } 189 }
190 190
191 base::CancelableTaskTracker::TaskId 191 base::CancelableTaskTracker::TaskId
192 AndroidHistoryProviderService::InsertSearchTerm( 192 AndroidHistoryProviderService::InsertSearchTerm(
193 const history::SearchRow& row, 193 const history::SearchRow& row,
194 const InsertCallback& callback, 194 const InsertCallback& callback,
195 base::CancelableTaskTracker* tracker) { 195 base::CancelableTaskTracker* tracker) {
196 HistoryService* hs = 196 HistoryService* hs = HistoryServiceFactory::GetForProfile(
197 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 197 profile_, ServiceAccessType::EXPLICIT_ACCESS);
198 if (hs) { 198 if (hs) {
199 DCHECK(hs->thread_) << "History service being called after cleanup"; 199 DCHECK(hs->thread_) << "History service being called after cleanup";
200 DCHECK(hs->thread_checker_.CalledOnValidThread()); 200 DCHECK(hs->thread_checker_.CalledOnValidThread());
201 return tracker->PostTaskAndReplyWithResult( 201 return tracker->PostTaskAndReplyWithResult(
202 hs->thread_->message_loop_proxy().get(), 202 hs->thread_->message_loop_proxy().get(),
203 FROM_HERE, 203 FROM_HERE,
204 base::Bind( 204 base::Bind(
205 &HistoryBackend::InsertSearchTerm, hs->history_backend_.get(), row), 205 &HistoryBackend::InsertSearchTerm, hs->history_backend_.get(), row),
206 callback); 206 callback);
207 } else { 207 } else {
208 callback.Run(0); 208 callback.Run(0);
209 return base::CancelableTaskTracker::kBadTaskId; 209 return base::CancelableTaskTracker::kBadTaskId;
210 } 210 }
211 } 211 }
212 212
213 base::CancelableTaskTracker::TaskId 213 base::CancelableTaskTracker::TaskId
214 AndroidHistoryProviderService::UpdateSearchTerms( 214 AndroidHistoryProviderService::UpdateSearchTerms(
215 const history::SearchRow& row, 215 const history::SearchRow& row,
216 const std::string& selection, 216 const std::string& selection,
217 const std::vector<base::string16>& selection_args, 217 const std::vector<base::string16>& selection_args,
218 const UpdateCallback& callback, 218 const UpdateCallback& callback,
219 base::CancelableTaskTracker* tracker) { 219 base::CancelableTaskTracker* tracker) {
220 HistoryService* hs = 220 HistoryService* hs = HistoryServiceFactory::GetForProfile(
221 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 221 profile_, ServiceAccessType::EXPLICIT_ACCESS);
222 if (hs) { 222 if (hs) {
223 DCHECK(hs->thread_) << "History service being called after cleanup"; 223 DCHECK(hs->thread_) << "History service being called after cleanup";
224 DCHECK(hs->thread_checker_.CalledOnValidThread()); 224 DCHECK(hs->thread_checker_.CalledOnValidThread());
225 return tracker->PostTaskAndReplyWithResult( 225 return tracker->PostTaskAndReplyWithResult(
226 hs->thread_->message_loop_proxy().get(), 226 hs->thread_->message_loop_proxy().get(),
227 FROM_HERE, 227 FROM_HERE,
228 base::Bind(&HistoryBackend::UpdateSearchTerms, 228 base::Bind(&HistoryBackend::UpdateSearchTerms,
229 hs->history_backend_.get(), 229 hs->history_backend_.get(),
230 row, 230 row,
231 selection, 231 selection,
232 selection_args), 232 selection_args),
233 callback); 233 callback);
234 } else { 234 } else {
235 callback.Run(0); 235 callback.Run(0);
236 return base::CancelableTaskTracker::kBadTaskId; 236 return base::CancelableTaskTracker::kBadTaskId;
237 } 237 }
238 } 238 }
239 239
240 base::CancelableTaskTracker::TaskId 240 base::CancelableTaskTracker::TaskId
241 AndroidHistoryProviderService::DeleteSearchTerms( 241 AndroidHistoryProviderService::DeleteSearchTerms(
242 const std::string& selection, 242 const std::string& selection,
243 const std::vector<base::string16>& selection_args, 243 const std::vector<base::string16>& selection_args,
244 const DeleteCallback& callback, 244 const DeleteCallback& callback,
245 base::CancelableTaskTracker* tracker) { 245 base::CancelableTaskTracker* tracker) {
246 HistoryService* hs = 246 HistoryService* hs = HistoryServiceFactory::GetForProfile(
247 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 247 profile_, ServiceAccessType::EXPLICIT_ACCESS);
248 if (hs) { 248 if (hs) {
249 DCHECK(hs->thread_) << "History service being called after cleanup"; 249 DCHECK(hs->thread_) << "History service being called after cleanup";
250 DCHECK(hs->thread_checker_.CalledOnValidThread()); 250 DCHECK(hs->thread_checker_.CalledOnValidThread());
251 return tracker->PostTaskAndReplyWithResult( 251 return tracker->PostTaskAndReplyWithResult(
252 hs->thread_->message_loop_proxy().get(), 252 hs->thread_->message_loop_proxy().get(),
253 FROM_HERE, 253 FROM_HERE,
254 base::Bind(&HistoryBackend::DeleteSearchTerms, 254 base::Bind(&HistoryBackend::DeleteSearchTerms,
255 hs->history_backend_.get(), 255 hs->history_backend_.get(),
256 selection, 256 selection,
257 selection_args), 257 selection_args),
258 callback); 258 callback);
259 } else { 259 } else {
260 callback.Run(0); 260 callback.Run(0);
261 return base::CancelableTaskTracker::kBadTaskId; 261 return base::CancelableTaskTracker::kBadTaskId;
262 } 262 }
263 } 263 }
264 264
265 base::CancelableTaskTracker::TaskId 265 base::CancelableTaskTracker::TaskId
266 AndroidHistoryProviderService::QuerySearchTerms( 266 AndroidHistoryProviderService::QuerySearchTerms(
267 const std::vector<history::SearchRow::ColumnID>& projections, 267 const std::vector<history::SearchRow::ColumnID>& projections,
268 const std::string& selection, 268 const std::string& selection,
269 const std::vector<base::string16>& selection_args, 269 const std::vector<base::string16>& selection_args,
270 const std::string& sort_order, 270 const std::string& sort_order,
271 const QueryCallback& callback, 271 const QueryCallback& callback,
272 base::CancelableTaskTracker* tracker) { 272 base::CancelableTaskTracker* tracker) {
273 HistoryService* hs = 273 HistoryService* hs = HistoryServiceFactory::GetForProfile(
274 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 274 profile_, ServiceAccessType::EXPLICIT_ACCESS);
275 if (hs) { 275 if (hs) {
276 DCHECK(hs->thread_) << "History service being called after cleanup"; 276 DCHECK(hs->thread_) << "History service being called after cleanup";
277 DCHECK(hs->thread_checker_.CalledOnValidThread()); 277 DCHECK(hs->thread_checker_.CalledOnValidThread());
278 return tracker->PostTaskAndReplyWithResult( 278 return tracker->PostTaskAndReplyWithResult(
279 hs->thread_->message_loop_proxy().get(), 279 hs->thread_->message_loop_proxy().get(),
280 FROM_HERE, 280 FROM_HERE,
281 base::Bind(&HistoryBackend::QuerySearchTerms, 281 base::Bind(&HistoryBackend::QuerySearchTerms,
282 hs->history_backend_.get(), 282 hs->history_backend_.get(),
283 projections, 283 projections,
284 selection, 284 selection,
285 selection_args, 285 selection_args,
286 sort_order), 286 sort_order),
287 callback); 287 callback);
288 } else { 288 } else {
289 callback.Run(NULL); 289 callback.Run(NULL);
290 return base::CancelableTaskTracker::kBadTaskId; 290 return base::CancelableTaskTracker::kBadTaskId;
291 } 291 }
292 } 292 }
293 293
294 base::CancelableTaskTracker::TaskId 294 base::CancelableTaskTracker::TaskId
295 AndroidHistoryProviderService::GetLargestRawFaviconForID( 295 AndroidHistoryProviderService::GetLargestRawFaviconForID(
296 favicon_base::FaviconID favicon_id, 296 favicon_base::FaviconID favicon_id,
297 const favicon_base::FaviconRawBitmapCallback& callback, 297 const favicon_base::FaviconRawBitmapCallback& callback,
298 base::CancelableTaskTracker* tracker) { 298 base::CancelableTaskTracker* tracker) {
299 FaviconService* fs = 299 FaviconService* fs = FaviconServiceFactory::GetForProfile(
300 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 300 profile_, ServiceAccessType::EXPLICIT_ACCESS);
301 DCHECK(fs); 301 DCHECK(fs);
302 return fs->GetLargestRawFaviconForID(favicon_id, callback, tracker); 302 return fs->GetLargestRawFaviconForID(favicon_id, callback, tracker);
303 } 303 }
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_tab_helper.cc ('k') | chrome/browser/history/android/sqlite_cursor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698