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

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

Issue 720373003: Add FakeClipboard implementation for unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WINDOWS!!! Created 6 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 | « ui/base/BUILD.gn ('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 66a5dcbf426b10be1fb7ea5e3758d9342b6fd235..ab3d34b3ceff6d8b7939b451e0026b597343f6f3 100644
--- a/ui/base/clipboard/clipboard.h
+++ b/ui/base/clipboard/clipboard.h
@@ -10,9 +10,11 @@
#include <vector>
#include "base/compiler_specific.h"
+#include "base/lazy_instance.h"
#include "base/memory/shared_memory.h"
#include "base/process/process.h"
#include "base/strings/string16.h"
+#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_checker.h"
#include "ui/base/clipboard/clipboard_types.h"
@@ -50,6 +52,7 @@ class NSString;
namespace ui {
template <typename T>
class ClipboardTest;
+class TestClipboard;
class ScopedClipboardWriter;
class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
@@ -71,10 +74,8 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
std::string Serialize() const;
static FormatType Deserialize(const std::string& serialization);
-#if !defined(OS_ANDROID)
// FormatType can be used in a set on some platforms.
bool operator<(const FormatType& other) const;
-#endif
#if defined(OS_WIN)
const FORMATETC& ToFormatEtc() const { return data_; }
@@ -195,7 +196,7 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
// Returns a sequence number which uniquely identifies clipboard state.
// This can be used to version the data on the clipboard and determine
// whether it has changed.
- virtual uint64 GetSequenceNumber(ClipboardType type) = 0;
+ virtual uint64 GetSequenceNumber(ClipboardType type) const = 0;
// Tests whether the clipboard contains a certain format
virtual bool IsFormatAvailable(const FormatType& format,
@@ -325,6 +326,20 @@ class UI_BASE_EXPORT Clipboard : NON_EXPORTED_BASE(public base::ThreadChecker) {
// TODO(dcheng): Remove the temporary exception for content.
friend class content::ClipboardMessageFilter;
friend class ScopedClipboardWriter;
+ friend class TestClipboard;
+
+ // A list of allowed threads. By default, this is empty and no thread checking
+ // is done (in the unit test case), but a user (like content) can set which
+ // threads are allowed to call this method.
+ typedef std::vector<base::PlatformThreadId> AllowedThreadsVector;
+ static base::LazyInstance<AllowedThreadsVector> allowed_threads_;
+
+ // Mapping from threads to clipboard objects.
+ typedef std::map<base::PlatformThreadId, Clipboard*> ClipboardMap;
+ static base::LazyInstance<ClipboardMap> clipboard_map_;
+
+ // Mutex that controls access to |g_clipboard_map|.
+ static base::LazyInstance<base::Lock>::Leaky clipboard_map_lock_;
DISALLOW_COPY_AND_ASSIGN(Clipboard);
};
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/clipboard/clipboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698