| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/string_piece.h" | 7 #include "base/string_piece.h" |
| 8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class TestTypedUrlModelAssociator : public TypedUrlModelAssociator { | 68 class TestTypedUrlModelAssociator : public TypedUrlModelAssociator { |
| 69 public: | 69 public: |
| 70 TestTypedUrlModelAssociator(base::WaitableEvent* startup, | 70 TestTypedUrlModelAssociator(base::WaitableEvent* startup, |
| 71 base::WaitableEvent* aborted) | 71 base::WaitableEvent* aborted) |
| 72 : TypedUrlModelAssociator(&mock_, NULL, NULL), | 72 : TypedUrlModelAssociator(&mock_, NULL, NULL), |
| 73 startup_(startup), | 73 startup_(startup), |
| 74 aborted_(aborted) {} | 74 aborted_(aborted) {} |
| 75 virtual bool IsAbortPending() { | 75 virtual bool IsAbortPending() OVERRIDE { |
| 76 // Let the main thread know that we've been started up, and block until | 76 // Let the main thread know that we've been started up, and block until |
| 77 // they've called Abort(). | 77 // they've called Abort(). |
| 78 startup_->Signal(); | 78 startup_->Signal(); |
| 79 EXPECT_TRUE(aborted_->TimedWait(TestTimeouts::action_timeout())); | 79 EXPECT_TRUE(aborted_->TimedWait(TestTimeouts::action_timeout())); |
| 80 return TypedUrlModelAssociator::IsAbortPending(); | 80 return TypedUrlModelAssociator::IsAbortPending(); |
| 81 } | 81 } |
| 82 private: | 82 private: |
| 83 ProfileSyncServiceMock mock_; | 83 ProfileSyncServiceMock mock_; |
| 84 base::WaitableEvent* startup_; | 84 base::WaitableEvent* startup_; |
| 85 base::WaitableEvent* aborted_; | 85 base::WaitableEvent* aborted_; |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, callback); | 437 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, callback); |
| 438 // Wait for the model associator to get created and start assocation. | 438 // Wait for the model associator to get created and start assocation. |
| 439 ASSERT_TRUE(startup.TimedWait(TestTimeouts::action_timeout())); | 439 ASSERT_TRUE(startup.TimedWait(TestTimeouts::action_timeout())); |
| 440 // Abort the model assocation - this should be callable from any thread. | 440 // Abort the model assocation - this should be callable from any thread. |
| 441 associator->AbortAssociation(); | 441 associator->AbortAssociation(); |
| 442 // Tell the remote thread to continue. | 442 // Tell the remote thread to continue. |
| 443 aborted.Signal(); | 443 aborted.Signal(); |
| 444 // Block until CreateModelAssociator() exits. | 444 // Block until CreateModelAssociator() exits. |
| 445 ASSERT_TRUE(done.TimedWait(TestTimeouts::action_timeout())); | 445 ASSERT_TRUE(done.TimedWait(TestTimeouts::action_timeout())); |
| 446 } | 446 } |
| OLD | NEW |