| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/test/test_clipboard.h" | 5 #include "ui/base/test/test_clipboard.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 | 10 |
| 11 namespace ui { | 11 namespace ui { |
| 12 | 12 |
| 13 TestClipboard::TestClipboard() | 13 TestClipboard::TestClipboard() |
| 14 : default_store_type_(CLIPBOARD_TYPE_COPY_PASTE) { | 14 : default_store_type_(CLIPBOARD_TYPE_COPY_PASTE) { |
| 15 } | 15 } |
| 16 | 16 |
| 17 TestClipboard::~TestClipboard() { | 17 TestClipboard::~TestClipboard() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 Clipboard* TestClipboard::CreateForCurrentThread() { | 20 void TestClipboard::UseForCurrentThread() { |
| 21 base::AutoLock lock(Clipboard::clipboard_map_lock_.Get()); | 21 base::AutoLock lock(Clipboard::clipboard_map_lock_.Get()); |
| 22 Clipboard* clipboard = new TestClipboard; | |
| 23 Clipboard::clipboard_map_.Get()[base::PlatformThread::CurrentId()] = | 22 Clipboard::clipboard_map_.Get()[base::PlatformThread::CurrentId()] = |
| 24 clipboard; | 23 new TestClipboard; |
| 25 return clipboard; | |
| 26 } | 24 } |
| 27 | 25 |
| 28 uint64 TestClipboard::GetSequenceNumber(ClipboardType type) const { | 26 uint64 TestClipboard::GetSequenceNumber(ClipboardType type) const { |
| 29 return GetStore(type).sequence_number; | 27 return GetStore(type).sequence_number; |
| 30 } | 28 } |
| 31 | 29 |
| 32 bool TestClipboard::IsFormatAvailable(const FormatType& format, | 30 bool TestClipboard::IsFormatAvailable(const FormatType& format, |
| 33 ClipboardType type) const { | 31 ClipboardType type) const { |
| 34 const DataStore& store = GetStore(type); | 32 const DataStore& store = GetStore(type); |
| 35 return store.data.find(format) != store.data.end(); | 33 return store.data.find(format) != store.data.end(); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 192 |
| 195 const TestClipboard::DataStore& TestClipboard::GetDefaultStore() const { | 193 const TestClipboard::DataStore& TestClipboard::GetDefaultStore() const { |
| 196 return GetStore(default_store_type_); | 194 return GetStore(default_store_type_); |
| 197 } | 195 } |
| 198 | 196 |
| 199 TestClipboard::DataStore& TestClipboard::GetDefaultStore() { | 197 TestClipboard::DataStore& TestClipboard::GetDefaultStore() { |
| 200 return GetStore(default_store_type_); | 198 return GetStore(default_store_type_); |
| 201 } | 199 } |
| 202 | 200 |
| 203 } // namespace ui | 201 } // namespace ui |
| OLD | NEW |