diff options
author | toyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 09:42:41 +0000 |
---|---|---|
committer | toyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 09:42:41 +0000 |
commit | 5350822e0ce84c1284f0631ff5f3e6cce81d9e21 (patch) | |
tree | 16c186ef578dc1eb0385bd814f678d5d0d9d3379 /ppapi | |
parent | 5ffb0a4c1abc6ca5e2261d40ef19a216e86265e4 (diff) | |
download | chromium_src-5350822e0ce84c1284f0631ff5f3e6cce81d9e21.zip chromium_src-5350822e0ce84c1284f0631ff5f3e6cce81d9e21.tar.gz chromium_src-5350822e0ce84c1284f0631ff5f3e6cce81d9e21.tar.bz2 |
WebSocket Pepper API: make the API out of dev
BUG=87310
TEST=ui_test
Review URL: http://codereview.chromium.org/9192009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
22 files changed, 253 insertions, 105 deletions
diff --git a/ppapi/api/dev/ppb_websocket_dev.idl b/ppapi/api/ppb_websocket.idl index 0a68e7c..7dd42b1 100644 --- a/ppapi/api/dev/ppb_websocket_dev.idl +++ b/ppapi/api/ppb_websocket.idl @@ -4,10 +4,10 @@ */ /** - * This file defines the <code>PPB_WebSocket_Dev</code> interface. + * This file defines the <code>PPB_WebSocket</code> interface. */ label Chrome { - M17 = 0.1 + M18 = 1.0 }; @@ -17,34 +17,34 @@ label Chrome { * GetReadyState() returns one of these states. */ [assert_size(4)] -enum PP_WebSocketReadyState_Dev { +enum PP_WebSocketReadyState { /** * Ready state is queried on an invalid resource. */ - PP_WEBSOCKETREADYSTATE_INVALID_DEV = -1, + PP_WEBSOCKETREADYSTATE_INVALID = -1, /** * Ready state that the connection has not yet been established. */ - PP_WEBSOCKETREADYSTATE_CONNECTING_DEV = 0, + PP_WEBSOCKETREADYSTATE_CONNECTING = 0, /** * Ready state that the WebSocket connection is established and communication * is possible. */ - PP_WEBSOCKETREADYSTATE_OPEN_DEV = 1, + PP_WEBSOCKETREADYSTATE_OPEN = 1, /** * Ready state that the connection is going through the closing handshake. */ - PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2, + PP_WEBSOCKETREADYSTATE_CLOSING = 2, /** * Ready state that the connection has been closed or could not be opened. */ - PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3 + PP_WEBSOCKETREADYSTATE_CLOSED = 3 }; -interface PPB_WebSocket_Dev { +interface PPB_WebSocket { /** * Create() creates a WebSocket instance. * @@ -64,9 +64,9 @@ interface PPB_WebSocket_Dev { * WebSocket. * * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a - * <code>PPB_WebSocket_Dev</code>, <code>PP_FALSE</code> if the + * <code>PPB_WebSocket</code>, <code>PP_FALSE</code> if the * <code>resource</code> is invalid or some type other than - * <code>PPB_WebSocket_Dev</code>. + * <code>PPB_WebSocket</code>. */ PP_Bool IsWebSocket([in] PP_Resource resource); @@ -158,7 +158,7 @@ interface PPB_WebSocket_Dev { * <code>message</code>. The <code>message</code> must remain valid until * the ReceiveMessage operation completes. Its <code>PP_VarType</code> * will be <code>PP_VARTYPE_STRING</code> or - * <code>PP_VARTYPE_ARRAY_BYFFER</code> on receiving. + * <code>PP_VARTYPE_ARRAY_BUFFER</code> on receiving. * * @param[in] callback A <code>PP_CompletionCallback</code> which is called * when the receiving message is completed. It is ignored if ReceiveMessage @@ -187,8 +187,8 @@ interface PPB_WebSocket_Dev { * * @return An int32_t containing an error code from <code>pp_errors.h</code>. * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is - * <code>PP_WEBSOCKETREADYSTATE_CONNECTING_DEV</code>. It corresponds - * JavaScript InvalidStateError of the specification. + * <code>PP_WEBSOCKETREADYSTATE_CONNECTING</code>. It corresponds JavaScript + * InvalidStateError of the specification. * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code> * of string type contains an invalid character as a UTF-8 string. It * corresponds to JavaScript SyntaxError of the specification. @@ -282,10 +282,10 @@ interface PPB_WebSocket_Dev { * @param[in] web_socket A <code>PP_Resource</code> corresponding to a * WebSocket. * - * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called + * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID</code> if called * before connect() is called, or called on an invalid resource. */ - PP_WebSocketReadyState_Dev GetReadyState([in] PP_Resource web_socket); + PP_WebSocketReadyState GetReadyState([in] PP_Resource web_socket); /** * GetURL() returns the URL associated with specified WebSocket connection. diff --git a/ppapi/c/dev/ppb_websocket_dev.h b/ppapi/c/ppb_websocket.h index 2a6f78b..9124c28 100644 --- a/ppapi/c/dev/ppb_websocket_dev.h +++ b/ppapi/c/ppb_websocket.h @@ -3,10 +3,10 @@ * found in the LICENSE file. */ -/* From dev/ppb_websocket_dev.idl modified Fri Jan 27 10:09:34 2012. */ +/* From ppb_websocket.idl modified Fri Jan 27 15:51:19 2012. */ -#ifndef PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ -#define PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ +#ifndef PPAPI_C_PPB_WEBSOCKET_H_ +#define PPAPI_C_PPB_WEBSOCKET_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" @@ -16,12 +16,12 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_WEBSOCKET_DEV_INTERFACE_0_1 "PPB_WebSocket(Dev);0.1" -#define PPB_WEBSOCKET_DEV_INTERFACE PPB_WEBSOCKET_DEV_INTERFACE_0_1 +#define PPB_WEBSOCKET_INTERFACE_1_0 "PPB_WebSocket;1.0" +#define PPB_WEBSOCKET_INTERFACE PPB_WEBSOCKET_INTERFACE_1_0 /** * @file - * This file defines the <code>PPB_WebSocket_Dev</code> interface. + * This file defines the <code>PPB_WebSocket</code> interface. */ @@ -38,26 +38,26 @@ typedef enum { /** * Ready state is queried on an invalid resource. */ - PP_WEBSOCKETREADYSTATE_INVALID_DEV = -1, + PP_WEBSOCKETREADYSTATE_INVALID = -1, /** * Ready state that the connection has not yet been established. */ - PP_WEBSOCKETREADYSTATE_CONNECTING_DEV = 0, + PP_WEBSOCKETREADYSTATE_CONNECTING = 0, /** * Ready state that the WebSocket connection is established and communication * is possible. */ - PP_WEBSOCKETREADYSTATE_OPEN_DEV = 1, + PP_WEBSOCKETREADYSTATE_OPEN = 1, /** * Ready state that the connection is going through the closing handshake. */ - PP_WEBSOCKETREADYSTATE_CLOSING_DEV = 2, + PP_WEBSOCKETREADYSTATE_CLOSING = 2, /** * Ready state that the connection has been closed or could not be opened. */ - PP_WEBSOCKETREADYSTATE_CLOSED_DEV = 3 -} PP_WebSocketReadyState_Dev; -PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState_Dev, 4); + PP_WEBSOCKETREADYSTATE_CLOSED = 3 +} PP_WebSocketReadyState; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState, 4); /** * @} */ @@ -66,7 +66,7 @@ PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_WebSocketReadyState_Dev, 4); * @addtogroup Interfaces * @{ */ -struct PPB_WebSocket_Dev_0_1 { +struct PPB_WebSocket_1_0 { /** * Create() creates a WebSocket instance. * @@ -85,9 +85,9 @@ struct PPB_WebSocket_Dev_0_1 { * WebSocket. * * @return Returns <code>PP_TRUE</code> if <code>resource</code> is a - * <code>PPB_WebSocket_Dev</code>, <code>PP_FALSE</code> if the + * <code>PPB_WebSocket</code>, <code>PP_FALSE</code> if the * <code>resource</code> is invalid or some type other than - * <code>PPB_WebSocket_Dev</code>. + * <code>PPB_WebSocket</code>. */ PP_Bool (*IsWebSocket)(PP_Resource resource); /** @@ -176,7 +176,7 @@ struct PPB_WebSocket_Dev_0_1 { * <code>message</code>. The <code>message</code> must remain valid until * the ReceiveMessage operation completes. Its <code>PP_VarType</code> * will be <code>PP_VARTYPE_STRING</code> or - * <code>PP_VARTYPE_ARRAY_BYFFER</code> on receiving. + * <code>PP_VARTYPE_ARRAY_BUFFER</code> on receiving. * * @param[in] callback A <code>PP_CompletionCallback</code> which is called * when the receiving message is completed. It is ignored if ReceiveMessage @@ -204,8 +204,8 @@ struct PPB_WebSocket_Dev_0_1 { * * @return An int32_t containing an error code from <code>pp_errors.h</code>. * Returns <code>PP_ERROR_FAILED</code> if the ReadyState is - * <code>PP_WEBSOCKETREADYSTATE_CONNECTING_DEV</code>. It corresponds - * JavaScript InvalidStateError of the specification. + * <code>PP_WEBSOCKETREADYSTATE_CONNECTING</code>. It corresponds JavaScript + * InvalidStateError of the specification. * Returns <code>PP_ERROR_BADARGUMENT</code> if provided <code>message</code> * of string type contains an invalid character as a UTF-8 string. It * corresponds to JavaScript SyntaxError of the specification. @@ -291,10 +291,10 @@ struct PPB_WebSocket_Dev_0_1 { * @param[in] web_socket A <code>PP_Resource</code> corresponding to a * WebSocket. * - * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called + * @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID</code> if called * before connect() is called, or called on an invalid resource. */ - PP_WebSocketReadyState_Dev (*GetReadyState)(PP_Resource web_socket); + PP_WebSocketReadyState (*GetReadyState)(PP_Resource web_socket); /** * GetURL() returns the URL associated with specified WebSocket connection. * @@ -308,10 +308,10 @@ struct PPB_WebSocket_Dev_0_1 { struct PP_Var (*GetURL)(PP_Resource web_socket); }; -typedef struct PPB_WebSocket_Dev_0_1 PPB_WebSocket_Dev; +typedef struct PPB_WebSocket_1_0 PPB_WebSocket; /** * @} */ -#endif /* PPAPI_C_DEV_PPB_WEBSOCKET_DEV_H_ */ +#endif /* PPAPI_C_PPB_WEBSOCKET_H_ */ diff --git a/ppapi/cpp/websocket.cc b/ppapi/cpp/websocket.cc new file mode 100644 index 0000000..2a65370 --- /dev/null +++ b/ppapi/cpp/websocket.cc @@ -0,0 +1,148 @@ +// Copyright (c) 2012 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/websocket.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/var.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_WebSocket>() { + return PPB_WEBSOCKET_INTERFACE; +} + +} // namespace + +WebSocket::WebSocket(Instance* instance) { + if (!has_interface<PPB_WebSocket>()) + return; + PassRefFromConstructor(get_interface<PPB_WebSocket>()->Create( + instance->pp_instance())); +} + +WebSocket::~WebSocket() { +} + +int32_t WebSocket::Connect(const Var& url, const Var protocols[], + uint32_t protocol_count, const CompletionCallback& callback) { + if (!has_interface<PPB_WebSocket>()) + return PP_ERROR_BADRESOURCE; + + // Convert protocols to C interface. + PP_Var *c_protocols = NULL; + if (protocol_count) { + c_protocols = new PP_Var[protocol_count]; + if (!c_protocols) + return PP_ERROR_NOMEMORY; + } + for (uint32_t i = 0; i < protocol_count; ++i) + c_protocols[i] = protocols[i].pp_var(); + + int32_t result = get_interface<PPB_WebSocket>()->Connect( + pp_resource(), url.pp_var(), c_protocols, protocol_count, + callback.pp_completion_callback()); + if (c_protocols) + delete[] c_protocols; + return result; +} + +int32_t WebSocket::Close(uint16_t code, const Var& reason, + const CompletionCallback& callback) { + if (!has_interface<PPB_WebSocket>()) + return PP_ERROR_BADRESOURCE; + + return get_interface<PPB_WebSocket>()->Close( + pp_resource(), code, reason.pp_var(), + callback.pp_completion_callback()); +} + +int32_t WebSocket::ReceiveMessage(Var* message, + const CompletionCallback& callback) { + if (!has_interface<PPB_WebSocket>()) + return PP_ERROR_BADRESOURCE; + + return get_interface<PPB_WebSocket>()->ReceiveMessage( + pp_resource(), const_cast<PP_Var*>(&message->pp_var()), + callback.pp_completion_callback()); +} + +int32_t WebSocket::SendMessage(const Var& message) { + if (!has_interface<PPB_WebSocket>()) + return PP_ERROR_BADRESOURCE; + + return get_interface<PPB_WebSocket>()->SendMessage( + pp_resource(), message.pp_var()); +} + +uint64_t WebSocket::GetBufferedAmount() { + if (!has_interface<PPB_WebSocket>()) + return 0; + + return get_interface<PPB_WebSocket>()->GetBufferedAmount(pp_resource()); +} + +uint16_t WebSocket::GetCloseCode() { + if (!has_interface<PPB_WebSocket>()) + return 0; + + return get_interface<PPB_WebSocket>()->GetCloseCode(pp_resource()); +} + +Var WebSocket::GetCloseReason() { + if (!has_interface<PPB_WebSocket>()) + return 0; + + return Var(Var::PassRef(), + get_interface<PPB_WebSocket>()->GetCloseReason(pp_resource())); +} + +bool WebSocket::GetCloseWasClean() { + if (!has_interface<PPB_WebSocket>()) + return false; + + PP_Bool result = + get_interface<PPB_WebSocket>()->GetCloseWasClean(pp_resource()); + return PP_ToBool(result); +} + +Var WebSocket::GetExtensions() { + if (!has_interface<PPB_WebSocket>()) + return Var(); + + return Var(Var::PassRef(), + get_interface<PPB_WebSocket>()->GetExtensions(pp_resource())); +} + +Var WebSocket::GetProtocol() { + if (!has_interface<PPB_WebSocket>()) + return Var(); + + return Var(Var::PassRef(), + get_interface<PPB_WebSocket>()->GetProtocol(pp_resource())); +} + +PP_WebSocketReadyState WebSocket::GetReadyState() { + if (!has_interface<PPB_WebSocket>()) + return PP_WEBSOCKETREADYSTATE_INVALID; + + return get_interface<PPB_WebSocket>()->GetReadyState(pp_resource()); +} + +Var WebSocket::GetURL() { + if (!has_interface<PPB_WebSocket>()) + return Var(); + + return Var(Var::PassRef(), + get_interface<PPB_WebSocket>()->GetURL(pp_resource())); +} + +} // namespace pp diff --git a/ppapi/cpp/dev/websocket_dev.h b/ppapi/cpp/websocket.h index e1de536..61e61df 100644 --- a/ppapi/cpp/dev/websocket_dev.h +++ b/ppapi/cpp/websocket.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ -#define PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ +#ifndef PPAPI_CPP_WEBSOCKET_H_ +#define PPAPI_CPP_WEBSOCKET_H_ -#include "ppapi/c/dev/ppb_websocket_dev.h" +#include "ppapi/c/ppb_websocket.h" #include "ppapi/cpp/resource.h" /// @file -/// This file defines the WebSocket_Dev interface. +/// This file defines the WebSocket interface. namespace pp { @@ -17,14 +17,14 @@ class CompletionCallback; class Instance; class Var; -/// The <code>WebSocket_Dev</code> class -class WebSocket_Dev : public Resource { +/// The <code>WebSocket</code> class +class WebSocket : public Resource { public: - /// Constructs a WebSocket_Dev object. - WebSocket_Dev(Instance* instance); + /// Constructs a WebSocket object. + WebSocket(Instance* instance); - /// Destructs a WebSocket_Dev object. - virtual ~WebSocket_Dev(); + /// Destructs a WebSocket object. + virtual ~WebSocket(); /// Connect() connects to the specified WebSocket server. Caller can call /// this method at most once. @@ -112,8 +112,8 @@ class WebSocket_Dev : public Resource { /// @return An int32_t containing an error code from /// <code>pp_errors.h</code>. /// Returns <code>PP_ERROR_FAILED</code> if the ReadyState is - /// <code>PP_WEBSOCKETREADYSTATE_CONNECTING_DEV</code>. It corresponds - /// JavaScript InvalidStateError of the specification. + /// <code>PP_WEBSOCKETREADYSTATE_CONNECTING</code>. It corresponds JavaScript + /// InvalidStateError of the specification. /// Returns <code>PP_ERROR_BADARGUMENT</code> if provided /// <code>message</code> of string type contains an invalid character as a /// UTF-8 string. It corresponds to JavaScript SyntaxError of the @@ -169,9 +169,9 @@ class WebSocket_Dev : public Resource { /// GetReadyState() returns the ready state of the specified WebSocket /// connection. /// - /// @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID_DEV</code> if called + /// @return Returns <code>PP_WEBSOCKETREADYSTATE_INVALID</code> if called /// before connect() is called. - PP_WebSocketReadyState_Dev GetReadyState(); + PP_WebSocketReadyState GetReadyState(); /// GetURL() returns the URL associated with specified WebSocket connection. /// @@ -182,4 +182,4 @@ class WebSocket_Dev : public Resource { } // namespace pp -#endif // PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ +#endif // PPAPI_CPP_WEBSOCKET_H_ diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc index 284e56d..9eb4215bd 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.cc @@ -416,10 +416,10 @@ const PPB_View* PPBViewInterface() { return ppb; } -const PPB_WebSocket_Dev* PPBWebSocketInterface() { - static const PPB_WebSocket_Dev* ppb = - static_cast<const PPB_WebSocket_Dev*>( - GetBrowserInterfaceSafe(PPB_WEBSOCKET_DEV_INTERFACE)); +const PPB_WebSocket* PPBWebSocketInterface() { + static const PPB_WebSocket* ppb = + static_cast<const PPB_WebSocket*>( + GetBrowserInterfaceSafe(PPB_WEBSOCKET_INTERFACE)); return ppb; } diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h index 913cf10..19ffd4f 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h @@ -12,7 +12,6 @@ #include "ppapi/c/dev/ppb_memory_dev.h" #include "ppapi/c/dev/ppb_scrollbar_dev.h" #include "ppapi/c/dev/ppb_testing_dev.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" #include "ppapi/c/dev/ppb_widget_dev.h" #include "ppapi/c/dev/ppb_zoom_dev.h" #include "ppapi/c/pp_instance.h" @@ -36,6 +35,7 @@ #include "ppapi/c/ppb_var.h" #include "ppapi/c/ppb_var_array_buffer.h" #include "ppapi/c/ppb_view.h" +#include "ppapi/c/ppb_websocket.h" #include "ppapi/c/private/ppb_net_address_private.h" #include "ppapi/c/private/ppb_pdf.h" #include "ppapi/c/private/ppb_tcp_socket_private.h" @@ -133,7 +133,7 @@ const PPB_Var* PPBVarInterface(); // shared const PPB_VarArrayBuffer* PPBVarArrayBufferInterface(); // shared const PPB_View* PPBViewInterface(); const PPB_WheelInputEvent* PPBWheelInputEventInterface(); -const PPB_WebSocket_Dev* PPBWebSocketInterface(); +const PPB_WebSocket* PPBWebSocketInterface(); const PPB_Widget_Dev* PPBWidgetInterface(); const PPB_Zoom_Dev* PPBZoomInterface(); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_websocket_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_websocket_rpc_server.cc index d59997b..65c0877 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_websocket_rpc_server.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_websocket_rpc_server.cc @@ -11,8 +11,8 @@ #include "native_client/src/shared/ppapi_proxy/utility.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" #include "srpcgen/ppb_rpc.h" +#include "ppapi/c/ppb_websocket.h" using ppapi_proxy::DebugPrintf; using ppapi_proxy::DeleteRemoteCallbackInfo; diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.cc index 493cacb..b8ef392 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.cc @@ -90,9 +90,9 @@ const PPB_VarArrayBuffer* PPBVarArrayBufferInterface() { GetBrowserInterfaceSafe(PPB_VAR_ARRAY_BUFFER_INTERFACE)); } -const PPB_WebSocket_Dev* PPBWebSocketInterface() { - return static_cast<const PPB_WebSocket_Dev*>( - GetBrowserInterfaceSafe(PPB_WEBSOCKET_DEV_INTERFACE)); +const PPB_WebSocket* PPBWebSocketInterface() { + return static_cast<const PPB_WebSocket*>( + GetBrowserInterfaceSafe(PPB_WEBSOCKET_INTERFACE)); } // Plugin interface helpers diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h index fbcba2d..600f098 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_globals.h @@ -6,7 +6,6 @@ #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_GLOBALS_H_ #include "ppapi/c/dev/ppb_memory_dev.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" #include "ppapi/c/dev/ppp_find_dev.h" #include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/c/dev/ppp_scrollbar_dev.h" @@ -18,6 +17,7 @@ #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_var.h" #include "ppapi/c/ppb_var_array_buffer.h" +#include "ppapi/c/ppb_websocket.h" #include "ppapi/c/ppp_input_event.h" #include "ppapi/c/ppp_instance.h" #include "ppapi/c/ppp_messaging.h" @@ -56,7 +56,7 @@ const PPB_Core* PPBCoreInterface(); // shared const PPB_Memory_Dev* PPBMemoryInterface(); // shared const PPB_Var* PPBVarInterface(); // shared const PPB_VarArrayBuffer* PPBVarArrayBufferInterface(); // shared -const PPB_WebSocket_Dev* PPBWebSocketInterface(); +const PPB_WebSocket* PPBWebSocketInterface(); // Support for getting PPP_ plugin interfaces. // Safe version CHECK's for NULL. diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc index 1efbab9..8d1734d 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb.cc @@ -103,7 +103,7 @@ InterfaceMapElement interface_map[] = { { PPB_VAR_INTERFACE, PluginVar::GetInterface(), true }, { PPB_VAR_INTERFACE_1_0, PluginVar::GetInterface1_0(), true }, { PPB_VIEW_INTERFACE, PluginView::GetInterface(), true }, - { PPB_WEBSOCKET_DEV_INTERFACE, PluginWebSocket::GetInterface(), + { PPB_WEBSOCKET_INTERFACE, PluginWebSocket::GetInterface(), true }, { PPB_WHEEL_INPUT_EVENT_INTERFACE, PluginInputEvent::GetWheelInterface(), true }, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.cc index 56b4de2..1fdbf2c 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.cc +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.cc @@ -13,7 +13,7 @@ #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_var.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" +#include "ppapi/c/ppb_websocket.h" #include "srpcgen/ppb_rpc.h" namespace ppapi_proxy { @@ -267,7 +267,7 @@ PP_Var GetProtocol(PP_Resource ws) { return PP_MakeUndefined(); } -PP_WebSocketReadyState_Dev GetReadyState(PP_Resource ws) { +PP_WebSocketReadyState GetReadyState(PP_Resource ws) { DebugPrintf( "PPB_WebSocket::GetReadyState: ws=%"NACL_PRId32"\n", ws); @@ -279,8 +279,8 @@ PP_WebSocketReadyState_Dev GetReadyState(PP_Resource ws) { NaClSrpcErrorString(srpc_result)); if (srpc_result != NACL_SRPC_RESULT_OK) - return PP_WEBSOCKETREADYSTATE_INVALID_DEV; - return static_cast<PP_WebSocketReadyState_Dev>(ready_state); + return PP_WEBSOCKETREADYSTATE_INVALID; + return static_cast<PP_WebSocketReadyState>(ready_state); } PP_Var GetURL(PP_Resource ws) { @@ -305,8 +305,8 @@ PP_Var GetURL(PP_Resource ws) { } // namespace -const PPB_WebSocket_Dev* PluginWebSocket::GetInterface() { - static const PPB_WebSocket_Dev websocket_interface = { +const PPB_WebSocket* PluginWebSocket::GetInterface() { + static const PPB_WebSocket websocket_interface = { &Create, &IsWebSocket, &Connect, diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.h b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.h index fb209ac..285ec36 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.h +++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_websocket.h @@ -6,14 +6,14 @@ #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PLUGIN_WEBSOCKET_H_ #include "native_client/src/include/nacl_macros.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" +#include "ppapi/c/ppb_websocket.h" namespace ppapi_proxy { // Implements the untrusted side of the PPB_WebSocket interface. class PluginWebSocket { public: - static const PPB_WebSocket_Dev* GetInterface(); + static const PPB_WebSocket* GetInterface(); private: NACL_DISALLOW_COPY_AND_ASSIGN(PluginWebSocket); diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_websocket.srpc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_websocket.srpc index 6c6fe49..9b9c665 100644 --- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_websocket.srpc +++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_websocket.srpc @@ -2,8 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # -# RPC methods used to implement PPB_WebSocket_Dev calls from the plugin. -# See ppapi/c/dev/ppb_websocket_dev.h for interface details. +# RPC methods used to implement PPB_WebSocket calls from the plugin. +# See ppapi/c/ppb_websocket.h for interface details. { 'name': 'PpbWebSocketRpc', diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index 3f69a6c..7c9e664 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -43,6 +43,7 @@ 'c/ppb_var.h', 'c/ppb_var_array_buffer.h', 'c/ppb_view.h', + 'c/ppb_websocket.h', 'c/ppp.h', 'c/ppp_graphics_3d.h', 'c/ppp_input_event.h', @@ -72,7 +73,6 @@ 'c/dev/ppb_testing_dev.h', 'c/dev/ppb_url_util_dev.h', 'c/dev/ppb_video_decoder_dev.h', - 'c/dev/ppb_websocket_dev.h', 'c/dev/ppb_widget_dev.h', 'c/dev/ppb_zoom_dev.h', 'c/dev/ppp_cursor_control_dev.h', @@ -173,6 +173,8 @@ 'cpp/var_array_buffer.h', 'cpp/view.cc', 'cpp/view.h', + 'cpp/websocket.cc', + 'cpp/websocket.h', # Dev interfaces. 'cpp/dev/audio_input_dev.cc', @@ -219,8 +221,6 @@ 'cpp/dev/video_decoder_client_dev.h', 'cpp/dev/video_decoder_dev.cc', 'cpp/dev/video_decoder_dev.h', - 'cpp/dev/websocket_dev.cc', - 'cpp/dev/websocket_dev.h', 'cpp/dev/widget_client_dev.cc', 'cpp/dev/widget_client_dev.h', 'cpp/dev/widget_dev.cc', diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h index 46f2fcf..b3d96f0 100644 --- a/ppapi/tests/all_c_includes.h +++ b/ppapi/tests/all_c_includes.h @@ -35,7 +35,6 @@ #include "ppapi/c/dev/ppb_var_deprecated.h" #include "ppapi/c/dev/ppb_video_decoder_dev.h" #include "ppapi/c/dev/ppb_video_layer_dev.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" #include "ppapi/c/dev/ppb_widget_dev.h" #include "ppapi/c/dev/ppb_zoom_dev.h" #include "ppapi/c/dev/ppp_class_deprecated.h" @@ -84,6 +83,7 @@ #include "ppapi/c/ppb_url_request_info.h" #include "ppapi/c/ppb_url_response_info.h" #include "ppapi/c/ppb_var_array_buffer.h" +#include "ppapi/c/ppb_websocket.h" #include "ppapi/c/ppp.h" #include "ppapi/c/ppp_graphics_3d.h" #include "ppapi/c/ppp_input_event.h" diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h index 481d627..5416a36 100644 --- a/ppapi/tests/all_cpp_includes.h +++ b/ppapi/tests/all_cpp_includes.h @@ -31,7 +31,6 @@ #include "ppapi/cpp/dev/transport_dev.h" #include "ppapi/cpp/dev/url_util_dev.h" #include "ppapi/cpp/dev/video_decoder_dev.h" -#include "ppapi/cpp/dev/websocket_dev.h" #include "ppapi/cpp/dev/widget_client_dev.h" #include "ppapi/cpp/dev/widget_dev.h" #include "ppapi/cpp/dev/zoom_dev.h" @@ -59,6 +58,7 @@ #include "ppapi/cpp/url_response_info.h" #include "ppapi/cpp/var.h" #include "ppapi/cpp/var_array_buffer.h" +#include "ppapi/cpp/websocket.h" #include "ppapi/utility/graphics/paint_aggregator.h" #include "ppapi/utility/graphics/paint_manager.h" #include "ppapi/utility/non_thread_safe_ref_count.h" diff --git a/ppapi/tests/test_websocket.cc b/ppapi/tests/test_websocket.cc index 91f6379..8eeeac2 100644 --- a/ppapi/tests/test_websocket.cc +++ b/ppapi/tests/test_websocket.cc @@ -8,16 +8,16 @@ #include <vector> #include "ppapi/c/dev/ppb_testing_dev.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_var.h" #include "ppapi/c/ppb_var_array_buffer.h" -#include "ppapi/cpp/dev/websocket_dev.h" +#include "ppapi/c/ppb_websocket.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" +#include "ppapi/cpp/websocket.h" #include "ppapi/tests/test_utils.h" #include "ppapi/tests/testing_instance.h" @@ -49,8 +49,8 @@ const uint64_t kMessageFrameOverhead = 6; REGISTER_TEST_CASE(WebSocket); bool TestWebSocket::Init() { - websocket_interface_ = static_cast<const PPB_WebSocket_Dev*>( - pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_DEV_INTERFACE)); + websocket_interface_ = static_cast<const PPB_WebSocket*>( + pp::Module::Get()->GetBrowserInterface(PPB_WEBSOCKET_INTERFACE)); var_interface_ = static_cast<const PPB_Var*>( pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE)); arraybuffer_interface_ = static_cast<const PPB_VarArrayBuffer*>( @@ -189,9 +189,9 @@ std::string TestWebSocket::TestUninitializedPropertiesAccess() { ASSERT_TRUE(AreEqualWithString(protocol, "")); ReleaseVar(protocol); - PP_WebSocketReadyState_Dev ready_state = + PP_WebSocketReadyState ready_state = websocket_interface_->GetReadyState(ws); - ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID_DEV, ready_state); + ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID, ready_state); PP_Var url = websocket_interface_->GetURL(ws); ASSERT_TRUE(AreEqualWithString(url, "")); @@ -519,12 +519,12 @@ std::string TestWebSocket::TestBufferedAmount() { result = websocket_interface_->Close(ws, kCloseCodeNormalClosure, reason, static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); ASSERT_EQ(PP_OK_COMPLETIONPENDING, result); - ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSING_DEV, + ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSING, websocket_interface_->GetReadyState(ws)); result = callback.WaitForResult(); ASSERT_EQ(PP_OK, result); - ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, + ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, websocket_interface_->GetReadyState(ws)); uint64_t base_buffered_amount = websocket_interface_->GetBufferedAmount(ws); @@ -555,7 +555,7 @@ std::string TestWebSocket::TestBufferedAmount() { std::string TestWebSocket::TestCcInterfaces() { // C++ bindings is simple straightforward, then just verifies interfaces work // as a interface bridge fine. - pp::WebSocket_Dev ws(instance_); + pp::WebSocket ws(instance_); // Check uninitialized properties access. ASSERT_EQ(0, ws.GetBufferedAmount()); @@ -564,7 +564,7 @@ std::string TestWebSocket::TestCcInterfaces() { ASSERT_EQ(false, ws.GetCloseWasClean()); ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); - ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID_DEV, ws.GetReadyState()); + ASSERT_EQ(PP_WEBSOCKETREADYSTATE_INVALID, ws.GetReadyState()); ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), "")); // Check communication interfaces (connect, send, receive, and close). @@ -619,7 +619,7 @@ std::string TestWebSocket::TestCcInterfaces() { ASSERT_EQ(true, ws.GetCloseWasClean()); ASSERT_TRUE(AreEqualWithString(ws.GetExtensions().pp_var(), "")); ASSERT_TRUE(AreEqualWithString(ws.GetProtocol().pp_var(), "")); - ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED_DEV, ws.GetReadyState()); + ASSERT_EQ(PP_WEBSOCKETREADYSTATE_CLOSED, ws.GetReadyState()); ASSERT_TRUE(AreEqualWithString(ws.GetURL().pp_var(), kCloseServerURL)); PASS(); diff --git a/ppapi/tests/test_websocket.h b/ppapi/tests/test_websocket.h index 43c56cb..f63d717 100644 --- a/ppapi/tests/test_websocket.h +++ b/ppapi/tests/test_websocket.h @@ -7,10 +7,10 @@ #include <string> -#include "ppapi/c/dev/ppb_websocket_dev.h" #include "ppapi/c/ppb_core.h" #include "ppapi/c/ppb_var.h" #include "ppapi/c/ppb_var_array_buffer.h" +#include "ppapi/c/ppb_websocket.h" #include "ppapi/tests/test_case.h" class TestWebSocket : public TestCase { @@ -48,7 +48,7 @@ class TestWebSocket : public TestCase { std::string TestCcInterfaces(); // Used by the tests that access the C API directly. - const PPB_WebSocket_Dev* websocket_interface_; + const PPB_WebSocket* websocket_interface_; const PPB_Var* var_interface_; const PPB_VarArrayBuffer* arraybuffer_interface_; const PPB_Core* core_interface_; diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index bfc828e..9a2ad23 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -64,8 +64,8 @@ PROXIED_IFACE(PPB_VideoDecoder, PPB_VIDEODECODER_DEV_INTERFACE_0_16, PPB_VideoDecoder_Dev_0_16) UNPROXIED_IFACE(PPB_VideoLayer, PPB_VIDEOLAYER_DEV_INTERFACE_0_1, PPB_VideoLayer_Dev_0_1) -UNPROXIED_IFACE(PPB_WebSocket, PPB_WEBSOCKET_DEV_INTERFACE_0_1, - PPB_WebSocket_Dev_0_1) +UNPROXIED_IFACE(PPB_WebSocket, PPB_WEBSOCKET_INTERFACE_1_0, + PPB_WebSocket_1_0) UNPROXIED_IFACE(PPB_Widget, PPB_WIDGET_DEV_INTERFACE_0_3, PPB_Widget_Dev_0_3) #include "ppapi/thunk/interfaces_postamble.h" diff --git a/ppapi/thunk/ppb_websocket_api.h b/ppapi/thunk/ppb_websocket_api.h index 867550d..c769cec 100644 --- a/ppapi/thunk/ppb_websocket_api.h +++ b/ppapi/thunk/ppb_websocket_api.h @@ -6,7 +6,7 @@ #define PPAPI_THUNK_WEBSOCKET_API_H_ #include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" +#include "ppapi/c/ppb_websocket.h" namespace ppapi { namespace thunk { @@ -31,7 +31,7 @@ class PPB_WebSocket_API { virtual PP_Bool GetCloseWasClean() = 0; virtual PP_Var GetExtensions() = 0; virtual PP_Var GetProtocol() = 0; - virtual PP_WebSocketReadyState_Dev GetReadyState() = 0; + virtual PP_WebSocketReadyState GetReadyState() = 0; virtual PP_Var GetURL() = 0; }; diff --git a/ppapi/thunk/ppb_websocket_thunk.cc b/ppapi/thunk/ppb_websocket_thunk.cc index ea67f84..1fcae10 100644 --- a/ppapi/thunk/ppb_websocket_thunk.cc +++ b/ppapi/thunk/ppb_websocket_thunk.cc @@ -110,10 +110,10 @@ PP_Var GetProtocol(PP_Resource resource) { return enter.object()->GetProtocol(); } -PP_WebSocketReadyState_Dev GetReadyState(PP_Resource resource) { +PP_WebSocketReadyState GetReadyState(PP_Resource resource) { EnterResource<PPB_WebSocket_API> enter(resource, false); if (enter.failed()) - return PP_WEBSOCKETREADYSTATE_INVALID_DEV; + return PP_WEBSOCKETREADYSTATE_INVALID; return enter.object()->GetReadyState(); } @@ -124,7 +124,7 @@ PP_Var GetURL(PP_Resource resource) { return enter.object()->GetURL(); } -const PPB_WebSocket_Dev_0_1 g_ppb_websocket_0_1_thunk = { +const PPB_WebSocket_1_0 g_ppb_websocket_1_0_thunk = { &Create, &IsWebSocket, &Connect, @@ -143,8 +143,8 @@ const PPB_WebSocket_Dev_0_1 g_ppb_websocket_0_1_thunk = { } // namespace -const PPB_WebSocket_Dev_0_1* GetPPB_WebSocket_Dev_0_1_Thunk() { - return &g_ppb_websocket_0_1_thunk; +const PPB_WebSocket_1_0* GetPPB_WebSocket_1_0_Thunk() { + return &g_ppb_websocket_1_0_thunk; } } // namespace thunk diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 90442ed..7d895d8 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -17,9 +17,9 @@ #include "ppapi/c/ppb_graphics_3d.h" #include "ppapi/c/ppb_image_data.h" #include "ppapi/c/ppb_input_event.h" +#include "ppapi/c/ppb_websocket.h" #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/dev/ppb_transport_dev.h" -#include "ppapi/c/dev/ppb_websocket_dev.h" #include "ppapi/shared_impl/api_id.h" struct PP_Flash_Menu; |