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

Side by Side Diff: src/trusted/weak_ref/weak_ref.h

Issue 7216027: typesafe call-on-main-thread interface. no cast to/from void* required. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/trusted/weak_ref/call_on_main_thread.h ('k') | src/trusted/weak_ref/weak_ref.gyp » ('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) 2011 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 // A form of weak reference for use by CallOnMainThread (COMT). This 7 // A form of weak reference for use by CallOnMainThread (COMT). This
8 // class is essentially a thread-safe refcounted class that is used to 8 // class is essentially a thread-safe refcounted class that is used to
9 // hold pointers to resources that may "go away" due to the plugin 9 // hold pointers to resources that may "go away" due to the plugin
10 // instance being destroyed. Generally resource cleanup should be 10 // instance being destroyed. Generally resource cleanup should be
(...skipping 10 matching lines...) Expand all
21 // destroys all resources associated with the queued callbacks. The 21 // destroys all resources associated with the queued callbacks. The
22 // WeakRef resource pointer is released, triggering the dtor for the 22 // WeakRef resource pointer is released, triggering the dtor for the
23 // resource, and the WeakRef reference is also decremented, so that 23 // resource, and the WeakRef reference is also decremented, so that
24 // when the COMT callback is invoked, it can discover that the 24 // when the COMT callback is invoked, it can discover that the
25 // associated callback data is gone, and will just abort by 25 // associated callback data is gone, and will just abort by
26 // decrementing the last reference to the WeakRef object. 26 // decrementing the last reference to the WeakRef object.
27 // 27 //
28 // In the normal execution, the callback data is present, and 28 // In the normal execution, the callback data is present, and
29 // ownership is released to the callback function. 29 // ownership is released to the callback function.
30 30
31 #ifndef NATIVE_CLIENT_SRC_TRUSTED_WEAK_REF_WEAK_REF_H_
32 #define NATIVE_CLIENT_SRC_TRUSTED_WEAK_REF_WEAK_REF_H_
33
31 #include <set> 34 #include <set>
32 35
33 #include "native_client/src/include/portability.h" 36 #include "native_client/src/include/portability.h"
34 #include "native_client/src/include/nacl_scoped_ptr.h" 37 #include "native_client/src/include/nacl_scoped_ptr.h"
35 #include "native_client/src/shared/platform/refcount_base.h" 38 #include "native_client/src/shared/platform/refcount_base.h"
36 #include "native_client/src/shared/platform/nacl_check.h" 39 #include "native_client/src/shared/platform/nacl_check.h"
37 #include "native_client/src/shared/platform/nacl_log.h" 40 #include "native_client/src/shared/platform/nacl_log.h"
38 #include "native_client/src/shared/platform/nacl_sync.h" 41 #include "native_client/src/shared/platform/nacl_sync.h"
39 #include "native_client/src/shared/platform/nacl_sync_checked.h" 42 #include "native_client/src/shared/platform/nacl_sync_checked.h"
40 43
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 WeakRef(WeakRefAnchor* anchor, R* resource) 202 WeakRef(WeakRefAnchor* anchor, R* resource)
200 : AnchoredResource(anchor), 203 : AnchoredResource(anchor),
201 resource_(resource) { 204 resource_(resource) {
202 CHECK(resource != NULL); 205 CHECK(resource != NULL);
203 } 206 }
204 207
205 scoped_ptr<R> resource_; // NULL when anchor object is destroyed. 208 scoped_ptr<R> resource_; // NULL when anchor object is destroyed.
206 }; 209 };
207 210
208 } // namespace nacl 211 } // namespace nacl
212
213 #endif
OLDNEW
« no previous file with comments | « src/trusted/weak_ref/call_on_main_thread.h ('k') | src/trusted/weak_ref/weak_ref.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698