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

Unified Diff: remoting/base/task_thread_proxy.h

Issue 7355011: Modify Chromoting logging to hook into base logging. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years, 5 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/logger.cc ('k') | remoting/base/task_thread_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/task_thread_proxy.h
diff --git a/remoting/base/task_thread_proxy.h b/remoting/base/task_thread_proxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..67ccc2db2368597d311ef2ec2012c6617f537022
--- /dev/null
+++ b/remoting/base/task_thread_proxy.h
@@ -0,0 +1,50 @@
+// 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.
+
+#ifndef REMOTING_BASE_TASK_THREAD_PROXY_H_
+#define REMOTING_BASE_TASK_THREAD_PROXY_H_
+
+#include "base/message_loop.h"
+
+namespace remoting {
+
+// This is a refcounted class that is used to switch to the appropriate thread
+// before running a task on a target object. It should be used whenever you
+// need to post to an object, but:
+// (1) You don't know when the object might be deleted, and
+// (2) You cannot subclass the target from RefCountedThreadSafe.
+//
+// Example usage:
+// Instead of:
+// MyClass* obj;
+// obj->Method(param);
+// Use:
+// proxy->Call(base::Bind(&MyClass::Method,
+// base::Unretained(obj),
+// param);
+class TaskThreadProxy : public base::RefCountedThreadSafe<TaskThreadProxy> {
+ public:
+ TaskThreadProxy(MessageLoop* loop);
+
+ // Detach should be called when the target of the posted task is being
+ // destroyed.
+ void Detach();
+
+ void Call(const base::Closure& closure);
+
+ private:
+ friend class base::RefCountedThreadSafe<TaskThreadProxy>;
+
+ virtual ~TaskThreadProxy();
+
+ void CallClosure(const base::Closure& closure);
+
+ MessageLoop* message_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(TaskThreadProxy);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_BASE_TASK_THREAD_PROXY_H_
« no previous file with comments | « remoting/base/logger.cc ('k') | remoting/base/task_thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698