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

Side by Side Diff: ppapi/cpp/dev/transport_dev.cc

Issue 6042003: Finish basic implementation of Pepper Transport API and... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "ppapi/cpp/dev/transport_dev.h" 5 #include "ppapi/cpp/dev/transport_dev.h"
6 6
7 #include "ppapi/c/pp_errors.h"
7 #include "ppapi/cpp/instance.h" 8 #include "ppapi/cpp/instance.h"
8 #include "ppapi/cpp/resource.h" 9 #include "ppapi/cpp/resource.h"
9 #include "ppapi/cpp/module.h" 10 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/module_impl.h" 11 #include "ppapi/cpp/module_impl.h"
11 12
12 namespace { 13 namespace {
13 14
14 DeviceFuncs<PPB_Transport_Dev> transport_f(PPB_TRANSPORT_DEV_INTERFACE); 15 DeviceFuncs<PPB_Transport_Dev> transport_f(PPB_TRANSPORT_DEV_INTERFACE);
15 16
16 } // namespace 17 } // namespace
17 18
18 namespace pp { 19 namespace pp {
19 20
20 Transport_Dev::Transport_Dev(const char* name, 21 Transport_Dev::Transport_Dev(const char* name,
21 const char* proto) { 22 const char* proto) {
22 if (transport_f) 23 if (transport_f)
23 PassRefFromConstructor( 24 PassRefFromConstructor(
24 transport_f->CreateTransport(Module::Get()->pp_module(), name, proto)); 25 transport_f->CreateTransport(Module::Get()->pp_module(), name, proto));
25 } 26 }
26 27
28 bool Transport_Dev::IsWritable() {
29 if (!transport_f) return false;
30 return PPBoolToBool(transport_f->IsWritable(pp_resource()));
31 }
32
33 int32_t Transport_Dev::Connect(const CompletionCallback& cc) {
34 if (!transport_f) return PP_ERROR_NOINTERFACE;
35 return transport_f->Connect(pp_resource(), cc.pp_completion_callback());
36 }
37
38 int32_t Transport_Dev::GetNextAddress(PP_Var* address,
39 const CompletionCallback& cc) {
40 if (!transport_f) return PP_ERROR_NOINTERFACE;
41 return transport_f->GetNextAddress(pp_resource(), address,
42 cc.pp_completion_callback());
43 }
44
45 int32_t Transport_Dev::ReceiveRemoteAddress(const PP_Var& address) {
46 if (!transport_f) return PP_ERROR_NOINTERFACE;
47 return transport_f->ReceiveRemoteAddress(pp_resource(), address);
48 }
49
50 int32_t Transport_Dev::Recv(void* data, uint32_t len,
51 const CompletionCallback& cc) {
52 if (!transport_f) return PP_ERROR_NOINTERFACE;
53 return transport_f->Recv(pp_resource(), data, len,
54 cc.pp_completion_callback());
55 }
56
57 int32_t Transport_Dev::Send(const void* data, uint32_t len,
58 const CompletionCallback& cc) {
59 if (!transport_f) return PP_ERROR_NOINTERFACE;
60 return transport_f->Send(pp_resource(), data, len,
61 cc.pp_completion_callback());
62 }
63
64 int32_t Transport_Dev::Close() {
65 if (!transport_f) return PP_ERROR_NOINTERFACE;
66 return transport_f->Close(pp_resource());
67 }
68
27 } // namespace pp 69 } // namespace pp
28
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698