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

Unified Diff: remoting/base/scoped_thread_proxy.h

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 | « no previous file | remoting/base/scoped_thread_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/scoped_thread_proxy.h
diff --git a/remoting/base/scoped_thread_proxy.h b/remoting/base/scoped_thread_proxy.h
deleted file mode 100644
index 9e43a15428b1c68ba3ced315bd233e8f233dda49..0000000000000000000000000000000000000000
--- a/remoting/base/scoped_thread_proxy.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef REMOTING_BASE_SCOPED_THREAD_PROXY_H_
-#define REMOTING_BASE_SCOPED_THREAD_PROXY_H_
-
-#include "base/callback_forward.h"
-#include "base/message_loop_proxy.h"
-
-namespace remoting {
-
-// ScopedThreadProxy is proxy for message loops that cancels all
-// pending tasks when it is destroyed. It can be used to post tasks
-// for a non-refcounted object. Must be deleted on the thread it
-// belongs to.
-//
-//
-// The main difference from WeakPtr<> is that this class can be used safely to
-// post tasks from different threads.
-// It is similar to WeakHandle<> used in sync: the main difference is
-// that WeakHandle<> creates closures itself, while ScopedThreadProxy
-// accepts base::Closure instances which caller needs to create using
-// base::Bind().
-//
-// TODO(sergeyu): Potentially we could use WeakHandle<> instead of
-// this class. Consider migrating to WeakHandle<> when it is moved to
-// src/base and support for delayed tasks is implemented.
-//
-// Usage:
-// class MyClass {
-// public:
-// MyClass()
-// : thread_proxy_(base::MessageLoopProxy::current()) {}
-//
-// // Always called on the thread on which this object was created.
-// void NonThreadSafeMethod() {}
-//
-// // Can be called on any thread.
-// void ThreadSafeMethod() {
-// thread_proxy_.PostTask(FROM_HERE, base::Bind(
-// &MyClass::NonThreadSafeMethod, base::Unretained(this)));
-// }
-//
-// private:
-// ScopedThreadProxy thread_proxy_;
-// };
-class ScopedThreadProxy {
- public:
- ScopedThreadProxy(base::MessageLoopProxy* message_loop);
- ~ScopedThreadProxy();
-
- void PostTask(const tracked_objects::Location& from_here,
- const base::Closure& closure);
- void PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& closure,
- int64 delay_ms);
-
- // Cancels all tasks posted via this proxy. Must be called on the
- // thread this object belongs to.
- void Detach();
-
- private:
- class Core;
-
- scoped_refptr<Core> core_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedThreadProxy);
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_SCOPED_THREAD_PROXY_H_
« no previous file with comments | « no previous file | remoting/base/scoped_thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698