Chromium Code Reviews| Index: ppapi/cpp/dev/websocket_dev.h |
| diff --git a/ppapi/cpp/dev/websocket_dev.h b/ppapi/cpp/dev/websocket_dev.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4fa37f9d55704b594a1452efd024e53e07475faa |
| --- /dev/null |
| +++ b/ppapi/cpp/dev/websocket_dev.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2011 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. |
| + |
| +#ifndef PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ |
| +#define PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ |
| + |
| +#include "ppapi/c/dev/ppb_websocket_dev.h" |
| + |
| +/// @file |
| +/// This file defines the WebSocket_Dev interface. |
| + |
| +namespace pp { |
| + |
| +class Var; |
| + |
| +/// The <code>WebSocket_Dev</code> class |
| +/// A version that use virtual functions |
| +class WebSocket_Dev : public Resource { |
| + public: |
| + WebSocket_Dev(); |
| + virtual ~WebSocket_Dev(); |
| + |
| + int32_t Connect(const Var& url, const Var& protocols[], |
| + uint32_t protocol_count); |
| + int32_t Close(uint16_t code, const Var& reason); |
| + int32_t Send(const Var& data); |
| + |
| + PP_WebSocketReadyState_Dev GetReadyState(); |
| + uint64_t GetBufferedAmount(); |
| + Var GetExtensions(); |
| + Var GetProtocol(); |
| + Var GetURL(); |
| + |
| + virtual void OnOpen() = 0; |
| + virtual void OnMessage(Var message) = 0; |
| + virtual void OnError() = 0; |
| + virtual void OnClose(bool wasClean, uint16_t code, const Var& reason) = 0; |
| +}; |
| + |
| +/// The <code>WebSocket_Dev</code> class |
| +/// A version that use delegate. |
| +class WebSocket_Dev : public Resource { |
| + public: |
| + class Delegate { |
| + virtual void OnOpen(WebSocket_Dev* instance) = 0; |
| + virtual void OnMessage(WebSocket_Dev* instance, Var message) = 0; |
| + virtual void OnError(WebSocket_Dev* instance) = 0; |
| + virtual void OnClose(WebSocket_Dev* instance, bool wasClean, uint16_t code, |
| + const Var& reason) = 0; |
| + }; |
| + WebSocket_Dev(Delegate* delegate); |
| + virtual ~WebSocket_Dev(); |
| + |
| + int32_t Connect(const Var& url, const Var& protocols[], |
| + uint32_t protocol_count); |
| + int32_t Close(uint16_t code, const Var& reason); |
| + int32_t Send(const Var& data); |
| + |
| + PP_WebSocketReadyState_Dev GetReadyState(); |
| + uint64_t GetBufferedAmount(); |
| + Var GetExtensions(); |
| + Var GetProtocol(); |
| + Var GetURL(); |
|
dmichael (off chromium)
2011/11/04 15:26:18
The delegate pattern does seem nice here. If there
Takashi Toyoshima
2011/11/07 08:35:57
OK, I see.
Actually, it seems to be difficult that
|
| +}; |
| + |
| +} // namespace pp |
| + |
| +#endif // PPAPI_CPP_DEV_WEBSOCKET_DEV_H_ |