| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // Note: WaitableEvent is not used for synchronization between the main thread | 28 // Note: WaitableEvent is not used for synchronization between the main thread |
| 29 // and history backend thread because the history subsystem posts tasks back | 29 // and history backend thread because the history subsystem posts tasks back |
| 30 // to the main thread. Had we tried to Signal an event in such a task | 30 // to the main thread. Had we tried to Signal an event in such a task |
| 31 // and Wait for it on the main thread, the task would not run at all because | 31 // and Wait for it on the main thread, the task would not run at all because |
| 32 // the main thread would be blocked on the Wait call, resulting in a deadlock. | 32 // the main thread would be blocked on the Wait call, resulting in a deadlock. |
| 33 | 33 |
| 34 // A task to be scheduled on the history backend thread. | 34 // A task to be scheduled on the history backend thread. |
| 35 // Notifies the main thread after all history backend thread tasks have run. | 35 // Notifies the main thread after all history backend thread tasks have run. |
| 36 class WaitForHistoryTask : public HistoryDBTask { | 36 class WaitForHistoryTask : public HistoryDBTask { |
| 37 public: | 37 public: |
| 38 WaitForHistoryTask() { | 38 WaitForHistoryTask() {} |
| 39 } | |
| 40 | 39 |
| 41 virtual bool RunOnDBThread(history::HistoryBackend* backend, | 40 virtual bool RunOnDBThread(history::HistoryBackend* backend, |
| 42 history::HistoryDatabase* db) { | 41 history::HistoryDatabase* db) { |
| 43 return true; | 42 return true; |
| 44 } | 43 } |
| 45 | 44 |
| 46 virtual void DoneRunOnMainThread() { | 45 virtual void DoneRunOnMainThread() { |
| 47 MessageLoop::current()->Quit(); | 46 MessageLoop::current()->Quit(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 private: | 49 private: |
| 50 virtual ~WaitForHistoryTask() {} |
| 51 |
| 51 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask); | 52 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask); |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 // Enumerates all history contents on the backend thread. | 55 // Enumerates all history contents on the backend thread. |
| 55 class HistoryEnumerator : public HistoryService::URLEnumerator { | 56 class HistoryEnumerator : public HistoryService::URLEnumerator { |
| 56 public: | 57 public: |
| 57 explicit HistoryEnumerator(HistoryService* history) { | 58 explicit HistoryEnumerator(HistoryService* history) { |
| 58 EXPECT_TRUE(history); | 59 EXPECT_TRUE(history); |
| 59 if (!history) | 60 if (!history) |
| 60 return; | 61 return; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // Mainly, this is to ensure we send a synchronous message to the renderer | 296 // Mainly, this is to ensure we send a synchronous message to the renderer |
| 296 // so that we're not susceptible (less susceptible?) to a race condition. | 297 // so that we're not susceptible (less susceptible?) to a race condition. |
| 297 // Should a race condition ever trigger, it won't result in flakiness. | 298 // Should a race condition ever trigger, it won't result in flakiness. |
| 298 int num = ui_test_utils::FindInPage( | 299 int num = ui_test_utils::FindInPage( |
| 299 browser()->GetSelectedTabContentsWrapper(), ASCIIToUTF16("<img"), true, | 300 browser()->GetSelectedTabContentsWrapper(), ASCIIToUTF16("<img"), true, |
| 300 true, NULL); | 301 true, NULL); |
| 301 EXPECT_GT(num, 0); | 302 EXPECT_GT(num, 0); |
| 302 EXPECT_EQ(ASCIIToUTF16("History"), | 303 EXPECT_EQ(ASCIIToUTF16("History"), |
| 303 browser()->GetSelectedWebContents()->GetTitle()); | 304 browser()->GetSelectedWebContents()->GetTitle()); |
| 304 } | 305 } |
| OLD | NEW |