| OLD | NEW |
| (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_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "base/id_map.h" | |
| 12 #include "content/public/browser/browser_message_filter.h" | |
| 13 #include "content/public/common/resource_type.h" | |
| 14 #include "net/socket_stream/socket_stream.h" | |
| 15 | |
| 16 class GURL; | |
| 17 | |
| 18 namespace net { | |
| 19 class SSLInfo; | |
| 20 } | |
| 21 | |
| 22 namespace content { | |
| 23 class ResourceContext; | |
| 24 class SocketStreamHost; | |
| 25 | |
| 26 // Dispatches ViewHostMsg_SocketStream_* messages sent from renderer. | |
| 27 // It also acts as SocketStream::Delegate so that it sends | |
| 28 // ViewMsg_SocketStream_* messages back to renderer. | |
| 29 class SocketStreamDispatcherHost : public BrowserMessageFilter, | |
| 30 public net::SocketStream::Delegate { | |
| 31 public: | |
| 32 typedef base::Callback<net::URLRequestContext*(ResourceType)> | |
| 33 GetRequestContextCallback; | |
| 34 SocketStreamDispatcherHost( | |
| 35 int render_process_id, | |
| 36 const GetRequestContextCallback& request_context_callback, | |
| 37 ResourceContext* resource_context); | |
| 38 | |
| 39 // BrowserMessageFilter: | |
| 40 bool OnMessageReceived(const IPC::Message& message) override; | |
| 41 | |
| 42 // Make this object inactive. | |
| 43 // Remove all active SocketStreamHost objects. | |
| 44 void Shutdown(); | |
| 45 | |
| 46 // SocketStream::Delegate: | |
| 47 void OnConnected(net::SocketStream* socket, | |
| 48 int max_pending_send_allowed) override; | |
| 49 void OnSentData(net::SocketStream* socket, int amount_sent) override; | |
| 50 void OnReceivedData(net::SocketStream* socket, | |
| 51 const char* data, | |
| 52 int len) override; | |
| 53 void OnClose(net::SocketStream* socket) override; | |
| 54 void OnError(const net::SocketStream* socket, int error) override; | |
| 55 void OnSSLCertificateError(net::SocketStream* socket, | |
| 56 const net::SSLInfo& ssl_info, | |
| 57 bool fatal) override; | |
| 58 bool CanGetCookies(net::SocketStream* socket, const GURL& url) override; | |
| 59 bool CanSetCookie(net::SocketStream* request, | |
| 60 const GURL& url, | |
| 61 const std::string& cookie_line, | |
| 62 net::CookieOptions* options) override; | |
| 63 | |
| 64 protected: | |
| 65 ~SocketStreamDispatcherHost() override; | |
| 66 | |
| 67 private: | |
| 68 // Message handlers called by OnMessageReceived. | |
| 69 void OnConnect(int render_frame_id, const GURL& url, int socket_id); | |
| 70 void OnSendData(int socket_id, const std::vector<char>& data); | |
| 71 void OnCloseReq(int socket_id); | |
| 72 | |
| 73 void DeleteSocketStreamHost(int socket_id); | |
| 74 | |
| 75 net::URLRequestContext* GetURLRequestContext(); | |
| 76 | |
| 77 IDMap<SocketStreamHost> hosts_; | |
| 78 int render_process_id_; | |
| 79 GetRequestContextCallback request_context_callback_; | |
| 80 ResourceContext* resource_context_; | |
| 81 | |
| 82 bool on_shutdown_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(SocketStreamDispatcherHost); | |
| 85 }; | |
| 86 | |
| 87 } // namespace content | |
| 88 | |
| 89 #endif // CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ | |
| OLD | NEW |