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

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: fix nits 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/host_message_context.h"
14 #include "ppapi/host/resource_host.h"
15 #include "ppapi/proxy/resource_message_params.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocket.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSocketClient.h"
18
19 namespace ppapi {
20 class StringVar;
21 class Var;
22 } // namespace ppapi
23
24 namespace content {
25
26 class RendererPpapiHost;
27
28 class CONTENT_EXPORT PepperWebSocketHost
29 : public ppapi::host::ResourceHost,
30 public NON_EXPORTED_BASE(::WebKit::WebSocketClient) {
31 public:
32 explicit PepperWebSocketHost(RendererPpapiHost* host,
33 PP_Instance instance,
34 PP_Resource resource);
35 virtual ~PepperWebSocketHost();
36
37 virtual int32_t OnResourceMessageReceived(
38 const IPC::Message& msg,
39 ppapi::host::HostMessageContext* context) OVERRIDE;
40
41 // WebSocketClient implementation.
42 virtual void didConnect();
43 virtual void didReceiveMessage(const WebKit::WebString& message);
44 virtual void didReceiveArrayBuffer(const WebKit::WebArrayBuffer& binaryData);
45 virtual void didReceiveMessageError();
46 virtual void didUpdateBufferedAmount(unsigned long buffered_amount);
47 virtual void didStartClosingHandshake();
48 virtual void didClose(unsigned long unhandled_buffered_amount,
49 ClosingHandshakeCompletionStatus status,
50 unsigned short code,
51 const WebKit::WebString& reason);
52 private:
53 // IPC message handlers.
54 int32_t OnHostMsgConnect(ppapi::host::HostMessageContext* context,
55 const std::string& url,
56 const std::vector<std::string>& protocols);
57 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context,
58 int32_t code,
59 const std::string& reason);
60 int32_t OnHostMsgSendText(ppapi::host::HostMessageContext* context,
61 const std::string& message);
62 int32_t OnHostMsgSendBinary(ppapi::host::HostMessageContext* context,
63 const std::vector<uint8_t>& message);
64 int32_t OnHostMsgFail(ppapi::host::HostMessageContext* context,
65 const std::string& message);
66
67 // Non-owning pointer.
68 RendererPpapiHost* renderer_ppapi_host_;
69
70 // IPC reply parameters.
71 ppapi::host::ReplyMessageContext connect_reply_;
72 ppapi::host::ReplyMessageContext close_reply_;
73
74 // The server URL to which this instance connects.
75 std::string url_;
76
77 // A flag to indicate if opening handshake is going on.
78 bool connecting_;
79
80 // A flag to indicate if client initiated closing handshake is performed.
81 bool initiating_close_;
82
83 // A flag to indicate if server initiated closing handshake is performed.
84 bool accepting_close_;
85
86 // Becomes true if any error is detected. Incoming data will be disposed
87 // if this variable is true.
88 bool error_was_received_;
89
90 // Keeps the WebKit side WebSocket object. This is used for calling WebKit
91 // side functions via WebKit API.
92 scoped_ptr<WebKit::WebSocket> websocket_;
93
94 DISALLOW_COPY_AND_ASSIGN(PepperWebSocketHost);
95 };
96
97 } // namespace content
98
99 #endif // CONTENT_RENDERER_PEPPER_PEPPER_WEBSOCKET_HOST_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_in_process_resource_creation.cc ('k') | content/renderer/pepper/pepper_websocket_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698