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

Unified Diff: ui/base/clipboard/clipboard_gtk.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
Index: ui/base/clipboard/clipboard_gtk.cc
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc
index a63bb8eef7eee0284ba085f74614d0a4cc033bdd..a3df8efad27ce20c6f18b4a84479069a7bbe850e 100644
--- a/ui/base/clipboard/clipboard_gtk.cc
+++ b/ui/base/clipboard/clipboard_gtk.cc
@@ -210,15 +210,18 @@ bool Clipboard::FormatType::Equals(const FormatType& other) const {
}
Clipboard::Clipboard() : clipboard_data_(NULL) {
+ DCHECK(CalledOnValidThread());
clipboard_ = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
primary_selection_ = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
}
Clipboard::~Clipboard() {
+ DCHECK(CalledOnValidThread());
gtk_clipboard_store(clipboard_);
}
void Clipboard::WriteObjects(const ObjectMap& objects) {
+ DCHECK(CalledOnValidThread());
clipboard_data_ = new TargetMap();
for (ObjectMap::const_iterator iter = objects.begin();
@@ -233,6 +236,7 @@ void Clipboard::WriteObjects(const ObjectMap& objects) {
// location", for example), we additionally stick it in the X clipboard. This
// matches other linux browsers.
void Clipboard::DidWriteURL(const std::string& utf8_text) {
+ DCHECK(CalledOnValidThread());
gtk_clipboard_set_text(primary_selection_, utf8_text.c_str(),
utf8_text.length());
}
@@ -347,6 +351,7 @@ void Clipboard::WriteData(const FormatType& format,
// and does not always refresh the cache when it is appropriate.
bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format,
Clipboard::Buffer buffer) const {
+ DCHECK(CalledOnValidThread());
GtkClipboard* clipboard = LookupBackingClipboard(buffer);
if (clipboard == NULL)
return false;
@@ -396,6 +401,7 @@ bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format,
void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer,
std::vector<string16>* types,
bool* contains_filenames) const {
+ DCHECK(CalledOnValidThread());
if (!types || !contains_filenames) {
NOTREACHED();
return;
@@ -426,6 +432,7 @@ void Clipboard::ReadAvailableTypes(Clipboard::Buffer buffer,
void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const {
+ DCHECK(CalledOnValidThread());
GtkClipboard* clipboard = LookupBackingClipboard(buffer);
if (clipboard == NULL)
return;
@@ -443,6 +450,7 @@ void Clipboard::ReadText(Clipboard::Buffer buffer, string16* result) const {
void Clipboard::ReadAsciiText(Clipboard::Buffer buffer,
std::string* result) const {
+ DCHECK(CalledOnValidThread());
GtkClipboard* clipboard = LookupBackingClipboard(buffer);
if (clipboard == NULL)
return;
@@ -458,6 +466,7 @@ void Clipboard::ReadAsciiText(Clipboard::Buffer buffer,
}
void Clipboard::ReadFile(FilePath* file) const {
+ DCHECK(CalledOnValidThread());
*file = FilePath();
}
@@ -466,6 +475,7 @@ void Clipboard::ReadFile(FilePath* file) const {
void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup,
std::string* src_url, uint32* fragment_start,
uint32* fragment_end) const {
+ DCHECK(CalledOnValidThread());
markup->clear();
if (src_url)
src_url->clear();
@@ -506,6 +516,7 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup,
}
SkBitmap Clipboard::ReadImage(Buffer buffer) const {
+ DCHECK(CalledOnValidThread());
ScopedGObject<GdkPixbuf>::Type pixbuf(
gtk_clipboard_wait_for_image(clipboard_));
if (!pixbuf.get())
@@ -526,6 +537,7 @@ SkBitmap Clipboard::ReadImage(Buffer buffer) const {
void Clipboard::ReadCustomData(Buffer buffer,
const string16& type,
string16* result) const {
+ DCHECK(CalledOnValidThread());
GtkClipboard* clipboard = LookupBackingClipboard(buffer);
if (!clipboard)
return;
@@ -546,6 +558,7 @@ void Clipboard::ReadBookmark(string16* title, std::string* url) const {
}
void Clipboard::ReadData(const FormatType& format, std::string* result) const {
+ DCHECK(CalledOnValidThread());
GtkSelectionData* data =
gtk_clipboard_wait_for_contents(clipboard_, format.ToGdkAtom());
if (!data)
@@ -557,6 +570,7 @@ void Clipboard::ReadData(const FormatType& format, std::string* result) const {
}
uint64 Clipboard::GetSequenceNumber(Buffer buffer) {
+ DCHECK(CalledOnValidThread());
if (buffer == BUFFER_STANDARD)
return SelectionChangeObserver::GetInstance()->clipboard_sequence_number();
else

Powered by Google App Engine
This is Rietveld 408576698