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

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: Address comments (done). 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 /* Handle an error reported from the NSS library. */
19 static void ReportError(const char* message, int error_code) {
20 // TODO(): Throw SocketIOException here. The error_code can go in its
Mads Ager (google) 2012/11/01 10:09:01 Fix this.
21 // OSError's errorCode field.
22 printf("Secure Socket error: %s Error code %d\n", message, error_code);
23 }
24
25 static const bool kTlsLogging = true;
26
27 static void TlsLog(const char* message) {
28 if (kTlsLogging) {
29 printf("%s\n", message);
30 }
31 }
32
33 static void TlsLogInt(const char* message, int value) {
34 if (kTlsLogging) {
35 printf("%s: %d\n", message, value);
36 }
37 }
38
39 class TlsFilterPlatformData;
40
41 class TlsFilter {
42 public:
43 enum BufferIndex { kReadPlaintext,
44 kWritePlaintext,
45 kReadEncrypted,
46 kWriteEncrypted,
47 kNumBuffers};
48
49 TlsFilter();
50 void Init(Dart_Handle dart_this);
51 void Connect();
52 void Destroy();
53 void DestroyPlatformIndependent();
54 void RegisterHandshakeCallbacks(Dart_Handle start, Dart_Handle finish);
55 static void InitializeLibrary(const char* pkcert_directory);
56
57 intptr_t ProcessBuffer(int bufferIndex);
58
59 private:
60 // static const char* bufferNames_[kNumBuffers];
Mads Ager (google) 2012/11/01 10:09:01 Code in comment.
61 static bool library_initialized_; // Should be mutex protected.
62
63 uint8_t* buffers_[kNumBuffers];
64 int64_t buffer_size_;
65 Dart_Handle stringStart_;
66 Dart_Handle stringLength_;
67 Dart_Handle dart_buffer_objects_[kNumBuffers];
68 Dart_Handle handshake_start_;
69 Dart_Handle handshake_finish_;
70 bool in_handshake_;
71 TlsFilterPlatformData* data_;
72
73 void InitializeBuffers(Dart_Handle dart_this);
74 void InitializePlatformData();
75 static void LockInitMutex() {}
76 static void UnlockInitMutex() {}
77
78 DISALLOW_COPY_AND_ASSIGN(TlsFilter);
79 };
80
81 #endif // BIN_TLS_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698