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

Side by Side Diff: base/sync_socket_nacl.cc

Issue 10696217: Implement SyncSocket for untrusted NaCl builds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | no next file » | 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 Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/sync_socket.h" 5 #include "base/sync_socket.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <limits.h> 8 #include <limits.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
11 11
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 14
15 15
16 namespace base { 16 namespace base {
17 17
18 const SyncSocket::Handle SyncSocket::kInvalidHandle = -1; 18 const SyncSocket::Handle SyncSocket::kInvalidHandle = -1;
19 19
20 SyncSocket::SyncSocket() : handle_(kInvalidHandle) { 20 SyncSocket::SyncSocket() : handle_(kInvalidHandle) {
21 NOTREACHED();
22 } 21 }
23 22
24 SyncSocket::~SyncSocket() { 23 SyncSocket::~SyncSocket() {
25 } 24 }
26 25
27 // static 26 // static
28 bool SyncSocket::CreatePair(SyncSocket* socket_a, SyncSocket* socket_b) { 27 bool SyncSocket::CreatePair(SyncSocket* socket_a, SyncSocket* socket_b) {
29 return false; 28 return false;
30 } 29 }
31 30
32 bool SyncSocket::Close() { 31 bool SyncSocket::Close() {
33 return false; 32 if (handle_ != kInvalidHandle) {
33 if (close(handle_) < 0)
34 DPLOG(ERROR) << "close";
35 handle_ = -1;
36 }
37 return true;
34 } 38 }
35 39
36 size_t SyncSocket::Send(const void* buffer, size_t length) { 40 size_t SyncSocket::Send(const void* buffer, size_t length) {
37 return 0; 41 // Not implemented since it's not needed by any client code yet.
42 return -1;
38 } 43 }
39 44
40 size_t SyncSocket::Receive(void* buffer, size_t length) { 45 size_t SyncSocket::Receive(void* buffer, size_t length) {
41 return 0; 46 return read(handle_, buffer, length);
42 } 47 }
43 48
44 size_t SyncSocket::Peek() { 49 size_t SyncSocket::Peek() {
45 return 0; 50 return -1;
46 } 51 }
47 52
48 CancelableSyncSocket::CancelableSyncSocket() {} 53 CancelableSyncSocket::CancelableSyncSocket() {
54 }
55
49 CancelableSyncSocket::CancelableSyncSocket(Handle handle) 56 CancelableSyncSocket::CancelableSyncSocket(Handle handle)
50 : SyncSocket(handle) { 57 : SyncSocket(handle) {
51 } 58 }
52 59
53 size_t CancelableSyncSocket::Send(const void* buffer, size_t length) { 60 size_t CancelableSyncSocket::Send(const void* buffer, size_t length) {
54 return 0; 61 return -1;
55 } 62 }
56 63
57 bool CancelableSyncSocket::Shutdown() { 64 bool CancelableSyncSocket::Shutdown() {
58 return false; 65 return false;
59 } 66 }
60 67
61 // static 68 // static
62 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, 69 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a,
63 CancelableSyncSocket* socket_b) { 70 CancelableSyncSocket* socket_b) {
64 return SyncSocket::CreatePair(socket_a, socket_b); 71 return SyncSocket::CreatePair(socket_a, socket_b);
65 } 72 }
66 73
67 } // namespace base 74 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698