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

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

Issue 2047703003: Revert of Implement ui::ClipboardMus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « ui/base/clipboard/clipboard.h ('k') | ui/base/clipboard/clipboard_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/clipboard/clipboard.cc
diff --git a/ui/base/clipboard/clipboard.cc b/ui/base/clipboard/clipboard.cc
index f8125f32cce99e69a5ed52dcd736221a4232812e..d43954bbc31d39fc7db5bcbc7fe645ae34599f8e 100644
--- a/ui/base/clipboard/clipboard.cc
+++ b/ui/base/clipboard/clipboard.cc
@@ -9,7 +9,6 @@
#include <memory>
#include "base/logging.h"
-#include "base/memory/ptr_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/size.h"
@@ -33,32 +32,32 @@
}
// static
-void Clipboard::SetClipboardForCurrentThread(
- std::unique_ptr<Clipboard> platform_clipboard) {
- base::AutoLock lock(clipboard_map_lock_.Get());
- base::PlatformThreadId id = Clipboard::GetAndValidateThreadID();
-
- ClipboardMap* clipboard_map = clipboard_map_.Pointer();
- ClipboardMap::const_iterator it = clipboard_map->find(id);
- if (it != clipboard_map->end()) {
- // This shouldn't happen. The clipboard should not already exist.
- NOTREACHED();
- }
- clipboard_map->insert(std::make_pair(id, std::move(platform_clipboard)));
-}
-
-// static
Clipboard* Clipboard::GetForCurrentThread() {
base::AutoLock lock(clipboard_map_lock_.Get());
- base::PlatformThreadId id = GetAndValidateThreadID();
+
+ base::PlatformThreadId id = base::PlatformThread::CurrentId();
+
+ AllowedThreadsVector* allowed_threads = allowed_threads_.Pointer();
+ if (!allowed_threads->empty()) {
+ bool found = false;
+ for (AllowedThreadsVector::const_iterator it = allowed_threads->begin();
+ it != allowed_threads->end(); ++it) {
+ if (*it == id) {
+ found = true;
+ break;
+ }
+ }
+
+ DCHECK(found);
+ }
ClipboardMap* clipboard_map = clipboard_map_.Pointer();
ClipboardMap::const_iterator it = clipboard_map->find(id);
if (it != clipboard_map->end())
- return it->second.get();
+ return it->second;
Clipboard* clipboard = Clipboard::Create();
- clipboard_map->insert(std::make_pair(id, base::WrapUnique(clipboard)));
+ clipboard_map->insert(std::make_pair(id, clipboard));
return clipboard;
}
@@ -68,8 +67,10 @@
ClipboardMap* clipboard_map = clipboard_map_.Pointer();
base::PlatformThreadId id = base::PlatformThread::CurrentId();
ClipboardMap::iterator it = clipboard_map->find(id);
- if (it != clipboard_map->end())
+ if (it != clipboard_map->end()) {
+ delete it->second;
clipboard_map->erase(it);
+ }
}
void Clipboard::DispatchObject(ObjectType type, const ObjectMapParams& params) {
@@ -131,25 +132,4 @@
}
}
-base::PlatformThreadId Clipboard::GetAndValidateThreadID() {
- base::PlatformThreadId id = base::PlatformThread::CurrentId();
-#ifndef NDEBUG
- AllowedThreadsVector* allowed_threads = allowed_threads_.Pointer();
- if (!allowed_threads->empty()) {
- bool found = false;
- for (AllowedThreadsVector::const_iterator it = allowed_threads->begin();
- it != allowed_threads->end(); ++it) {
- if (*it == id) {
- found = true;
- break;
- }
- }
-
- DCHECK(found);
- }
-#endif
-
- return id;
-}
-
} // namespace ui
« no previous file with comments | « ui/base/clipboard/clipboard.h ('k') | ui/base/clipboard/clipboard_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698