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

Side by Side Diff: runtime/bin/io_buffer.h

Issue 205153002: Auto delete persistent weak handles during finalization after invoking the callback associated with… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | « no previous file | runtime/include/dart_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_IO_BUFFER_H_ 5 #ifndef BIN_IO_BUFFER_H_
6 #define BIN_IO_BUFFER_H_ 6 #define BIN_IO_BUFFER_H_
7 7
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 9
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
(...skipping 11 matching lines...) Expand all
22 // Allocate IO buffer storage. 22 // Allocate IO buffer storage.
23 static uint8_t* Allocate(intptr_t size); 23 static uint8_t* Allocate(intptr_t size);
24 24
25 // Function for disposing of IO buffer storage. All backing storage 25 // Function for disposing of IO buffer storage. All backing storage
26 // for IO buffers must be freed using this function. 26 // for IO buffers must be freed using this function.
27 static void Free(void* buffer) { 27 static void Free(void* buffer) {
28 delete[] reinterpret_cast<uint8_t*>(buffer); 28 delete[] reinterpret_cast<uint8_t*>(buffer);
29 } 29 }
30 30
31 // Function for finalizing external byte arrays used as IO buffers. 31 // Function for finalizing external byte arrays used as IO buffers.
32 static void Finalizer(Dart_Isolate isolate, 32 static void Finalizer(void* isolate_callback_data,
33 Dart_WeakPersistentHandle handle, 33 Dart_WeakPersistentHandle handle,
34 void* buffer) { 34 void* buffer) {
35 Free(buffer); 35 Free(buffer);
36 if (handle != NULL) {
37 Dart_DeleteWeakPersistentHandle(isolate, handle);
38 }
39 } 36 }
40 37
41 private: 38 private:
42 DISALLOW_ALLOCATION(); 39 DISALLOW_ALLOCATION();
43 DISALLOW_IMPLICIT_CONSTRUCTORS(IOBuffer); 40 DISALLOW_IMPLICIT_CONSTRUCTORS(IOBuffer);
44 }; 41 };
45 42
46 } // namespace bin 43 } // namespace bin
47 } // namespace dart 44 } // namespace dart
48 45
49 #endif // BIN_IO_BUFFER_H_ 46 #endif // BIN_IO_BUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/include/dart_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698