| OLD | NEW | 
|   1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |   1 // Copyright (c) 2012 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 #ifndef PPAPI_THUNK_WEBSOCKET_API_H_ |   5 #ifndef PPAPI_THUNK_WEBSOCKET_API_H_ | 
|   6 #define PPAPI_THUNK_WEBSOCKET_API_H_ |   6 #define PPAPI_THUNK_WEBSOCKET_API_H_ | 
|   7  |   7  | 
|   8 #include "base/memory/ref_counted.h" |   8 #include "base/memory/ref_counted.h" | 
|   9 #include "ppapi/c/pp_completion_callback.h" |   9 #include "ppapi/c/pp_completion_callback.h" | 
|  10 #include "ppapi/c/ppb_websocket.h" |  10 #include "ppapi/c/ppb_websocket.h" | 
 |  11 #include "ppapi/thunk/ppapi_thunk_export.h" | 
|  11  |  12  | 
|  12 namespace ppapi { |  13 namespace ppapi { | 
|  13  |  14  | 
|  14 class TrackedCallback; |  15 class TrackedCallback; | 
|  15  |  16  | 
|  16 namespace thunk { |  17 namespace thunk { | 
|  17  |  18  | 
|  18 // Some arguments and attributes are based on The WebSocket Protocol and The |  19 // Some arguments and attributes are based on The WebSocket Protocol and The | 
|  19 // WebSocket API. See also following official specifications. |  20 // WebSocket API. See also following official specifications. | 
|  20 //  - The WebSocket Protocol http://tools.ietf.org/html/rfc6455 |  21 //  - The WebSocket Protocol http://tools.ietf.org/html/rfc6455 | 
|  21 //  - The WebSocket API      http://dev.w3.org/html5/websockets/ |  22 //  - The WebSocket API      http://dev.w3.org/html5/websockets/ | 
|  22 class PPB_WebSocket_API { |  23 class PPAPI_THUNK_EXPORT PPB_WebSocket_API { | 
|  23  public: |  24  public: | 
|  24   virtual ~PPB_WebSocket_API() {} |  25   virtual ~PPB_WebSocket_API() {} | 
|  25  |  26  | 
|  26   // Connects to the specified WebSocket server with |protocols| argument |  27   // Connects to the specified WebSocket server with |protocols| argument | 
|  27   // defined by the WebSocket API. Returns an int32_t error code from |  28   // defined by the WebSocket API. Returns an int32_t error code from | 
|  28   // pp_errors.h. |  29   // pp_errors.h. | 
|  29   virtual int32_t Connect(PP_Var url, |  30   virtual int32_t Connect(const PP_Var& url, | 
|  30                           const PP_Var protocols[], |  31                           const PP_Var protocols[], | 
|  31                           uint32_t protocol_count, |  32                           uint32_t protocol_count, | 
|  32                           scoped_refptr<TrackedCallback> callback) = 0; |  33                           scoped_refptr<TrackedCallback> callback) = 0; | 
|  33  |  34  | 
|  34   // Closes the established connection with specified |code| and |reason|. |  35   // Closes the established connection with specified |code| and |reason|. | 
|  35   // Returns an int32_t error code from pp_errors.h. |  36   // Returns an int32_t error code from pp_errors.h. | 
|  36   virtual int32_t Close(uint16_t code, |  37   virtual int32_t Close(uint16_t code, | 
|  37                         PP_Var reason, |  38                         const PP_Var& reason, | 
|  38                         scoped_refptr<TrackedCallback> callback) = 0; |  39                         scoped_refptr<TrackedCallback> callback) = 0; | 
|  39  |  40  | 
|  40   // Receives a message from the WebSocket server. Caller must keep specified |  41   // Receives a message from the WebSocket server. Caller must keep specified | 
|  41   // |message| object as valid until completion callback is invoked. Returns an |  42   // |message| object as valid until completion callback is invoked. Returns an | 
|  42   // int32_t error code from pp_errors.h. |  43   // int32_t error code from pp_errors.h. | 
|  43   virtual int32_t ReceiveMessage(PP_Var* message, |  44   virtual int32_t ReceiveMessage(PP_Var* message, | 
|  44                                  scoped_refptr<TrackedCallback> callback) = 0; |  45                                  scoped_refptr<TrackedCallback> callback) = 0; | 
|  45  |  46  | 
|  46   // Sends a message to the WebSocket server. Returns an int32_t error code |  47   // Sends a message to the WebSocket server. Returns an int32_t error code | 
|  47   // from pp_errors.h. |  48   // from pp_errors.h. | 
|  48   virtual int32_t SendMessage(PP_Var message) = 0; |  49   virtual int32_t SendMessage(const PP_Var& message) = 0; | 
|  49  |  50  | 
|  50   // Returns the bufferedAmount attribute of The WebSocket API. |  51   // Returns the bufferedAmount attribute of The WebSocket API. | 
|  51   virtual uint64_t GetBufferedAmount() = 0; |  52   virtual uint64_t GetBufferedAmount() = 0; | 
|  52  |  53  | 
|  53   // Returns the CloseEvent code attribute of The WebSocket API. Returned code |  54   // Returns the CloseEvent code attribute of The WebSocket API. Returned code | 
|  54   // is valid if the connection is already closed and wasClean attribute is |  55   // is valid if the connection is already closed and wasClean attribute is | 
|  55   // true. |  56   // true. | 
|  56   virtual uint16_t GetCloseCode() = 0; |  57   virtual uint16_t GetCloseCode() = 0; | 
|  57  |  58  | 
|  58   // Returns the CloseEvent reason attribute of The WebSocket API. Returned |  59   // Returns the CloseEvent reason attribute of The WebSocket API. Returned | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  74   virtual PP_WebSocketReadyState GetReadyState() = 0; |  75   virtual PP_WebSocketReadyState GetReadyState() = 0; | 
|  75  |  76  | 
|  76   // Returns the url attribute of The WebSocket API. |  77   // Returns the url attribute of The WebSocket API. | 
|  77   virtual PP_Var GetURL() = 0; |  78   virtual PP_Var GetURL() = 0; | 
|  78 }; |  79 }; | 
|  79  |  80  | 
|  80 }  // namespace thunk |  81 }  // namespace thunk | 
|  81 }  // namespace ppapi |  82 }  // namespace ppapi | 
|  82  |  83  | 
|  83 #endif  // PPAPI_THUNK_WEBSOCKET_API_H_ |  84 #endif  // PPAPI_THUNK_WEBSOCKET_API_H_ | 
| OLD | NEW |