Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Add NaCl SyncSocket and SharedMemory stubs for the PPAPI Proxy.
Browse files Browse the repository at this point in the history
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/9515018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124181 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
bbudge@chromium.org committed Feb 29, 2012
1 parent 570c195 commit 1cea38b
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 0 deletions.
124 changes: 124 additions & 0 deletions base/shared_memory_nacl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/shared_memory.h"

#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>

#include "base/logging.h"

namespace base {

SharedMemory::SharedMemory()
: mapped_file_(-1),
mapped_size_(0),
inode_(0),
memory_(NULL),
read_only_(false),
created_size_(0) {
NOTREACHED();
}

SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only)
: mapped_file_(handle.fd),
mapped_size_(0),
inode_(0),
memory_(NULL),
read_only_(read_only),
created_size_(0) {
NOTREACHED();
}

SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only,
ProcessHandle process)
: mapped_file_(handle.fd),
mapped_size_(0),
inode_(0),
memory_(NULL),
read_only_(read_only),
created_size_(0) {
NOTREACHED();
}

SharedMemory::~SharedMemory() {
}

// static
bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) {
NOTREACHED();
return false;
}

// static
SharedMemoryHandle SharedMemory::NULLHandle() {
return SharedMemoryHandle();
}

// static
void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
}

bool SharedMemory::CreateAndMapAnonymous(uint32 size) {
return false;
}

bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
return false;
}

// Our current implementation of shmem is with mmap()ing of files.
// These files need to be deleted explicitly.
// In practice this call is only needed for unit tests.
bool SharedMemory::Delete(const std::string& name) {
return false;
}

bool SharedMemory::Open(const std::string& name, bool read_only) {
return false;
}

bool SharedMemory::Map(uint32 bytes) {
return false;
}

bool SharedMemory::Unmap() {
return false;
}

SharedMemoryHandle SharedMemory::handle() const {
return FileDescriptor(mapped_file_, false);
}

void SharedMemory::Close() {
}

void SharedMemory::Lock() {
}

void SharedMemory::Unlock() {
}

bool SharedMemory::PrepareMapFile(FILE *fp) {
return false;
}

bool SharedMemory::FilePathForMemoryName(const std::string& mem_name,
FilePath* path) {
return false;
}

void SharedMemory::LockOrUnlockCommon(int function) {
}

bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
SharedMemoryHandle *new_handle,
bool close_self) {
return false;
}

} // namespace base
63 changes: 63 additions & 0 deletions base/sync_socket_nacl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/sync_socket.h"

#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <sys/types.h>

#include "base/file_util.h"
#include "base/logging.h"


namespace base {

const SyncSocket::Handle SyncSocket::kInvalidHandle = -1;

SyncSocket::SyncSocket() : handle_(kInvalidHandle) {
NOTREACHED();
}

SyncSocket::~SyncSocket() {
}

// static
bool SyncSocket::CreatePair(SyncSocket* socket_a, SyncSocket* socket_b) {
return false;
}

bool SyncSocket::Close() {
return false;
}

size_t SyncSocket::Send(const void* buffer, size_t length) {
return 0;
}

size_t SyncSocket::Receive(void* buffer, size_t length) {
return 0;
}

size_t SyncSocket::Peek() {
return 0;
}

CancelableSyncSocket::CancelableSyncSocket() {}
CancelableSyncSocket::CancelableSyncSocket(Handle handle)
: SyncSocket(handle) {
}

bool CancelableSyncSocket::Shutdown() {
return false;
}

// static
bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a,
CancelableSyncSocket* socket_b) {
return SyncSocket::CreatePair(socket_a, socket_b);
}

} // namespace base

0 comments on commit 1cea38b

Please sign in to comment.