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

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

Issue 9568007: Added CPP wrapper for PPB_TCPServerSocket_Private. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Restored IsAvailable method, fixed TCPSocketPrivate constructor. Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2011 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/private/tcp_socket_private.h" 5 #include "ppapi/cpp/private/tcp_socket_private.h"
6 6
7 #include "ppapi/c/pp_bool.h" 7 #include "ppapi/c/pp_bool.h"
8 #include "ppapi/c/pp_errors.h" 8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/instance_handle.h" 10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module.h" 11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/module_impl.h" 12 #include "ppapi/cpp/module_impl.h"
13 13
14 namespace pp { 14 namespace pp {
15 15
16 namespace { 16 namespace {
17 17
18 template <> const char* interface_name<PPB_TCPSocket_Private>() { 18 template <> const char* interface_name<PPB_TCPSocket_Private>() {
19 return PPB_TCPSOCKET_PRIVATE_INTERFACE; 19 return PPB_TCPSOCKET_PRIVATE_INTERFACE;
20 } 20 }
21 21
22 } // namespace 22 } // namespace
23 23
24 TCPSocketPrivate::TCPSocketPrivate(const InstanceHandle& instance) { 24 TCPSocketPrivate::TCPSocketPrivate(const InstanceHandle& instance) {
25 if (has_interface<PPB_TCPSocket_Private>()) { 25 if (has_interface<PPB_TCPSocket_Private>()) {
26 PassRefFromConstructor(get_interface<PPB_TCPSocket_Private>()->Create( 26 PassRefFromConstructor(get_interface<PPB_TCPSocket_Private>()->Create(
27 instance.pp_instance())); 27 instance.pp_instance()));
28 } 28 }
29 } 29 }
30 30
ygorshenin1 2012/03/07 11:17:29 I'm still afraid, that if PPB_TCPSocket_Private in
yzshen1 2012/03/07 17:27:05 You could release it using ReleaseResource() in pp
ygorshenin1 2012/03/07 17:40:40 Sure, but how to notify user about that? On 2012/
yzshen1 2012/03/07 17:56:49 is_null() will be true. If the user expects the r
brettw 2012/03/08 18:47:17 I'd just delete the if and call the default resour
ygorshenin1 2012/03/11 09:39:33 Done.
31 TCPSocketPrivate::TCPSocketPrivate(PassRef, PP_Resource resource) {
32 if (has_interface<PPB_TCPSocket_Private>() &&
33 get_interface<PPB_TCPSocket_Private>()->IsTCPSocket(resource)) {
34 PassRefFromConstructor(resource);
35 }
36 }
37
31 // static 38 // static
32 bool TCPSocketPrivate::IsAvailable() { 39 bool TCPSocketPrivate::IsAvailable() {
33 return has_interface<PPB_TCPSocket_Private>(); 40 return has_interface<PPB_TCPSocket_Private>();
34 } 41 }
35 42
36 int32_t TCPSocketPrivate::Connect(const char* host, 43 int32_t TCPSocketPrivate::Connect(const char* host,
37 uint16_t port, 44 uint16_t port,
38 const CompletionCallback& callback) { 45 const CompletionCallback& callback) {
39 if (!has_interface<PPB_TCPSocket_Private>()) 46 if (!has_interface<PPB_TCPSocket_Private>())
40 return callback.MayForce(PP_ERROR_NOINTERFACE); 47 return callback.MayForce(PP_ERROR_NOINTERFACE);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback()); 103 pp_resource(), buffer, bytes_to_write, callback.pp_completion_callback());
97 } 104 }
98 105
99 void TCPSocketPrivate::Disconnect() { 106 void TCPSocketPrivate::Disconnect() {
100 if (!has_interface<PPB_TCPSocket_Private>()) 107 if (!has_interface<PPB_TCPSocket_Private>())
101 return; 108 return;
102 return get_interface<PPB_TCPSocket_Private>()->Disconnect(pp_resource()); 109 return get_interface<PPB_TCPSocket_Private>()->Disconnect(pp_resource());
103 } 110 }
104 111
105 } // namespace pp 112 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698