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

Unified Diff: chrome/browser/chrome_thread_relay.h

Issue 2878062: Asynchronously open the temp file used for Pepper StreamToFile, and delete th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | « base/scoped_callback_factory.h ('k') | chrome/browser/chrome_thread_relay.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_thread_relay.h
===================================================================
--- chrome/browser/chrome_thread_relay.h (revision 0)
+++ chrome/browser/chrome_thread_relay.h (revision 0)
@@ -0,0 +1,55 @@
+// Copyright (c) 2010 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.
+
+// ChromeThreadRelay provides a convenient way to bounce work to a specific
+// ChromeThread and then return results back to the originating thread.
+//
+// EXAMPLE:
+//
+// class MyRelay : public ChromeThreadRelay {
+// public:
+// MyRelay(const Params& params) : params_(params) {
+// }
+// protected:
+// virtual void RunWork() {
+// results_ = DoWork(params_);
+// }
+// virtual void RunCallback() {
+// ... use results_ on the originating thread ...
+// }
+// private:
+// Params params_;
+// Results_ results_;
+// };
+
+#ifndef CHROME_BROWSER_CHROME_THREAD_RELAY_H_
+#define CHROME_BROWSER_CHROME_THREAD_RELAY_H_
+
+#include "base/ref_counted.h"
+#include "chrome/browser/chrome_thread.h"
+
+class ChromeThreadRelay
+ : public base::RefCountedThreadSafe<ChromeThreadRelay> {
+ public:
+ ChromeThreadRelay();
+
+ void Start(ChromeThread::ID target_thread_id,
+ const tracked_objects::Location& from_here);
+
+ protected:
+ friend class base::RefCountedThreadSafe<ChromeThreadRelay>;
+ virtual ~ChromeThreadRelay() {}
+
+ // Called to perform work on the FILE thread.
+ virtual void RunWork() = 0;
+
+ // Called to notify the callback on the origin thread.
+ virtual void RunCallback() = 0;
+
+ private:
+ void ProcessOnTargetThread();
+ ChromeThread::ID origin_thread_id_;
+};
+
+#endif // CHROME_BROWSER_CHROME_THREAD_RELAY_H_
Property changes on: chrome\browser\chrome_thread_relay.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « base/scoped_callback_factory.h ('k') | chrome/browser/chrome_thread_relay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698