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/sync/test/integration/typed_urls_helper.h" | 5 #include "chrome/browser/sync/test/integration/typed_urls_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 base::WaitableEvent* wait_event_; | 140 base::WaitableEvent* wait_event_; |
141 }; | 141 }; |
142 | 142 |
143 // Waits for the history DB thread to finish executing its current set of | 143 // Waits for the history DB thread to finish executing its current set of |
144 // tasks. | 144 // tasks. |
145 void WaitForHistoryDBThread(int index) { | 145 void WaitForHistoryDBThread(int index) { |
146 base::CancelableTaskTracker tracker; | 146 base::CancelableTaskTracker tracker; |
147 history::HistoryService* service = | 147 history::HistoryService* service = |
148 HistoryServiceFactory::GetForProfileWithoutCreating( | 148 HistoryServiceFactory::GetForProfileWithoutCreating( |
149 test()->GetProfile(index)); | 149 test()->GetProfile(index)); |
150 base::WaitableEvent wait_event(true, false); | 150 base::WaitableEvent wait_event( |
| 151 base::WaitableEvent::ResetPolicy::MANUAL, |
| 152 base::WaitableEvent::InitialState::NOT_SIGNALED); |
151 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( | 153 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( |
152 new FlushHistoryDBQueueTask(&wait_event)), | 154 new FlushHistoryDBQueueTask(&wait_event)), |
153 &tracker); | 155 &tracker); |
154 wait_event.Wait(); | 156 wait_event.Wait(); |
155 } | 157 } |
156 | 158 |
157 // Creates a URLRow in the specified HistoryService with the passed transition | 159 // Creates a URLRow in the specified HistoryService with the passed transition |
158 // type. | 160 // type. |
159 void AddToHistory(history::HistoryService* service, | 161 void AddToHistory(history::HistoryService* service, |
160 const GURL& url, | 162 const GURL& url, |
161 ui::PageTransition transition, | 163 ui::PageTransition transition, |
162 history::VisitSource source, | 164 history::VisitSource source, |
163 const base::Time& timestamp) { | 165 const base::Time& timestamp) { |
164 service->AddPage(url, | 166 service->AddPage(url, |
165 timestamp, | 167 timestamp, |
166 NULL, // scope | 168 NULL, // scope |
167 1234, // nav_entry_id | 169 1234, // nav_entry_id |
168 GURL(), // referrer | 170 GURL(), // referrer |
169 history::RedirectList(), | 171 history::RedirectList(), |
170 transition, | 172 transition, |
171 source, | 173 source, |
172 false); | 174 false); |
173 } | 175 } |
174 | 176 |
175 history::URLRows GetTypedUrlsFromHistoryService( | 177 history::URLRows GetTypedUrlsFromHistoryService( |
176 history::HistoryService* service) { | 178 history::HistoryService* service) { |
177 base::CancelableTaskTracker tracker; | 179 base::CancelableTaskTracker tracker; |
178 history::URLRows rows; | 180 history::URLRows rows; |
179 base::WaitableEvent wait_event(true, false); | 181 base::WaitableEvent wait_event( |
| 182 base::WaitableEvent::ResetPolicy::MANUAL, |
| 183 base::WaitableEvent::InitialState::NOT_SIGNALED); |
180 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( | 184 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( |
181 new GetTypedUrlsTask(&rows, &wait_event)), | 185 new GetTypedUrlsTask(&rows, &wait_event)), |
182 &tracker); | 186 &tracker); |
183 wait_event.Wait(); | 187 wait_event.Wait(); |
184 return rows; | 188 return rows; |
185 } | 189 } |
186 | 190 |
187 bool GetUrlFromHistoryService(history::HistoryService* service, | 191 bool GetUrlFromHistoryService(history::HistoryService* service, |
188 const GURL& url, | 192 const GURL& url, |
189 history::URLRow* row) { | 193 history::URLRow* row) { |
190 base::CancelableTaskTracker tracker; | 194 base::CancelableTaskTracker tracker; |
191 base::WaitableEvent wait_event(true, false); | 195 base::WaitableEvent wait_event( |
| 196 base::WaitableEvent::ResetPolicy::MANUAL, |
| 197 base::WaitableEvent::InitialState::NOT_SIGNALED); |
192 bool found = false; | 198 bool found = false; |
193 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( | 199 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( |
194 new GetUrlTask(url, row, &found, &wait_event)), | 200 new GetUrlTask(url, row, &found, &wait_event)), |
195 &tracker); | 201 &tracker); |
196 wait_event.Wait(); | 202 wait_event.Wait(); |
197 return found; | 203 return found; |
198 } | 204 } |
199 | 205 |
200 history::VisitVector GetVisitsFromHistoryService( | 206 history::VisitVector GetVisitsFromHistoryService( |
201 history::HistoryService* service, | 207 history::HistoryService* service, |
202 history::URLID id) { | 208 history::URLID id) { |
203 base::CancelableTaskTracker tracker; | 209 base::CancelableTaskTracker tracker; |
204 base::WaitableEvent wait_event(true, false); | 210 base::WaitableEvent wait_event( |
| 211 base::WaitableEvent::ResetPolicy::MANUAL, |
| 212 base::WaitableEvent::InitialState::NOT_SIGNALED); |
205 history::VisitVector visits; | 213 history::VisitVector visits; |
206 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( | 214 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( |
207 new GetVisitsTask(id, &visits, &wait_event)), | 215 new GetVisitsTask(id, &visits, &wait_event)), |
208 &tracker); | 216 &tracker); |
209 wait_event.Wait(); | 217 wait_event.Wait(); |
210 return visits; | 218 return visits; |
211 } | 219 } |
212 | 220 |
213 void RemoveVisitsFromHistoryService(history::HistoryService* service, | 221 void RemoveVisitsFromHistoryService(history::HistoryService* service, |
214 const history::VisitVector& visits) { | 222 const history::VisitVector& visits) { |
215 base::CancelableTaskTracker tracker; | 223 base::CancelableTaskTracker tracker; |
216 base::WaitableEvent wait_event(true, false); | 224 base::WaitableEvent wait_event( |
| 225 base::WaitableEvent::ResetPolicy::MANUAL, |
| 226 base::WaitableEvent::InitialState::NOT_SIGNALED); |
217 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( | 227 service->ScheduleDBTask(std::unique_ptr<history::HistoryDBTask>( |
218 new RemoveVisitsTask(visits, &wait_event)), | 228 new RemoveVisitsTask(visits, &wait_event)), |
219 &tracker); | 229 &tracker); |
220 wait_event.Wait(); | 230 wait_event.Wait(); |
221 } | 231 } |
222 | 232 |
223 static base::Time* timestamp = NULL; | 233 static base::Time* timestamp = NULL; |
224 | 234 |
225 } // namespace | 235 } // namespace |
226 | 236 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 450 |
441 } // namespace | 451 } // namespace |
442 | 452 |
443 bool AwaitCheckAllProfilesHaveSameURLs() { | 453 bool AwaitCheckAllProfilesHaveSameURLs() { |
444 ProfilesHaveSameURLsChecker checker; | 454 ProfilesHaveSameURLsChecker checker; |
445 checker.Wait(); | 455 checker.Wait(); |
446 return !checker.TimedOut(); | 456 return !checker.TimedOut(); |
447 } | 457 } |
448 | 458 |
449 } // namespace typed_urls_helper | 459 } // namespace typed_urls_helper |
OLD | NEW |