| 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 CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" |
| 10 #include "base/id_map.h" | 11 #include "base/id_map.h" |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 12 #include "content/browser/loader/resource_message_filter.h" | |
| 13 #include "content/browser/ssl/ssl_error_handler.h" | 13 #include "content/browser/ssl/ssl_error_handler.h" |
| 14 #include "content/public/browser/browser_message_filter.h" | 14 #include "content/public/browser/browser_message_filter.h" |
| 15 #include "net/socket_stream/socket_stream.h" | 15 #include "net/socket_stream/socket_stream.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 class SSLInfo; | 20 class SSLInfo; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 class ResourceContext; | 24 class ResourceContext; |
| 25 class SocketStreamHost; | 25 class SocketStreamHost; |
| 26 | 26 |
| 27 // Dispatches ViewHostMsg_SocketStream_* messages sent from renderer. | 27 // Dispatches ViewHostMsg_SocketStream_* messages sent from renderer. |
| 28 // It also acts as SocketStream::Delegate so that it sends | 28 // It also acts as SocketStream::Delegate so that it sends |
| 29 // ViewMsg_SocketStream_* messages back to renderer. | 29 // ViewMsg_SocketStream_* messages back to renderer. |
| 30 class SocketStreamDispatcherHost | 30 class SocketStreamDispatcherHost |
| 31 : public BrowserMessageFilter, | 31 : public BrowserMessageFilter, |
| 32 public net::SocketStream::Delegate, | 32 public net::SocketStream::Delegate, |
| 33 public SSLErrorHandler::Delegate { | 33 public SSLErrorHandler::Delegate { |
| 34 public: | 34 public: |
| 35 typedef base::Callback<net::URLRequestContext*(ResourceType::Type)> |
| 36 GetRequestContextCallback; |
| 35 SocketStreamDispatcherHost( | 37 SocketStreamDispatcherHost( |
| 36 int render_process_id, | 38 int render_process_id, |
| 37 ResourceMessageFilter::URLRequestContextSelector* selector, | 39 const GetRequestContextCallback& request_context_callback, |
| 38 ResourceContext* resource_context); | 40 ResourceContext* resource_context); |
| 39 | 41 |
| 40 // BrowserMessageFilter: | 42 // BrowserMessageFilter: |
| 41 virtual bool OnMessageReceived(const IPC::Message& message, | 43 virtual bool OnMessageReceived(const IPC::Message& message, |
| 42 bool* message_was_ok) OVERRIDE; | 44 bool* message_was_ok) OVERRIDE; |
| 43 | 45 |
| 44 // Make this object inactive. | 46 // Make this object inactive. |
| 45 // Remove all active SocketStreamHost objects. | 47 // Remove all active SocketStreamHost objects. |
| 46 void Shutdown(); | 48 void Shutdown(); |
| 47 | 49 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 77 void OnConnect(int render_view_id, const GURL& url, int socket_id); | 79 void OnConnect(int render_view_id, const GURL& url, int socket_id); |
| 78 void OnSendData(int socket_id, const std::vector<char>& data); | 80 void OnSendData(int socket_id, const std::vector<char>& data); |
| 79 void OnCloseReq(int socket_id); | 81 void OnCloseReq(int socket_id); |
| 80 | 82 |
| 81 void DeleteSocketStreamHost(int socket_id); | 83 void DeleteSocketStreamHost(int socket_id); |
| 82 | 84 |
| 83 net::URLRequestContext* GetURLRequestContext(); | 85 net::URLRequestContext* GetURLRequestContext(); |
| 84 | 86 |
| 85 IDMap<SocketStreamHost> hosts_; | 87 IDMap<SocketStreamHost> hosts_; |
| 86 int render_process_id_; | 88 int render_process_id_; |
| 87 const scoped_ptr<ResourceMessageFilter::URLRequestContextSelector> | 89 GetRequestContextCallback request_context_callback_; |
| 88 url_request_context_selector_; | |
| 89 ResourceContext* resource_context_; | 90 ResourceContext* resource_context_; |
| 90 | 91 |
| 91 base::WeakPtrFactory<SocketStreamDispatcherHost> weak_ptr_factory_; | 92 base::WeakPtrFactory<SocketStreamDispatcherHost> weak_ptr_factory_; |
| 92 bool on_shutdown_; | 93 bool on_shutdown_; |
| 93 | 94 |
| 94 DISALLOW_COPY_AND_ASSIGN(SocketStreamDispatcherHost); | 95 DISALLOW_COPY_AND_ASSIGN(SocketStreamDispatcherHost); |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 } // namespace content | 98 } // namespace content |
| 98 | 99 |
| 99 #endif // CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ | 100 #endif // CONTENT_BROWSER_RENDERER_HOST_SOCKET_STREAM_DISPATCHER_HOST_H_ |
| OLD | NEW |