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

Side by Side Diff: third_party/WebKit/Source/platform/CrossThreadCopier.h

Issue 1916923005: Disallow direct use of AllowCrossThreadAccessWrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_prep0
Patch Set: auto-Rebase Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 { 234 {
235 return ptr; 235 return ptr;
236 } 236 }
237 }; 237 };
238 238
239 // |T| is |C*| or |const WeakPtr<C>&|. 239 // |T| is |C*| or |const WeakPtr<C>&|.
240 template <typename T> 240 template <typename T>
241 struct AllowCrossThreadAccessWrapper { 241 struct AllowCrossThreadAccessWrapper {
242 STACK_ALLOCATED(); 242 STACK_ALLOCATED();
243 public: 243 public:
244 explicit AllowCrossThreadAccessWrapper(T value) : m_value(value) { }
245 T value() const { return m_value; } 244 T value() const { return m_value; }
246 private: 245 private:
246 // Only constructible from AllowCrossThreadAccess().
247 explicit AllowCrossThreadAccessWrapper(T value) : m_value(value) { }
248 template <typename U>
249 friend AllowCrossThreadAccessWrapper<U*> AllowCrossThreadAccess(U*);
250 template <typename U>
251 friend AllowCrossThreadAccessWrapper<const WeakPtr<U>&> AllowCrossThreadAcce ss(const WeakPtr<U>&);
252
247 // This raw pointer is safe since AllowCrossThreadAccessWrapper is 253 // This raw pointer is safe since AllowCrossThreadAccessWrapper is
248 // always stack-allocated. Ideally this should be Member<T> if T is 254 // always stack-allocated. Ideally this should be Member<T> if T is
249 // garbage-collected and T* otherwise, but we don't want to introduce 255 // garbage-collected and T* otherwise, but we don't want to introduce
250 // another template magic just for distinguishing Member<T> from T*. 256 // another template magic just for distinguishing Member<T> from T*.
251 // From the perspective of GC, T* always works correctly. 257 // From the perspective of GC, T* always works correctly.
252 GC_PLUGIN_IGNORE("") 258 GC_PLUGIN_IGNORE("")
253 T m_value; 259 T m_value;
254 }; 260 };
255 261
256 template <typename T> 262 template <typename T>
(...skipping 11 matching lines...) Expand all
268 274
269 template <typename T> 275 template <typename T>
270 AllowCrossThreadAccessWrapper<const WeakPtr<T>&> AllowCrossThreadAccess(const We akPtr<T>& value) 276 AllowCrossThreadAccessWrapper<const WeakPtr<T>&> AllowCrossThreadAccess(const We akPtr<T>& value)
271 { 277 {
272 return AllowCrossThreadAccessWrapper<const WeakPtr<T>&>(value); 278 return AllowCrossThreadAccessWrapper<const WeakPtr<T>&>(value);
273 } 279 }
274 280
275 } // namespace blink 281 } // namespace blink
276 282
277 #endif // CrossThreadCopier_h 283 #endif // CrossThreadCopier_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698