| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 10 #include "base/thread_task_runner_handle.h" | |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "storage/browser/fileapi/timed_task_helper.h" | 12 #include "storage/browser/fileapi/timed_task_helper.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 using storage::TimedTaskHelper; | 15 using storage::TimedTaskHelper; |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class Embedder { | 21 class Embedder { |
| 22 public: | 22 public: |
| 23 Embedder() | 23 Embedder() |
| 24 : timer_(base::ThreadTaskRunnerHandle::Get().get()), | 24 : timer_(base::MessageLoopProxy::current().get()), timer_fired_(false) {} |
| 25 timer_fired_(false) {} | |
| 26 | 25 |
| 27 void OnTimerFired() { | 26 void OnTimerFired() { |
| 28 timer_fired_ = true; | 27 timer_fired_ = true; |
| 29 } | 28 } |
| 30 | 29 |
| 31 TimedTaskHelper* timer() { return &timer_; } | 30 TimedTaskHelper* timer() { return &timer_; } |
| 32 bool timer_fired() const { return timer_fired_; } | 31 bool timer_fired() const { return timer_fired_; } |
| 33 | 32 |
| 34 private: | 33 private: |
| 35 TimedTaskHelper timer_; | 34 TimedTaskHelper timer_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 76 |
| 78 ASSERT_TRUE(embedder.timer()->IsRunning()); | 77 ASSERT_TRUE(embedder.timer()->IsRunning()); |
| 79 } | 78 } |
| 80 | 79 |
| 81 // At this point the callback is still in the message queue but | 80 // At this point the callback is still in the message queue but |
| 82 // embedder is gone. | 81 // embedder is gone. |
| 83 base::RunLoop().RunUntilIdle(); | 82 base::RunLoop().RunUntilIdle(); |
| 84 } | 83 } |
| 85 | 84 |
| 86 } // namespace content | 85 } // namespace content |
| OLD | NEW |