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

Side by Side Diff: content/renderer/pepper/pepper_websocket_host.h

Issue 10944005: Pepper WebSocket API: Implement new design Chrome IPC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retry Created 8 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_
7
8 #include <queue>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_export.h"
13 #include "ppapi/host/resource_host.h"
14 #include "ppapi/proxy/resource_message_params.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocket.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocketClient.h"
17
18 namespace ppapi {
19 class StringVar;
20 class Var;
21 } // namespace ppapi
22
23 namespace content {
24
25 class RendererPpapiHost;
26
27 class CONTENT_EXPORT PepperWebSocketHost
28 : public ppapi::host::ResourceHost,
29 public ::WebKit::WebSocketClient {
30 public:
31 explicit PepperWebSocketHost(RendererPpapiHost* host,
32 PP_Instance instance,
33 PP_Resource resource);
34 virtual ~PepperWebSocketHost();
35
36 virtual int32_t OnResourceMessageReceived(
37 const IPC::Message& msg,
38 ppapi::host::HostMessageContext* context) OVERRIDE;
39
40 // WebSocketClient implementation.
41 virtual void didConnect();
42 virtual void didReceiveMessage(const WebKit::WebString& message);
43 virtual void didReceiveArrayBuffer(const WebKit::WebArrayBuffer& binaryData);
44 virtual void didReceiveMessageError();
45 virtual void didUpdateBufferedAmount(unsigned long buffered_amount);
46 virtual void didStartClosingHandshake();
47 virtual void didClose(unsigned long unhandled_buffered_amount,
48 ClosingHandshakeCompletionStatus status,
49 unsigned short code,
50 const WebKit::WebString& reason);
51 private:
52 // IPC message handlers.
53 int32_t OnHostMsgConnect(ppapi::host::HostMessageContext* context,
54 const std::string& url,
55 const std::string& protocols);
56 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context,
57 int32_t code,
58 const std::string& reason);
59 int32_t OnHostMsgSendText(ppapi::host::HostMessageContext* context,
60 const std::string& message);
61 int32_t OnHostMsgSendBinary(ppapi::host::HostMessageContext* context,
62 const std::vector<uint8_t>& message);
63 int32_t OnHostMsgFail(ppapi::host::HostMessageContext* context,
64 const std::string& message);
65
66 // Handles actual connection establishment.
67 int32_t DoConnect(const std::string& url,
68 const std::string& protocols,
69 std::string* spec);
70
71 // Non-owning pointer.
72 RendererPpapiHost* renderer_ppapi_host_;
73
74 // IPC reply parameters.
75 ppapi::proxy::ResourceMessageReplyParams connect_reply_;
76 ppapi::proxy::ResourceMessageReplyParams close_reply_;
77
78 // A flag to indicate if client initiated closing handshake is performed.
79 bool initiating_close_;
80
81 // A flag to indicate if server initiated closing handshake is performed.
82 bool accepting_close_;
83
84 // Becomes true if any error is detected. Incoming data will be disposed
85 // if this variable is true.
86 bool error_was_received_;
87
88 // Keeps the WebKit side WebSocket object. This is used for calling WebKit
89 // side functions via WebKit API.
90 scoped_ptr<WebKit::WebSocket> websocket_;
91
92 DISALLOW_COPY_AND_ASSIGN(PepperWebSocketHost);
93 };
94
95 } // namespace content
96
97 #endif // CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698