cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ppapi / proxy / tcp_socket_resource.cc
blob085aab3cf335bc16c2ff6dd03a6290511deb4f50
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/proxy/tcp_socket_resource.h"
7 #include "ppapi/proxy/ppapi_messages.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_net_address_api.h"
11 namespace ppapi {
12 namespace proxy {
14 namespace {
16 typedef thunk::EnterResourceNoLock<thunk::PPB_NetAddress_API>
17 EnterNetAddressNoLock;
19 } // namespace
21 TCPSocketResource::TCPSocketResource(Connection connection,
22 PP_Instance instance)
23 : TCPSocketResourceBase(connection, instance, false) {
24 SendCreate(BROWSER, PpapiHostMsg_TCPSocket_Create());
27 TCPSocketResource::~TCPSocketResource() {
28 DisconnectImpl();
31 thunk::PPB_TCPSocket_API* TCPSocketResource::AsPPB_TCPSocket_API() {
32 return this;
35 int32_t TCPSocketResource::Connect(PP_Resource addr,
36 scoped_refptr<TrackedCallback> callback) {
37 EnterNetAddressNoLock enter(addr, true);
38 if (enter.failed())
39 return PP_ERROR_BADARGUMENT;
41 return ConnectWithNetAddressImpl(&enter.object()->GetNetAddressPrivate(),
42 callback);
45 PP_Resource TCPSocketResource::GetLocalAddress() {
46 PP_NetAddress_Private addr_private;
47 if (!GetLocalAddressImpl(&addr_private))
48 return 0;
50 thunk::EnterResourceCreationNoLock enter(pp_instance());
51 if (enter.failed())
52 return 0;
53 return enter.functions()->CreateNetAddressFromNetAddressPrivate(
54 pp_instance(), addr_private);
57 PP_Resource TCPSocketResource::GetRemoteAddress() {
58 PP_NetAddress_Private addr_private;
59 if (!GetRemoteAddressImpl(&addr_private))
60 return 0;
62 thunk::EnterResourceCreationNoLock enter(pp_instance());
63 if (enter.failed())
64 return 0;
65 return enter.functions()->CreateNetAddressFromNetAddressPrivate(
66 pp_instance(), addr_private);
69 int32_t TCPSocketResource::Read(char* buffer,
70 int32_t bytes_to_read,
71 scoped_refptr<TrackedCallback> callback) {
72 return ReadImpl(buffer, bytes_to_read, callback);
75 int32_t TCPSocketResource::Write(const char* buffer,
76 int32_t bytes_to_write,
77 scoped_refptr<TrackedCallback> callback) {
78 return WriteImpl(buffer, bytes_to_write, callback);
81 void TCPSocketResource::Close() {
82 DisconnectImpl();
85 int32_t TCPSocketResource::SetOption(PP_TCPSocket_Option name,
86 const PP_Var& value,
87 scoped_refptr<TrackedCallback> callback) {
88 return SetOptionImpl(name, value, callback);
91 } // namespace proxy
92 } // namespace ppapi