| 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/memory/ptr_util.h" | |
| 9 #include "base/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 11 | 10 |
| 12 namespace ui { | 11 namespace ui { |
| 13 | 12 |
| 14 TestClipboard::TestClipboard() | 13 TestClipboard::TestClipboard() |
| 15 : default_store_type_(CLIPBOARD_TYPE_COPY_PASTE) { | 14 : default_store_type_(CLIPBOARD_TYPE_COPY_PASTE) { |
| 16 } | 15 } |
| 17 | 16 |
| 18 TestClipboard::~TestClipboard() { | 17 TestClipboard::~TestClipboard() { |
| 19 } | 18 } |
| 20 | 19 |
| 21 Clipboard* TestClipboard::CreateForCurrentThread() { | 20 Clipboard* TestClipboard::CreateForCurrentThread() { |
| 22 base::AutoLock lock(Clipboard::clipboard_map_lock_.Get()); | 21 base::AutoLock lock(Clipboard::clipboard_map_lock_.Get()); |
| 23 Clipboard* clipboard = new TestClipboard; | 22 Clipboard* clipboard = new TestClipboard; |
| 24 Clipboard::clipboard_map_.Get()[base::PlatformThread::CurrentId()] = | 23 Clipboard::clipboard_map_.Get()[base::PlatformThread::CurrentId()] = |
| 25 base::WrapUnique(clipboard); | 24 clipboard; |
| 26 return clipboard; | 25 return clipboard; |
| 27 } | 26 } |
| 28 | 27 |
| 29 uint64_t TestClipboard::GetSequenceNumber(ClipboardType type) const { | 28 uint64_t TestClipboard::GetSequenceNumber(ClipboardType type) const { |
| 30 return GetStore(type).sequence_number; | 29 return GetStore(type).sequence_number; |
| 31 } | 30 } |
| 32 | 31 |
| 33 bool TestClipboard::IsFormatAvailable(const FormatType& format, | 32 bool TestClipboard::IsFormatAvailable(const FormatType& format, |
| 34 ClipboardType type) const { | 33 ClipboardType type) const { |
| 35 const DataStore& store = GetStore(type); | 34 const DataStore& store = GetStore(type); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 209 |
| 211 const TestClipboard::DataStore& TestClipboard::GetDefaultStore() const { | 210 const TestClipboard::DataStore& TestClipboard::GetDefaultStore() const { |
| 212 return GetStore(default_store_type_); | 211 return GetStore(default_store_type_); |
| 213 } | 212 } |
| 214 | 213 |
| 215 TestClipboard::DataStore& TestClipboard::GetDefaultStore() { | 214 TestClipboard::DataStore& TestClipboard::GetDefaultStore() { |
| 216 return GetStore(default_store_type_); | 215 return GetStore(default_store_type_); |
| 217 } | 216 } |
| 218 | 217 |
| 219 } // namespace ui | 218 } // namespace ui |
| OLD | NEW |