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

Unified Diff: ppapi/cpp/dev/websocket_dev.h

Issue 8395037: IDL for WebSocket Pepper API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add C++ API sample 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/c/dev/ppb_websocket_dev.h ('k') | ppapi/generators/generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « ppapi/c/dev/ppb_websocket_dev.h ('k') | ppapi/generators/generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698