diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-22 22:17:22 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-22 22:17:22 +0000 |
commit | b838eeae926063bc732785681300e086bdf2a3db (patch) | |
tree | d740e2008b624682d0c781dea3b1898e31dc0fd0 /ppapi/cpp | |
parent | f384a72559724b6d75ad443734a7bbf797be1828 (diff) | |
download | chromium_src-b838eeae926063bc732785681300e086bdf2a3db.zip chromium_src-b838eeae926063bc732785681300e086bdf2a3db.tar.gz chromium_src-b838eeae926063bc732785681300e086bdf2a3db.tar.bz2 |
Move PPB_TCPSocket out of dev.
BUG=247225
TEST=None
Review URL: https://chromiumcodereview.appspot.com/17314012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208094 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/dev/tcp_socket_dev.cc | 117 | ||||
-rw-r--r-- | ppapi/cpp/tcp_socket.cc | 116 | ||||
-rw-r--r-- | ppapi/cpp/tcp_socket.h (renamed from ppapi/cpp/dev/tcp_socket_dev.h) | 48 |
3 files changed, 140 insertions, 141 deletions
diff --git a/ppapi/cpp/dev/tcp_socket_dev.cc b/ppapi/cpp/dev/tcp_socket_dev.cc deleted file mode 100644 index 03628a8..0000000 --- a/ppapi/cpp/dev/tcp_socket_dev.cc +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ppapi/cpp/dev/tcp_socket_dev.h" - -#include "ppapi/c/pp_errors.h" -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> const char* interface_name<PPB_TCPSocket_Dev_0_1>() { - return PPB_TCPSOCKET_DEV_INTERFACE_0_1; -} - -} // namespace - -TCPSocket_Dev::TCPSocket_Dev() { -} - -TCPSocket_Dev::TCPSocket_Dev(const InstanceHandle& instance) { - if (has_interface<PPB_TCPSocket_Dev_0_1>()) { - PassRefFromConstructor(get_interface<PPB_TCPSocket_Dev_0_1>()->Create( - instance.pp_instance())); - } -} - -TCPSocket_Dev::TCPSocket_Dev(PassRef, PP_Resource resource) - : Resource(PASS_REF, resource) { -} - -TCPSocket_Dev::TCPSocket_Dev(const TCPSocket_Dev& other) : Resource(other) { -} - -TCPSocket_Dev::~TCPSocket_Dev() { -} - -TCPSocket_Dev& TCPSocket_Dev::operator=(const TCPSocket_Dev& other) { - Resource::operator=(other); - return *this; -} - -// static -bool TCPSocket_Dev::IsAvailable() { - return has_interface<PPB_TCPSocket_Dev_0_1>(); -} - -int32_t TCPSocket_Dev::Connect(const NetAddress& addr, - const CompletionCallback& callback) { - if (has_interface<PPB_TCPSocket_Dev_0_1>()) { - return get_interface<PPB_TCPSocket_Dev_0_1>()->Connect( - pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); - } - return callback.MayForce(PP_ERROR_NOINTERFACE); -} - -NetAddress TCPSocket_Dev::GetLocalAddress() const { - if (has_interface<PPB_TCPSocket_Dev_0_1>()) { - return NetAddress( - PASS_REF, - get_interface<PPB_TCPSocket_Dev_0_1>()->GetLocalAddress(pp_resource())); - } - return NetAddress(); -} - -NetAddress TCPSocket_Dev::GetRemoteAddress() const { - if (has_interface<PPB_TCPSocket_Dev_0_1>()) { - return NetAddress( - PASS_REF, - get_interface<PPB_TCPSocket_Dev_0_1>()->GetRemoteAddress( - pp_resource())); - } - return NetAddress(); -} - -int32_t TCPSocket_Dev::Read(char* buffer, - int32_t bytes_to_read, - const CompletionCallback& callback) { - if (has_interface<PPB_TCPSocket_Dev_0_1>()) { - return get_interface<PPB_TCPSocket_Dev_0_1>()->Read( - pp_resource(), buffer, bytes_to_read, - callback.pp_completion_callback()); - } - return callback.MayForce(PP_ERROR_NOINTERFACE); -} - -int32_t TCPSocket_Dev::Write(const char* buffer, - int32_t bytes_to_write, - const CompletionCallback& callback) { - if (has_interface<PPB_TCPSocket_Dev_0_1>()) { - return get_interface<PPB_TCPSocket_Dev_0_1>()->Write( - pp_resource(), buffer, bytes_to_write, - callback.pp_completion_callback()); - } - return callback.MayForce(PP_ERROR_NOINTERFACE); -} - -void TCPSocket_Dev::Close() { - if (has_interface<PPB_TCPSocket_Dev_0_1>()) - get_interface<PPB_TCPSocket_Dev_0_1>()->Close(pp_resource()); -} - -int32_t TCPSocket_Dev::SetOption(PP_TCPSocket_Option_Dev name, - const Var& value, - const CompletionCallback& callback) { - if (has_interface<PPB_TCPSocket_Dev_0_1>()) { - return get_interface<PPB_TCPSocket_Dev_0_1>()->SetOption( - pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); - } - return callback.MayForce(PP_ERROR_NOINTERFACE); -} - -} // namespace pp diff --git a/ppapi/cpp/tcp_socket.cc b/ppapi/cpp/tcp_socket.cc new file mode 100644 index 0000000..f0002fa --- /dev/null +++ b/ppapi/cpp/tcp_socket.cc @@ -0,0 +1,116 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/cpp/tcp_socket.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_TCPSocket_1_0>() { + return PPB_TCPSOCKET_INTERFACE_1_0; +} + +} // namespace + +TCPSocket::TCPSocket() { +} + +TCPSocket::TCPSocket(const InstanceHandle& instance) { + if (has_interface<PPB_TCPSocket_1_0>()) { + PassRefFromConstructor(get_interface<PPB_TCPSocket_1_0>()->Create( + instance.pp_instance())); + } +} + +TCPSocket::TCPSocket(PassRef, PP_Resource resource) + : Resource(PASS_REF, resource) { +} + +TCPSocket::TCPSocket(const TCPSocket& other) : Resource(other) { +} + +TCPSocket::~TCPSocket() { +} + +TCPSocket& TCPSocket::operator=(const TCPSocket& other) { + Resource::operator=(other); + return *this; +} + +// static +bool TCPSocket::IsAvailable() { + return has_interface<PPB_TCPSocket_1_0>(); +} + +int32_t TCPSocket::Connect(const NetAddress& addr, + const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_0>()) { + return get_interface<PPB_TCPSocket_1_0>()->Connect( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +NetAddress TCPSocket::GetLocalAddress() const { + if (has_interface<PPB_TCPSocket_1_0>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_TCPSocket_1_0>()->GetLocalAddress(pp_resource())); + } + return NetAddress(); +} + +NetAddress TCPSocket::GetRemoteAddress() const { + if (has_interface<PPB_TCPSocket_1_0>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_TCPSocket_1_0>()->GetRemoteAddress(pp_resource())); + } + return NetAddress(); +} + +int32_t TCPSocket::Read(char* buffer, + int32_t bytes_to_read, + const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_0>()) { + return get_interface<PPB_TCPSocket_1_0>()->Read( + pp_resource(), buffer, bytes_to_read, + callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t TCPSocket::Write(const char* buffer, + int32_t bytes_to_write, + const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_0>()) { + return get_interface<PPB_TCPSocket_1_0>()->Write( + pp_resource(), buffer, bytes_to_write, + callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +void TCPSocket::Close() { + if (has_interface<PPB_TCPSocket_1_0>()) + get_interface<PPB_TCPSocket_1_0>()->Close(pp_resource()); +} + +int32_t TCPSocket::SetOption(PP_TCPSocket_Option name, + const Var& value, + const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_0>()) { + return get_interface<PPB_TCPSocket_1_0>()->SetOption( + pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +} // namespace pp diff --git a/ppapi/cpp/dev/tcp_socket_dev.h b/ppapi/cpp/tcp_socket.h index 4067bf0..5a5e0f4 100644 --- a/ppapi/cpp/dev/tcp_socket_dev.h +++ b/ppapi/cpp/tcp_socket.h @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_CPP_DEV_TCP_SOCKET_DEV_H_ -#define PPAPI_CPP_DEV_TCP_SOCKET_DEV_H_ +#ifndef PPAPI_CPP_TCP_SOCKET_H_ +#define PPAPI_CPP_TCP_SOCKET_H_ -#include "ppapi/c/dev/ppb_tcp_socket_dev.h" +#include "ppapi/c/ppb_tcp_socket.h" #include "ppapi/cpp/net_address.h" #include "ppapi/cpp/pass_ref.h" #include "ppapi/cpp/resource.h" @@ -15,47 +15,47 @@ namespace pp { class CompletionCallback; class InstanceHandle; -/// The <code>TCPSocket_Dev</code> class provides TCP socket operations. +/// The <code>TCPSocket</code> class provides TCP socket operations. /// /// Permissions: Apps permission <code>socket</code> with subrule /// <code>tcp-connect</code> is required for <code>Connect()</code>. /// For more details about network communication permissions, please see: /// http://developer.chrome.com/apps/app_network.html -class TCPSocket_Dev: public Resource { +class TCPSocket : public Resource { public: - /// Default constructor for creating an is_null() <code>TCPSocket_Dev</code> + /// Default constructor for creating an is_null() <code>TCPSocket</code> /// object. - TCPSocket_Dev(); + TCPSocket(); - /// A constructor used to create a <code>TCPSocket_Dev</code> object. + /// A constructor used to create a <code>TCPSocket</code> object. /// /// @param[in] instance The instance with which this resource will be /// associated. - explicit TCPSocket_Dev(const InstanceHandle& instance); + explicit TCPSocket(const InstanceHandle& instance); /// A constructor used when you have received a <code>PP_Resource</code> as a /// return value that has had 1 ref added for you. /// - /// @param[in] resource A <code>PPB_TCPSocket_Dev</code> resource. - TCPSocket_Dev(PassRef, PP_Resource resource); + /// @param[in] resource A <code>PPB_TCPSocket</code> resource. + TCPSocket(PassRef, PP_Resource resource); - /// The copy constructor for <code>TCPSocket_Dev</code>. + /// The copy constructor for <code>TCPSocket</code>. /// - /// @param[in] other A reference to another <code>TCPSocket_Dev</code>. - TCPSocket_Dev(const TCPSocket_Dev& other); + /// @param[in] other A reference to another <code>TCPSocket</code>. + TCPSocket(const TCPSocket& other); /// The destructor. - virtual ~TCPSocket_Dev(); + virtual ~TCPSocket(); - /// The assignment operator for <code>TCPSocket_Dev</code>. + /// The assignment operator for <code>TCPSocket</code>. /// - /// @param[in] other A reference to another <code>TCPSocket_Dev</code>. + /// @param[in] other A reference to another <code>TCPSocket</code>. /// - /// @return A reference to this <code>TCPSocket_Dev</code> object. - TCPSocket_Dev& operator=(const TCPSocket_Dev& other); + /// @return A reference to this <code>TCPSocket</code> object. + TCPSocket& operator=(const TCPSocket& other); /// Static function for determining whether the browser supports the - /// <code>PPB_TCPSocket_Dev</code> interface. + /// <code>PPB_TCPSocket</code> interface. /// /// @return true if the interface is available, false otherwise. static bool IsAvailable(); @@ -101,7 +101,7 @@ class TCPSocket_Dev: public Resource { /// of your class. When your class goes out of scope, the callback factory /// will not actually cancel the operation, but will rather just skip issuing /// the callback on your class. This means that if the underlying - /// <code>PPB_TCPSocket_Dev</code> resource outlives your class, the browser + /// <code>PPB_TCPSocket</code> resource outlives your class, the browser /// will still try to write into your buffer when the operation completes. /// The buffer must be kept valid until then to avoid memory corruption. /// If you want to release the buffer while the <code>Read()</code> call is @@ -146,7 +146,7 @@ class TCPSocket_Dev: public Resource { void Close(); /// Sets a socket option on the TCP socket. - /// Please see the <code>PP_TCPSocket_Option_Dev</code> description for option + /// Please see the <code>PP_TCPSocket_Option</code> description for option /// names, value types and allowed values. /// /// @param[in] name The option to set. @@ -156,11 +156,11 @@ class TCPSocket_Dev: public Resource { /// /// @return An int32_t containing an error code from <code>pp_errors.h</code>. //// - int32_t SetOption(PP_TCPSocket_Option_Dev name, + int32_t SetOption(PP_TCPSocket_Option name, const Var& value, const CompletionCallback& callback); }; } // namespace pp -#endif // PPAPI_CPP_DEV_TCP_SOCKET__DevDEV_H_ +#endif // PPAPI_CPP_TCP_SOCKET_H_ |