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

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

Issue 10916081: Add secure sockets to dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo in bin.gypi 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef BIN_TLS_SOCKET_H_
6 #define BIN_TLS_SOCKET_H_
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include <stdio.h>
11 #include <sys/types.h>
12
13 #include "bin/builtin.h"
14 #include "bin/dartutils.h"
15 #include "platform/globals.h"
16 #include "platform/thread.h"
17
18 static Dart_Handle HandleError(Dart_Handle handle) {
19 if (Dart_IsError(handle)) Dart_PropagateError(handle);
20 return handle;
21 }
22
23 /* Handle an error reported from the NSS library. */
24 static void ReportError(const char* message, int error_code) {
25 // TODO(): Throw SocketIOException here. The error_code can go in its
26 // OSError's errorCode field.
27 printf("Secure Socket error: %s Error code %d\n", message, pr_error);
28 }
29
30 static const bool kTlsLogging = true;
Søren Gjesse 2012/11/01 11:49:11 This logging should be turned off before committin
Bill Hesse 2012/11/11 22:34:34 Removed. On 2012/11/01 11:49:11, Søren Gjesse wrot
31
32 static void TlsLog(const char* message) {
33 if (kTlsLogging) {
34 printf("%s\n", message);
35 }
36 }
37
38 static void TlsLogInt(const char* message, int value) {
39 if (kTlsLogging) {
40 printf("%s: %d\n", message, value);
41 }
42 }
43
44 class TlsFilterPlatformData;
45
46 class TlsFilter {
47 public:
48 enum BufferIndex { kReadPlaintext,
49 kWritePlaintext,
50 kReadEncrypted,
51 kWriteEncrypted,
52 kNumBuffers};
53
54 TlsFilter();
55 void Init(Dart_Handle dart_this);
56 void Connect();
57 void Destroy();
58 void DestroyPlatformIndependent();
59 void RegisterHandshakeCallbacks(Dart_Handle start, Dart_Handle finish);
60 static void InitializeLibrary(const char* pkcert_directory);
61
62 intptr_t ProcessBuffer(int bufferIndex);
63
64 private:
65 // static const char* bufferNames_[kNumBuffers];
66 static bool library_initialized_; // Should be mutex protected.
67
68 uint8_t* buffers_[kNumBuffers];
69 int64_t buffer_size_;
70 Dart_Handle stringStart_;
71 Dart_Handle stringLength_;
72 Dart_Handle dart_buffer_objects_[kNumBuffers];
73 Dart_Handle handshake_start_;
74 Dart_Handle handshake_finish_;
75 bool in_handshake_;
76 TlsFilterPlatformData* data_;
77
78 void InitializeBuffers(Dart_Handle dart_this);
79 void InitializePlatformData();
80 static void LockInitMutex() {}
81 static void UnlockInitMutex() {}
82
83 DISALLOW_COPY_AND_ASSIGN(TlsFilter);
84 };
85
86 #endif // BIN_TLS_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698