Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: remoting/base/scoped_thread_proxy.cc

Issue 10440107: Replace ScopedThreadProxy with MessageLoopProxy & WeakPtrs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use correct TaskRunner reference, and copy instance reference in lock. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/base/scoped_thread_proxy.h ('k') | remoting/client/chromoting_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/scoped_thread_proxy.cc
diff --git a/remoting/base/scoped_thread_proxy.cc b/remoting/base/scoped_thread_proxy.cc
deleted file mode 100644
index d1dcc2618b8a41f8ab99970ce699a235e2422da6..0000000000000000000000000000000000000000
--- a/remoting/base/scoped_thread_proxy.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "remoting/base/scoped_thread_proxy.h"
-
-#include "base/bind.h"
-
-namespace remoting {
-
-class ScopedThreadProxy::Core : public base::RefCountedThreadSafe<Core> {
- public:
- Core(base::MessageLoopProxy* message_loop)
- : message_loop_(message_loop),
- canceled_(false) {
- }
-
- void PostTask(const tracked_objects::Location& from_here,
- const base::Closure& closure) {
- if (!canceled_)
- message_loop_->PostTask(from_here, Wrap(closure));
- }
-
- void PostDelayedTask(
- const tracked_objects::Location& from_here,
- const base::Closure& closure,
- int64 delay_ms) {
- if (!canceled_) {
- message_loop_->PostDelayedTask(from_here, Wrap(closure), delay_ms);
- }
- }
-
- void Detach() {
- DCHECK(message_loop_->BelongsToCurrentThread());
- canceled_ = true;
- }
-
- private:
- friend class base::RefCountedThreadSafe<Core>;
-
- ~Core() {
- DCHECK(canceled_);
- }
-
- base::Closure Wrap(const base::Closure& closure) {
- return base::Bind(&Core::CallClosure, this, closure);
- }
-
- void CallClosure(const base::Closure& closure) {
- DCHECK(message_loop_->BelongsToCurrentThread());
-
- if (!canceled_)
- closure.Run();
- }
-
- scoped_refptr<base::MessageLoopProxy> message_loop_;
- bool canceled_;
-
- DISALLOW_COPY_AND_ASSIGN(Core);
-};
-
-ScopedThreadProxy::ScopedThreadProxy(base::MessageLoopProxy* message_loop)
- : core_(new Core(message_loop)) {
-}
-
-ScopedThreadProxy::~ScopedThreadProxy() {
- Detach();
-}
-
-void ScopedThreadProxy::PostTask(const tracked_objects::Location& from_here,
- const base::Closure& closure) {
- core_->PostTask(from_here, closure);
-}
-
-void ScopedThreadProxy::PostDelayedTask(
- const tracked_objects::Location& from_here,
- const base::Closure& closure,
- int64 delay_ms) {
- core_->PostDelayedTask(from_here, closure, delay_ms);
-}
-
-void ScopedThreadProxy::Detach() {
- core_->Detach();
-}
-
-} // namespace remoting
« no previous file with comments | « remoting/base/scoped_thread_proxy.h ('k') | remoting/client/chromoting_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698