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

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

Issue 10916081: Add secure sockets to dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments, remove HandshakeStartHandler. Created 8 years, 1 month 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 | « runtime/bin/bin.gypi ('k') | runtime/bin/dartutils.cc » ('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_DARTUTILS_H_ 5 #ifndef BIN_DARTUTILS_H_
6 #define BIN_DARTUTILS_H_ 6 #define BIN_DARTUTILS_H_
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
11 #include "platform/globals.h" 11 #include "platform/globals.h"
12 12
13 /* Handles error handles returned from Dart API functions. If a value
14 * is an error, uses Dart_PropagateError to throw it to the enclosing
15 * Dart activation. Otherwise, returns the original handle.
16 *
17 * This function can be used to wrap most API functions, but API
18 * functions can also be nested without this error check, since all
19 * API functions return any error handles passed in as arguments, unchanged.
20 */
21 static inline Dart_Handle ThrowIfError(Dart_Handle handle) {
22 if (Dart_IsError(handle)) Dart_PropagateError(handle);
23 return handle;
24 }
25
13 class CommandLineOptions { 26 class CommandLineOptions {
14 public: 27 public:
15 explicit CommandLineOptions(int max_count) 28 explicit CommandLineOptions(int max_count)
16 : count_(0), max_count_(max_count), arguments_(NULL) { 29 : count_(0), max_count_(max_count), arguments_(NULL) {
17 static const int kWordSize = sizeof(intptr_t); 30 static const int kWordSize = sizeof(intptr_t);
18 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize)); 31 arguments_ = reinterpret_cast<const char **>(malloc(max_count * kWordSize));
19 if (arguments_ == NULL) { 32 if (arguments_ == NULL) {
20 max_count_ = 0; 33 max_count_ = 0;
21 } 34 }
22 } 35 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 Dart_Handle library, 111 Dart_Handle library,
99 Dart_Handle url, 112 Dart_Handle url,
100 Dart_LibraryTag tag, 113 Dart_LibraryTag tag,
101 const char* filename); 114 const char* filename);
102 static Dart_Handle PrepareForScriptLoading(const char* package_root, 115 static Dart_Handle PrepareForScriptLoading(const char* package_root,
103 Dart_Handle builtin_lib); 116 Dart_Handle builtin_lib);
104 117
105 static bool PostNull(Dart_Port port_id); 118 static bool PostNull(Dart_Port port_id);
106 static bool PostInt32(Dart_Port port_id, int32_t value); 119 static bool PostInt32(Dart_Port port_id, int32_t value);
107 120
121 static Dart_Handle GetDartClass(const char* library_url,
122 const char* class_name);
108 // Create a new Dart OSError object with the current OS error. 123 // Create a new Dart OSError object with the current OS error.
109 static Dart_Handle NewDartOSError(); 124 static Dart_Handle NewDartOSError();
110 // Create a new Dart OSError object with the provided OS error. 125 // Create a new Dart OSError object with the provided OS error.
111 static Dart_Handle NewDartOSError(OSError* os_error); 126 static Dart_Handle NewDartOSError(OSError* os_error);
127 static Dart_Handle NewDartSocketIOException(const char* message,
128 Dart_Handle os_error);
129 static Dart_Handle NewDartExceptionWithMessage(const char* library_url,
130 const char* exception_name,
131 const char* message);
132 static Dart_Handle NewDartArgumentError(const char* message);
112 133
113 // Create a new Dart String object from a C String. 134 // Create a new Dart String object from a C String.
114 static Dart_Handle NewString(const char* str) { 135 static Dart_Handle NewString(const char* str) {
115 ASSERT((str != NULL) && (strlen(str) != 0)); 136 ASSERT(str != NULL);
116 return Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str), 137 return Dart_NewStringFromUTF8(reinterpret_cast<const uint8_t*>(str),
117 strlen(str)); 138 strlen(str));
118 } 139 }
119 140
120 static void SetOriginalWorkingDirectory(); 141 static void SetOriginalWorkingDirectory();
121 142
122 // Global state that stores the original working directory.. 143 // Global state that stores the original working directory..
123 static const char* original_working_directory; 144 static const char* original_working_directory;
124 145
125 static const char* kDartScheme; 146 static const char* kDartScheme;
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 void* Peer() const { return cobject_->value.as_external_byte_array.peer; } 390 void* Peer() const { return cobject_->value.as_external_byte_array.peer; }
370 Dart_PeerFinalizer Callback() const { 391 Dart_PeerFinalizer Callback() const {
371 return cobject_->value.as_external_byte_array.callback; 392 return cobject_->value.as_external_byte_array.callback;
372 } 393 }
373 394
374 private: 395 private:
375 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array); 396 DISALLOW_COPY_AND_ASSIGN(CObjectExternalUint8Array);
376 }; 397 };
377 398
378 #endif // BIN_DARTUTILS_H_ 399 #endif // BIN_DARTUTILS_H_
OLDNEW
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/bin/dartutils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698