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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/eintr_wrapper.h" | 10 #include "base/eintr_wrapper.h" |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 RecordDeletionProbe(RecordDeletionProbe* post_on_delete, bool* was_deleted) | 421 RecordDeletionProbe(RecordDeletionProbe* post_on_delete, bool* was_deleted) |
422 : post_on_delete_(post_on_delete), was_deleted_(was_deleted) { | 422 : post_on_delete_(post_on_delete), was_deleted_(was_deleted) { |
423 } | 423 } |
424 ~RecordDeletionProbe() { | 424 ~RecordDeletionProbe() { |
425 *was_deleted_ = true; | 425 *was_deleted_ = true; |
426 if (post_on_delete_) | 426 if (post_on_delete_) |
427 MessageLoop::current()->PostTask( | 427 MessageLoop::current()->PostTask( |
428 FROM_HERE, | 428 FROM_HERE, |
429 base::Bind(&RecordDeletionProbe::Run, post_on_delete_.get())); | 429 base::Bind(&RecordDeletionProbe::Run, post_on_delete_.get())); |
430 } | 430 } |
431 virtual void Run() {} | 431 void Run() {} |
432 private: | 432 private: |
433 scoped_refptr<RecordDeletionProbe> post_on_delete_; | 433 scoped_refptr<RecordDeletionProbe> post_on_delete_; |
434 bool* was_deleted_; | 434 bool* was_deleted_; |
435 }; | 435 }; |
436 | 436 |
437 void RunTest_EnsureDeletion(MessageLoop::Type message_loop_type) { | 437 void RunTest_EnsureDeletion(MessageLoop::Type message_loop_type) { |
438 bool a_was_deleted = false; | 438 bool a_was_deleted = false; |
439 bool b_was_deleted = false; | 439 bool b_was_deleted = false; |
440 { | 440 { |
441 MessageLoop loop(message_loop_type); | 441 MessageLoop loop(message_loop_type); |
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 base::Bind(&DestructionObserverProbe::Run, | 1691 base::Bind(&DestructionObserverProbe::Run, |
1692 new DestructionObserverProbe(&task_destroyed, | 1692 new DestructionObserverProbe(&task_destroyed, |
1693 &destruction_observer_called)), | 1693 &destruction_observer_called)), |
1694 kDelayMS); | 1694 kDelayMS); |
1695 delete loop; | 1695 delete loop; |
1696 EXPECT_TRUE(observer.task_destroyed_before_message_loop()); | 1696 EXPECT_TRUE(observer.task_destroyed_before_message_loop()); |
1697 // The task should have been destroyed when we deleted the loop. | 1697 // The task should have been destroyed when we deleted the loop. |
1698 EXPECT_TRUE(task_destroyed); | 1698 EXPECT_TRUE(task_destroyed); |
1699 EXPECT_TRUE(destruction_observer_called); | 1699 EXPECT_TRUE(destruction_observer_called); |
1700 } | 1700 } |
OLD | NEW |