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

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

Issue 9419036: Change all platforms except Windows to access the clipboard solely from the UI thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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 | ui/base/clipboard/clipboard.h » ('j') | ui/base/clipboard/clipboard.h » ('J')
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 1825b344dfbbb4e7178507c7c1722cd481f0e8e2..f96151f5f282b28aa38851343b5131354d9323e2 100644
--- a/content/browser/renderer_host/clipboard_message_filter.cc
+++ b/content/browser/renderer_host/clipboard_message_filter.cc
@@ -39,12 +39,23 @@ ClipboardMessageFilter::ClipboardMessageFilter() {
void ClipboardMessageFilter::OverrideThreadForMessage(
const IPC::Message& message, BrowserThread::ID* thread) {
+ // Clipboard writes should always occur on the UI thread due the restrictions
+ // of various platform APIs. In general, the clipboard is not
+ // thread-safe, so all clipboard calls should be serviced from the UI thread.
+ //
+ // Windows needs clipboard reads to be serviced from the IO thread because
+ // these are sync IPCs which can result in deadlocks with NPAPI plugins if
+ // serviced from the UI thread. Note that Windows clipboard calls ARE
+ // thread-safe so it is ok for reads and writes to be serviced from different
+ // threads.
+#if !defined(OS_WIN)
+ if (IPC_MESSAGE_CLASS(message) == ClipboardMsgStart)
+ *thread = BrowserThread::UI;
dcheng 2012/02/17 19:43:22 Doesn't this change result in us posting a task fr
raymes 2012/02/17 23:14:03 Sounds good, I was considering this but wasn't sur
+#endif
+
#if defined(OS_WIN)
if (message.type() == ClipboardHostMsg_ReadImage::ID)
*thread = BrowserThread::FILE;
-#elif defined(USE_X11)
- if (IPC_MESSAGE_CLASS(message) == ClipboardMsgStart)
- *thread = BrowserThread::UI;
#endif
}
« no previous file with comments | « no previous file | ui/base/clipboard/clipboard.h » ('j') | ui/base/clipboard/clipboard.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698