| 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 "remoting/base/scoped_thread_proxy.h" | 5 #include "remoting/base/scoped_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 | 10 |
| 11 class ScopedThreadProxy::Core : public base::RefCountedThreadSafe<Core> { | 11 class ScopedThreadProxy::Core : public base::RefCountedThreadSafe<Core> { |
| 12 public: | 12 public: |
| 13 Core(base::MessageLoopProxy* message_loop) | 13 Core(base::MessageLoopProxy* message_loop) |
| 14 : message_loop_(message_loop), | 14 : message_loop_(message_loop), |
| 15 canceled_(false) { | 15 canceled_(false) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 void PostTask(const tracked_objects::Location& from_here, | 18 void PostTask(const tracked_objects::Location& from_here, |
| 19 const base::Closure& closure) { | 19 const base::Closure& closure) { |
| 20 if (!canceled_) | 20 if (!canceled_) |
| 21 message_loop_->PostTask(from_here, Wrap(closure)); | 21 message_loop_->PostTask(from_here, Wrap(closure)); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void PostDelayedTask( | 24 void PostDelayedTask( |
| 25 const tracked_objects::Location& from_here, | 25 const tracked_objects::Location& from_here, |
| 26 const base::Closure& closure, | 26 const base::Closure& closure, |
| 27 int64 delay_ms) { | 27 base::TimeDelta delay) { |
| 28 if (!canceled_) { | 28 if (!canceled_) { |
| 29 message_loop_->PostDelayedTask(from_here, Wrap(closure), delay_ms); | 29 message_loop_->PostDelayedTask(from_here, Wrap(closure), delay); |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 void Detach() { | 33 void Detach() { |
| 34 DCHECK(message_loop_->BelongsToCurrentThread()); | 34 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 35 canceled_ = true; | 35 canceled_ = true; |
| 36 } | 36 } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 friend class base::RefCountedThreadSafe<Core>; | 39 friend class base::RefCountedThreadSafe<Core>; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ScopedThreadProxy::PostTask(const tracked_objects::Location& from_here, | 70 void ScopedThreadProxy::PostTask(const tracked_objects::Location& from_here, |
| 71 const base::Closure& closure) { | 71 const base::Closure& closure) { |
| 72 core_->PostTask(from_here, closure); | 72 core_->PostTask(from_here, closure); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ScopedThreadProxy::PostDelayedTask( | 75 void ScopedThreadProxy::PostDelayedTask( |
| 76 const tracked_objects::Location& from_here, | 76 const tracked_objects::Location& from_here, |
| 77 const base::Closure& closure, | 77 const base::Closure& closure, |
| 78 int64 delay_ms) { | 78 base::TimeDelta delay) { |
| 79 core_->PostDelayedTask(from_here, closure, delay_ms); | 79 core_->PostDelayedTask(from_here, closure, delay); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void ScopedThreadProxy::Detach() { | 82 void ScopedThreadProxy::Detach() { |
| 83 core_->Detach(); | 83 core_->Detach(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace remoting | 86 } // namespace remoting |
| OLD | NEW |