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

Side by Side Diff: ppapi/cpp/private/flash_tcp_socket.cc

Issue 8506016: Remove 'Flash' from TCP/UDP Pepper interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // TODO(yzshen): See the comment in corresponding .h file.
6
7 #include "ppapi/cpp/private/flash_tcp_socket.h"
8
9 #include "ppapi/c/pp_bool.h"
10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/cpp/completion_callback.h"
12 #include "ppapi/cpp/instance.h"
13 #include "ppapi/cpp/module.h"
14 #include "ppapi/cpp/module_impl.h"
15
16 namespace pp {
17
18 namespace {
19
20 template <> const char* interface_name<PPB_Flash_TCPSocket>() {
21 return PPB_FLASH_TCPSOCKET_INTERFACE;
22 }
23
24 } // namespace
25
26 namespace flash {
27
28 TCPSocket::TCPSocket(Instance* instance) {
29 if (has_interface<PPB_Flash_TCPSocket>() && instance) {
30 PassRefFromConstructor(get_interface<PPB_Flash_TCPSocket>()->Create(
31 instance->pp_instance()));
32 }
33 }
34
35 int32_t TCPSocket::Connect(const char* host,
36 uint16_t port,
37 const CompletionCallback& callback) {
38 if (!has_interface<PPB_Flash_TCPSocket>())
39 return callback.MayForce(PP_ERROR_NOINTERFACE);
40 return get_interface<PPB_Flash_TCPSocket>()->Connect(
41 pp_resource(), host, port, callback.pp_completion_callback());
42 }
43
44 int32_t TCPSocket::ConnectWithNetAddress(const PP_Flash_NetAddress* addr,
45 const CompletionCallback& callback) {
46 if (!has_interface<PPB_Flash_TCPSocket>())
47 return callback.MayForce(PP_ERROR_NOINTERFACE);
48 return get_interface<PPB_Flash_TCPSocket>()->ConnectWithNetAddress(
49 pp_resource(), addr, callback.pp_completion_callback());
50 }
51
52 bool TCPSocket::GetLocalAddress(PP_Flash_NetAddress* local_addr) {
53 if (!has_interface<PPB_Flash_TCPSocket>())
54 return false;
55
56 PP_Bool result = get_interface<PPB_Flash_TCPSocket>()->GetLocalAddress(
57 pp_resource(), local_addr);
58 return PP_ToBool(result);
59 }
60
61 bool TCPSocket::GetRemoteAddress(PP_Flash_NetAddress* remote_addr) {
62 if (!has_interface<PPB_Flash_TCPSocket>())
63 return false;
64 PP_Bool result = get_interface<PPB_Flash_TCPSocket>()->GetRemoteAddress(
65 pp_resource(), remote_addr);
66 return PP_ToBool(result);
67 }
68
69 int32_t TCPSocket::SSLHandshake(const char* server_name,
70 uint16_t server_port,
71 const CompletionCallback& callback) {
72 if (!has_interface<PPB_Flash_TCPSocket>())
73 return callback.MayForce(PP_ERROR_NOINTERFACE);
74 return get_interface<PPB_Flash_TCPSocket>()->SSLHandshake(
75 pp_resource(), server_name, server_port,
76 callback.pp_completion_callback());
77 }
78
79 int32_t TCPSocket::Read(char* buffer,
80 int32_t bytes_to_read,
81 const CompletionCallback& callback) {
82 if (!has_interface<PPB_Flash_TCPSocket>())
83 return callback.MayForce(PP_ERROR_NOINTERFACE);
84 return get_interface<PPB_Flash_TCPSocket>()->Read(
85 pp_resource(), buffer, bytes_to_read, callback.pp_completion_callback());
86 }
87
88 int32_t TCPSocket::Write(const char* buffer,
89 int32_t bytes_to_write,
90 const CompletionCallback& callback) {
91 if (!has_interface<PPB_Flash_TCPSocket>())
92 return callback.MayForce(PP_ERROR_NOINTERFACE);
93 return get_interface<PPB_Flash_TCPSocket>()->Write(
94 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback());
95 }
96
97 void TCPSocket::Disconnect() {
98 if (!has_interface<PPB_Flash_TCPSocket>())
99 return;
100 return get_interface<PPB_Flash_TCPSocket>()->Disconnect(pp_resource());
101 }
102
103 } // namespace flash
104 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698