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