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

Unified Diff: ui/base/clipboard/clipboard.h

Issue 10916214: Try 2 - Change how ui::Clipboard is accessed so there's only one per thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved to BrowserThreadsStarted Created 8 years, 3 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 | « content/shell/shell_aura.cc ('k') | ui/base/clipboard/clipboard.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/clipboard.h
diff --git a/ui/base/clipboard/clipboard.h b/ui/base/clipboard/clipboard.h
index b98cfc4748953f32ad60eb5c45be673cd1afc771..18463da7472806a860d8faf7b3abc229c4933416 100644
--- a/ui/base/clipboard/clipboard.h
+++ b/ui/base/clipboard/clipboard.h
@@ -15,6 +15,7 @@
#include "base/shared_memory.h"
#include "base/string16.h"
#include "base/threading/thread_checker.h"
+#include "base/threading/platform_thread.h"
#include "ui/base/ui_export.h"
#if defined(TOOLKIT_GTK)
@@ -46,6 +47,7 @@ class NSString;
#endif
namespace ui {
+class ClipboardTest;
class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
public:
@@ -182,8 +184,22 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
return static_cast<Buffer>(buffer);
}
- Clipboard();
- ~Clipboard();
+ // Sets the list of threads that are allowed to access the clipboard.
+ static void SetAllowedThreads(
+ const std::vector<base::PlatformThreadId>& allowed_threads);
+
+ // Returns the clipboard object for the current thread.
+ //
+ // Most implementations will have at most one clipboard which will live on
+ // the main UI thread, but Windows has tricky semantics where there have to
+ // be two clipboards: one that lives on the UI thread and one that lives on
+ // the IO thread.
+ static Clipboard* GetForCurrentThread();
+
+ // Destroys the clipboard for the current thread. Usually, this will clean up
+ // all clipboards, except on Windows. (Previous code leaks the IO thread
+ // clipboard, so it shouldn't be a problem.)
+ static void DestroyClipboardForCurrentThread();
// Write a bunch of objects to the system clipboard. Copies are made of the
// contents of |objects|. On Windows they are copied to the system clipboard.
@@ -284,6 +300,10 @@ class UI_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
private:
FRIEND_TEST_ALL_PREFIXES(ClipboardTest, SharedBitmapTest);
FRIEND_TEST_ALL_PREFIXES(ClipboardTest, EmptyHTMLTest);
+ friend class ClipboardTest;
+
+ Clipboard();
+ ~Clipboard();
void DispatchObject(ObjectType type, const ObjectMapParams& params);
« no previous file with comments | « content/shell/shell_aura.cc ('k') | ui/base/clipboard/clipboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698