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 "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/task/cancelable_task_tracker.h" | 10 #include "base/task/cancelable_task_tracker.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 using sync_datatype_helper::test; | 22 using sync_datatype_helper::test; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 class FlushHistoryDBQueueTask : public history::HistoryDBTask { | 26 class FlushHistoryDBQueueTask : public history::HistoryDBTask { |
27 public: | 27 public: |
28 explicit FlushHistoryDBQueueTask(base::WaitableEvent* event) | 28 explicit FlushHistoryDBQueueTask(base::WaitableEvent* event) |
29 : wait_event_(event) {} | 29 : wait_event_(event) {} |
30 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 30 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
31 history::HistoryDatabase* db) OVERRIDE { | 31 history::HistoryDatabase* db) override { |
32 wait_event_->Signal(); | 32 wait_event_->Signal(); |
33 return true; | 33 return true; |
34 } | 34 } |
35 | 35 |
36 virtual void DoneRunOnMainThread() OVERRIDE {} | 36 virtual void DoneRunOnMainThread() override {} |
37 | 37 |
38 private: | 38 private: |
39 virtual ~FlushHistoryDBQueueTask() {} | 39 virtual ~FlushHistoryDBQueueTask() {} |
40 | 40 |
41 base::WaitableEvent* wait_event_; | 41 base::WaitableEvent* wait_event_; |
42 }; | 42 }; |
43 | 43 |
44 class GetTypedUrlsTask : public history::HistoryDBTask { | 44 class GetTypedUrlsTask : public history::HistoryDBTask { |
45 public: | 45 public: |
46 GetTypedUrlsTask(history::URLRows* rows, base::WaitableEvent* event) | 46 GetTypedUrlsTask(history::URLRows* rows, base::WaitableEvent* event) |
47 : rows_(rows), wait_event_(event) {} | 47 : rows_(rows), wait_event_(event) {} |
48 | 48 |
49 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 49 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
50 history::HistoryDatabase* db) OVERRIDE { | 50 history::HistoryDatabase* db) override { |
51 // Fetch the typed URLs. | 51 // Fetch the typed URLs. |
52 backend->GetAllTypedURLs(rows_); | 52 backend->GetAllTypedURLs(rows_); |
53 wait_event_->Signal(); | 53 wait_event_->Signal(); |
54 return true; | 54 return true; |
55 } | 55 } |
56 | 56 |
57 virtual void DoneRunOnMainThread() OVERRIDE {} | 57 virtual void DoneRunOnMainThread() override {} |
58 | 58 |
59 private: | 59 private: |
60 virtual ~GetTypedUrlsTask() {} | 60 virtual ~GetTypedUrlsTask() {} |
61 | 61 |
62 history::URLRows* rows_; | 62 history::URLRows* rows_; |
63 base::WaitableEvent* wait_event_; | 63 base::WaitableEvent* wait_event_; |
64 }; | 64 }; |
65 | 65 |
66 class GetUrlTask : public history::HistoryDBTask { | 66 class GetUrlTask : public history::HistoryDBTask { |
67 public: | 67 public: |
68 GetUrlTask(const GURL& url, | 68 GetUrlTask(const GURL& url, |
69 history::URLRow* row, | 69 history::URLRow* row, |
70 bool* found, | 70 bool* found, |
71 base::WaitableEvent* event) | 71 base::WaitableEvent* event) |
72 : url_(url), row_(row), wait_event_(event), found_(found) {} | 72 : url_(url), row_(row), wait_event_(event), found_(found) {} |
73 | 73 |
74 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 74 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
75 history::HistoryDatabase* db) OVERRIDE { | 75 history::HistoryDatabase* db) override { |
76 // Fetch the typed URLs. | 76 // Fetch the typed URLs. |
77 *found_ = backend->GetURL(url_, row_); | 77 *found_ = backend->GetURL(url_, row_); |
78 wait_event_->Signal(); | 78 wait_event_->Signal(); |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
82 virtual void DoneRunOnMainThread() OVERRIDE {} | 82 virtual void DoneRunOnMainThread() override {} |
83 | 83 |
84 private: | 84 private: |
85 virtual ~GetUrlTask() {} | 85 virtual ~GetUrlTask() {} |
86 | 86 |
87 GURL url_; | 87 GURL url_; |
88 history::URLRow* row_; | 88 history::URLRow* row_; |
89 base::WaitableEvent* wait_event_; | 89 base::WaitableEvent* wait_event_; |
90 bool* found_; | 90 bool* found_; |
91 }; | 91 }; |
92 | 92 |
93 class GetVisitsTask : public history::HistoryDBTask { | 93 class GetVisitsTask : public history::HistoryDBTask { |
94 public: | 94 public: |
95 GetVisitsTask(history::URLID id, | 95 GetVisitsTask(history::URLID id, |
96 history::VisitVector* visits, | 96 history::VisitVector* visits, |
97 base::WaitableEvent* event) | 97 base::WaitableEvent* event) |
98 : id_(id), visits_(visits), wait_event_(event) {} | 98 : id_(id), visits_(visits), wait_event_(event) {} |
99 | 99 |
100 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 100 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
101 history::HistoryDatabase* db) OVERRIDE { | 101 history::HistoryDatabase* db) override { |
102 // Fetch the visits. | 102 // Fetch the visits. |
103 backend->GetVisitsForURL(id_, visits_); | 103 backend->GetVisitsForURL(id_, visits_); |
104 wait_event_->Signal(); | 104 wait_event_->Signal(); |
105 return true; | 105 return true; |
106 } | 106 } |
107 | 107 |
108 virtual void DoneRunOnMainThread() OVERRIDE {} | 108 virtual void DoneRunOnMainThread() override {} |
109 | 109 |
110 private: | 110 private: |
111 virtual ~GetVisitsTask() {} | 111 virtual ~GetVisitsTask() {} |
112 | 112 |
113 history::URLID id_; | 113 history::URLID id_; |
114 history::VisitVector* visits_; | 114 history::VisitVector* visits_; |
115 base::WaitableEvent* wait_event_; | 115 base::WaitableEvent* wait_event_; |
116 }; | 116 }; |
117 | 117 |
118 class RemoveVisitsTask : public history::HistoryDBTask { | 118 class RemoveVisitsTask : public history::HistoryDBTask { |
119 public: | 119 public: |
120 RemoveVisitsTask(const history::VisitVector& visits, | 120 RemoveVisitsTask(const history::VisitVector& visits, |
121 base::WaitableEvent* event) | 121 base::WaitableEvent* event) |
122 : visits_(visits), wait_event_(event) {} | 122 : visits_(visits), wait_event_(event) {} |
123 | 123 |
124 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 124 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
125 history::HistoryDatabase* db) OVERRIDE { | 125 history::HistoryDatabase* db) override { |
126 // Fetch the visits. | 126 // Fetch the visits. |
127 backend->RemoveVisits(visits_); | 127 backend->RemoveVisits(visits_); |
128 wait_event_->Signal(); | 128 wait_event_->Signal(); |
129 return true; | 129 return true; |
130 } | 130 } |
131 | 131 |
132 virtual void DoneRunOnMainThread() OVERRIDE {} | 132 virtual void DoneRunOnMainThread() override {} |
133 | 133 |
134 private: | 134 private: |
135 virtual ~RemoveVisitsTask() {} | 135 virtual ~RemoveVisitsTask() {} |
136 | 136 |
137 const history::VisitVector& visits_; | 137 const history::VisitVector& visits_; |
138 base::WaitableEvent* wait_event_; | 138 base::WaitableEvent* wait_event_; |
139 }; | 139 }; |
140 | 140 |
141 // Waits for the history DB thread to finish executing its current set of | 141 // Waits for the history DB thread to finish executing its current set of |
142 // tasks. | 142 // tasks. |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 390 |
391 namespace { | 391 namespace { |
392 | 392 |
393 // Helper class used in the implementation of | 393 // Helper class used in the implementation of |
394 // AwaitCheckAllProfilesHaveSameURLsAsVerifier. | 394 // AwaitCheckAllProfilesHaveSameURLsAsVerifier. |
395 class ProfilesHaveSameURLsChecker : public MultiClientStatusChangeChecker { | 395 class ProfilesHaveSameURLsChecker : public MultiClientStatusChangeChecker { |
396 public: | 396 public: |
397 ProfilesHaveSameURLsChecker(); | 397 ProfilesHaveSameURLsChecker(); |
398 virtual ~ProfilesHaveSameURLsChecker(); | 398 virtual ~ProfilesHaveSameURLsChecker(); |
399 | 399 |
400 virtual bool IsExitConditionSatisfied() OVERRIDE; | 400 virtual bool IsExitConditionSatisfied() override; |
401 virtual std::string GetDebugMessage() const OVERRIDE; | 401 virtual std::string GetDebugMessage() const override; |
402 }; | 402 }; |
403 | 403 |
404 ProfilesHaveSameURLsChecker::ProfilesHaveSameURLsChecker() | 404 ProfilesHaveSameURLsChecker::ProfilesHaveSameURLsChecker() |
405 : MultiClientStatusChangeChecker( | 405 : MultiClientStatusChangeChecker( |
406 sync_datatype_helper::test()->GetSyncServices()) {} | 406 sync_datatype_helper::test()->GetSyncServices()) {} |
407 | 407 |
408 ProfilesHaveSameURLsChecker::~ProfilesHaveSameURLsChecker() {} | 408 ProfilesHaveSameURLsChecker::~ProfilesHaveSameURLsChecker() {} |
409 | 409 |
410 bool ProfilesHaveSameURLsChecker::IsExitConditionSatisfied() { | 410 bool ProfilesHaveSameURLsChecker::IsExitConditionSatisfied() { |
411 return CheckAllProfilesHaveSameURLsAsVerifier(); | 411 return CheckAllProfilesHaveSameURLsAsVerifier(); |
412 } | 412 } |
413 | 413 |
414 std::string ProfilesHaveSameURLsChecker::GetDebugMessage() const { | 414 std::string ProfilesHaveSameURLsChecker::GetDebugMessage() const { |
415 return "Waiting for matching typed urls profiles"; | 415 return "Waiting for matching typed urls profiles"; |
416 } | 416 } |
417 | 417 |
418 } // namespace | 418 } // namespace |
419 | 419 |
420 bool AwaitCheckAllProfilesHaveSameURLsAsVerifier() { | 420 bool AwaitCheckAllProfilesHaveSameURLsAsVerifier() { |
421 ProfilesHaveSameURLsChecker checker; | 421 ProfilesHaveSameURLsChecker checker; |
422 checker.Wait(); | 422 checker.Wait(); |
423 return !checker.TimedOut(); | 423 return !checker.TimedOut(); |
424 } | 424 } |
425 | 425 |
426 } // namespace typed_urls_helper | 426 } // namespace typed_urls_helper |
OLD | NEW |