Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/history/history.h" | 9 #include "chrome/browser/history/history.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 // Note: WaitableEvent is not used for synchronization between the main thread | 23 // Note: WaitableEvent is not used for synchronization between the main thread |
| 24 // and history backend thread because the history subsystem posts tasks back | 24 // and history backend thread because the history subsystem posts tasks back |
| 25 // to the main thread. Had we tried to Signal an event in such a task | 25 // to the main thread. Had we tried to Signal an event in such a task |
| 26 // and Wait for it on the main thread, the task would not run at all because | 26 // and Wait for it on the main thread, the task would not run at all because |
| 27 // the main thread would be blocked on the Wait call, resulting in a deadlock. | 27 // the main thread would be blocked on the Wait call, resulting in a deadlock. |
| 28 | 28 |
| 29 // A task to be scheduled on the history backend thread. | 29 // A task to be scheduled on the history backend thread. |
| 30 // Notifies the main thread after all history backend thread tasks have run. | 30 // Notifies the main thread after all history backend thread tasks have run. |
| 31 class WaitForHistoryTask : public HistoryDBTask { | 31 class WaitForHistoryTask : public HistoryDBTask { |
| 32 public: | 32 public: |
| 33 WaitForHistoryTask() { | 33 WaitForHistoryTask() {} |
| 34 } | |
| 35 | 34 |
| 36 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 35 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
| 37 history::HistoryDatabase* db) { | 36 history::HistoryDatabase* db) { |
| 38 return true; | 37 return true; |
| 39 } | 38 } |
| 40 | 39 |
| 41 virtual void DoneRunOnMainThread() { | 40 virtual void DoneRunOnMainThread() { |
| 42 MessageLoop::current()->Quit(); | 41 MessageLoop::current()->Quit(); |
| 43 } | 42 } |
| 44 | 43 |
| 45 private: | 44 private: |
| 45 virtual ~WaitForHistoryTask() {} | |
|
sky
2012/04/13 15:50:52
There are subclasses of this class. Won't this nee
Ryan Sleevi
2012/04/13 19:00:25
There are no subclasses. This is just in this unit
| |
| 46 | |
| 46 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask); | 47 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask); |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 // Enumerates all history contents on the backend thread. | 50 // Enumerates all history contents on the backend thread. |
| 50 class HistoryEnumerator : public HistoryService::URLEnumerator { | 51 class HistoryEnumerator : public HistoryService::URLEnumerator { |
| 51 public: | 52 public: |
| 52 explicit HistoryEnumerator(HistoryService* history) { | 53 explicit HistoryEnumerator(HistoryService* history) { |
| 53 EXPECT_TRUE(history); | 54 EXPECT_TRUE(history); |
| 54 if (!history) | 55 if (!history) |
| 55 return; | 56 return; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 WaitForHistoryBackendToRun(); | 205 WaitForHistoryBackendToRun(); |
| 205 | 206 |
| 206 { | 207 { |
| 207 std::vector<GURL> urls(GetHistoryContents()); | 208 std::vector<GURL> urls(GetHistoryContents()); |
| 208 ASSERT_EQ(1U, urls.size()); | 209 ASSERT_EQ(1U, urls.size()); |
| 209 EXPECT_EQ(GetTestUrl().spec(), urls[0].spec()); | 210 EXPECT_EQ(GetTestUrl().spec(), urls[0].spec()); |
| 210 } | 211 } |
| 211 } | 212 } |
| 212 | 213 |
| 213 } // namespace | 214 } // namespace |
| OLD | NEW |