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

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

Issue 8606002: Remove Task inheritance in clipboard code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback from jam 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
diff --git a/content/browser/renderer_host/clipboard_message_filter.cc b/content/browser/renderer_host/clipboard_message_filter.cc
index 30250fcb7a402fc7a1167925c461b96c528fec7d..cd4b6dfbd145f2af4852f45668e97f82189abcc8 100644
--- a/content/browser/renderer_host/clipboard_message_filter.cc
+++ b/content/browser/renderer_host/clipboard_message_filter.cc
@@ -11,6 +11,7 @@
#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"
@@ -24,24 +25,12 @@ using content::BrowserThread;
namespace {
-// 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_;
-};
+// 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);
+}
} // namespace
@@ -104,7 +93,7 @@ void ClipboardMessageFilter::OnWriteObjectsSync(
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- new WriteClipboardTask(long_living_objects));
+ base::Bind(&WriteObjectsHelper, base::Owned(long_living_objects)));
}
void ClipboardMessageFilter::OnWriteObjectsAsync(
@@ -122,7 +111,7 @@ void ClipboardMessageFilter::OnWriteObjectsAsync(
BrowserThread::PostTask(
BrowserThread::UI,
FROM_HERE,
- new WriteClipboardTask(long_living_objects));
+ base::Bind(&WriteObjectsHelper, base::Owned(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