OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/clipboard/clipboard.h" | 5 #include "ui/base/clipboard/clipboard.h" |
6 | 6 |
7 #include <algorithm> | |
8 #include <iterator> | 7 #include <iterator> |
9 #include <limits> | 8 #include <limits> |
10 #include <memory> | 9 #include <memory> |
11 | 10 |
12 #include "base/debug/dump_without_crashing.h" | 11 #include "base/debug/dump_without_crashing.h" |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/stl_util.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
16 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
19 | 19 |
20 base::LazyInstance<Clipboard::AllowedThreadsVector>::DestructorAtExit | 20 base::LazyInstance<Clipboard::AllowedThreadsVector>::DestructorAtExit |
21 Clipboard::allowed_threads_ = LAZY_INSTANCE_INITIALIZER; | 21 Clipboard::allowed_threads_ = LAZY_INSTANCE_INITIALIZER; |
22 base::LazyInstance<Clipboard::ClipboardMap>::DestructorAtExit | 22 base::LazyInstance<Clipboard::ClipboardMap>::DestructorAtExit |
23 Clipboard::clipboard_map_ = LAZY_INSTANCE_INITIALIZER; | 23 Clipboard::clipboard_map_ = LAZY_INSTANCE_INITIALIZER; |
24 base::LazyInstance<base::Lock>::Leaky Clipboard::clipboard_map_lock_ = | 24 base::LazyInstance<base::Lock>::Leaky Clipboard::clipboard_map_lock_ = |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 base::PlatformThreadId Clipboard::GetAndValidateThreadID() { | 154 base::PlatformThreadId Clipboard::GetAndValidateThreadID() { |
155 clipboard_map_lock_.Get().AssertAcquired(); | 155 clipboard_map_lock_.Get().AssertAcquired(); |
156 | 156 |
157 const base::PlatformThreadId id = base::PlatformThread::CurrentId(); | 157 const base::PlatformThreadId id = base::PlatformThread::CurrentId(); |
158 | 158 |
159 // TODO(fdoray): Surround this block with #if DCHECK_IS_ON() and remove the | 159 // TODO(fdoray): Surround this block with #if DCHECK_IS_ON() and remove the |
160 // DumpWithoutCrashing() call once https://crbug.com/662055 is resolved. | 160 // DumpWithoutCrashing() call once https://crbug.com/662055 is resolved. |
161 AllowedThreadsVector* allowed_threads = allowed_threads_.Pointer(); | 161 AllowedThreadsVector* allowed_threads = allowed_threads_.Pointer(); |
162 if (!allowed_threads->empty() && | 162 if (!allowed_threads->empty() && !base::ContainsValue(*allowed_threads, id)) { |
163 std::find(allowed_threads->begin(), allowed_threads->end(), id) == | |
164 allowed_threads->end()) { | |
165 NOTREACHED(); | 163 NOTREACHED(); |
166 base::debug::DumpWithoutCrashing(); | 164 base::debug::DumpWithoutCrashing(); |
167 } | 165 } |
168 | 166 |
169 return id; | 167 return id; |
170 } | 168 } |
171 | 169 |
172 } // namespace ui | 170 } // namespace ui |
OLD | NEW |