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

Unified Diff: content/browser/renderer_host/clipboard_message_filter.cc

Issue 8634002: Revert 111080 - Remove Task inheritance in clipboard code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 | content/browser/renderer_host/clipboard_message_filter_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/clipboard_message_filter.cc
===================================================================
--- content/browser/renderer_host/clipboard_message_filter.cc (revision 111082)
+++ content/browser/renderer_host/clipboard_message_filter.cc (working copy)
@@ -11,7 +11,6 @@
#endif
#include "base/bind.h"
-#include "base/bind_helpers.h"
#include "base/stl_util.h"
#include "content/common/clipboard_messages.h"
#include "content/public/browser/content_browser_client.h"
@@ -25,13 +24,25 @@
namespace {
-// This helper is needed because content::ContentBrowserClient::GetClipboard()
-// must be called on the UI thread.
-void WriteObjectsHelper(const ui::Clipboard::ObjectMap* objects) {
- content::GetContentClient()->browser()->GetClipboard()->WriteObjects(
- *objects);
-}
+// Completes a clipboard write initiated by the renderer. The write must be
+// performed on the UI thread because the clipboard service from the IO thread
+// cannot create windows so it cannot be the "owner" of the clipboard's
+// contents.
+class WriteClipboardTask : public Task {
+ public:
+ explicit WriteClipboardTask(ui::Clipboard::ObjectMap* objects)
+ : objects_(objects) {}
+ ~WriteClipboardTask() {}
+ void Run() {
+ content::GetContentClient()->browser()->GetClipboard()->WriteObjects(
+ *objects_.get());
+ }
+
+ private:
+ scoped_ptr<ui::Clipboard::ObjectMap> objects_;
+};
+
} // namespace
ClipboardMessageFilter::ClipboardMessageFilter() {
@@ -93,7 +104,7 @@
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects)));
+ new WriteClipboardTask(long_living_objects));
}
void ClipboardMessageFilter::OnWriteObjectsAsync(
@@ -111,7 +122,7 @@
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects)));
+ new WriteClipboardTask(long_living_objects));
}
void ClipboardMessageFilter::OnGetSequenceNumber(
« no previous file with comments | « no previous file | content/browser/renderer_host/clipboard_message_filter_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698