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

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

Issue 6478018: Basic implementation of Pepper Transport API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 10 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 | « ppapi/cpp/dev/transport_dev.h ('k') | ppapi/tests/test_transport.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
12 #include "ppapi/cpp/var.h"
11 13
12 namespace pp { 14 namespace pp {
13 15
14 namespace { 16 namespace {
15 17
16 template <> const char* interface_name<PPB_Transport_Dev>() { 18 template <> const char* interface_name<PPB_Transport_Dev>() {
17 return PPB_TRANSPORT_DEV_INTERFACE; 19 return PPB_TRANSPORT_DEV_INTERFACE;
18 } 20 }
19 21
20 } // namespace 22 } // namespace
21 23
22 Transport_Dev::Transport_Dev(Instance* instance, 24 Transport_Dev::Transport_Dev(Instance* instance,
23 const char* name, 25 const char* name,
24 const char* proto) { 26 const char* proto) {
25 if (has_interface<PPB_Transport_Dev>()) 27 if (has_interface<PPB_Transport_Dev>())
26 PassRefFromConstructor(get_interface<PPB_Transport_Dev>()->CreateTransport( 28 PassRefFromConstructor(get_interface<PPB_Transport_Dev>()->CreateTransport(
27 instance->pp_instance(), name, proto)); 29 instance->pp_instance(), name, proto));
28 } 30 }
29 31
32 bool Transport_Dev::IsWritable() {
33 if (!has_interface<PPB_Transport_Dev>())
34 return false;
35 return PPBoolToBool(
36 get_interface<PPB_Transport_Dev>()->IsWritable(pp_resource()));
37 }
38
39 int32_t Transport_Dev::Connect(const CompletionCallback& cc) {
40 if (!has_interface<PPB_Transport_Dev>())
41 return PP_ERROR_NOINTERFACE;
42 return get_interface<PPB_Transport_Dev>()->Connect(
43 pp_resource(), cc.pp_completion_callback());
44 }
45
46 int32_t Transport_Dev::GetNextAddress(Var* address,
47 const CompletionCallback& cc) {
48 if (!has_interface<PPB_Transport_Dev>())
49 return PP_ERROR_NOINTERFACE;
50 PP_Var temp_address = PP_MakeUndefined();
51 int32_t ret_val = get_interface<PPB_Transport_Dev>()->GetNextAddress(
52 pp_resource(), &temp_address, cc.pp_completion_callback());
53 *address = Var(Var::PassRef(), temp_address);
54 return ret_val;
55 }
56
57 int32_t Transport_Dev::ReceiveRemoteAddress(const pp::Var& address) {
58 if (!has_interface<PPB_Transport_Dev>())
59 return PP_ERROR_NOINTERFACE;
60 return get_interface<PPB_Transport_Dev>()->ReceiveRemoteAddress(
61 pp_resource(), address.pp_var());
62 }
63
64 int32_t Transport_Dev::Recv(void* data, uint32_t len,
65 const CompletionCallback& cc) {
66 if (!has_interface<PPB_Transport_Dev>())
67 return PP_ERROR_NOINTERFACE;
68 return get_interface<PPB_Transport_Dev>()->Recv(
69 pp_resource(), data, len, cc.pp_completion_callback());
70 }
71
72 int32_t Transport_Dev::Send(const void* data, uint32_t len,
73 const CompletionCallback& cc) {
74 if (!has_interface<PPB_Transport_Dev>())
75 return PP_ERROR_NOINTERFACE;
76 return get_interface<PPB_Transport_Dev>()->Send(
77 pp_resource(), data, len, cc.pp_completion_callback());
78 }
79
80 int32_t Transport_Dev::Close() {
81 if (!has_interface<PPB_Transport_Dev>())
82 return PP_ERROR_NOINTERFACE;
83 return get_interface<PPB_Transport_Dev>()->Close(pp_resource());
84 }
85
30 } // namespace pp 86 } // namespace pp
31
OLDNEW
« no previous file with comments | « ppapi/cpp/dev/transport_dev.h ('k') | ppapi/tests/test_transport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698