| 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_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/devtools_http_handler.h" | 16 #include "content/public/browser/devtools_http_handler.h" |
| 17 #include "content/public/browser/devtools_http_handler_delegate.h" | 17 #include "content/public/browser/devtools_http_handler_delegate.h" |
| 18 #include "content/public/browser/notification_observer.h" | |
| 19 #include "content/public/browser/notification_registrar.h" | |
| 20 #include "net/server/http_server.h" | 18 #include "net/server/http_server.h" |
| 21 | 19 |
| 22 namespace base { | 20 namespace base { |
| 23 class DictionaryValue; | 21 class DictionaryValue; |
| 24 class Thread; | 22 class Thread; |
| 25 class Value; | 23 class Value; |
| 26 } | 24 } |
| 27 | 25 |
| 28 namespace net { | 26 namespace net { |
| 29 class StreamListenSocketFactory; | 27 class StreamListenSocketFactory; |
| 30 class URLRequestContextGetter; | 28 class URLRequestContextGetter; |
| 31 } | 29 } |
| 32 | 30 |
| 33 namespace content { | 31 namespace content { |
| 34 | 32 |
| 35 class DevToolsBrowserTarget; | 33 class DevToolsBrowserTarget; |
| 36 class DevToolsClientHost; | 34 class DevToolsClientHost; |
| 37 | 35 |
| 38 class DevToolsHttpHandlerImpl | 36 class DevToolsHttpHandlerImpl |
| 39 : public DevToolsHttpHandler, | 37 : public DevToolsHttpHandler, |
| 40 public NotificationObserver, | |
| 41 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, | 38 public base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>, |
| 42 public net::HttpServer::Delegate { | 39 public net::HttpServer::Delegate { |
| 43 private: | 40 private: |
| 44 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; | 41 friend class base::RefCountedThreadSafe<DevToolsHttpHandlerImpl>; |
| 45 friend class DevToolsHttpHandler; | 42 friend class DevToolsHttpHandler; |
| 46 | 43 |
| 47 // Takes ownership over |socket_factory|. | 44 // Takes ownership over |socket_factory|. |
| 48 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, | 45 DevToolsHttpHandlerImpl(const net::StreamListenSocketFactory* socket_factory, |
| 49 const std::string& frontend_url, | 46 const std::string& frontend_url, |
| 50 DevToolsHttpHandlerDelegate* delegate); | 47 DevToolsHttpHandlerDelegate* delegate); |
| 51 virtual ~DevToolsHttpHandlerImpl(); | 48 virtual ~DevToolsHttpHandlerImpl(); |
| 52 void Start(); | 49 void Start(); |
| 53 | 50 |
| 54 // DevToolsHttpHandler implementation. | 51 // DevToolsHttpHandler implementation. |
| 55 virtual void Stop() OVERRIDE; | 52 virtual void Stop() OVERRIDE; |
| 56 virtual void SetDevToolsAgentHostBinding( | 53 virtual void SetDevToolsAgentHostBinding( |
| 57 DevToolsAgentHostBinding* binding) OVERRIDE; | 54 DevToolsAgentHostBinding* binding) OVERRIDE; |
| 58 virtual GURL GetFrontendURL(DevToolsAgentHost* agent_host) OVERRIDE; | 55 virtual GURL GetFrontendURL(DevToolsAgentHost* agent_host) OVERRIDE; |
| 59 | 56 |
| 60 // NotificationObserver implementation. | |
| 61 virtual void Observe(int type, | |
| 62 const NotificationSource& source, | |
| 63 const NotificationDetails& details) OVERRIDE; | |
| 64 | |
| 65 // net::HttpServer::Delegate implementation. | 57 // net::HttpServer::Delegate implementation. |
| 66 virtual void OnHttpRequest(int connection_id, | 58 virtual void OnHttpRequest(int connection_id, |
| 67 const net::HttpServerRequestInfo& info) OVERRIDE; | 59 const net::HttpServerRequestInfo& info) OVERRIDE; |
| 68 virtual void OnWebSocketRequest( | 60 virtual void OnWebSocketRequest( |
| 69 int connection_id, | 61 int connection_id, |
| 70 const net::HttpServerRequestInfo& info) OVERRIDE; | 62 const net::HttpServerRequestInfo& info) OVERRIDE; |
| 71 virtual void OnWebSocketMessage(int connection_id, | 63 virtual void OnWebSocketMessage(int connection_id, |
| 72 const std::string& data) OVERRIDE; | 64 const std::string& data) OVERRIDE; |
| 73 virtual void OnClose(int connection_id) OVERRIDE; | 65 virtual void OnClose(int connection_id) OVERRIDE; |
| 74 | 66 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 scoped_ptr<base::Thread> thread_; | 107 scoped_ptr<base::Thread> thread_; |
| 116 | 108 |
| 117 std::string overridden_frontend_url_; | 109 std::string overridden_frontend_url_; |
| 118 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; | 110 scoped_ptr<const net::StreamListenSocketFactory> socket_factory_; |
| 119 scoped_refptr<net::HttpServer> server_; | 111 scoped_refptr<net::HttpServer> server_; |
| 120 typedef std::map<int, DevToolsClientHost*> ConnectionToClientHostMap; | 112 typedef std::map<int, DevToolsClientHost*> ConnectionToClientHostMap; |
| 121 ConnectionToClientHostMap connection_to_client_host_ui_; | 113 ConnectionToClientHostMap connection_to_client_host_ui_; |
| 122 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; | 114 scoped_ptr<DevToolsHttpHandlerDelegate> delegate_; |
| 123 DevToolsAgentHostBinding* binding_; | 115 DevToolsAgentHostBinding* binding_; |
| 124 scoped_ptr<DevToolsAgentHostBinding> default_binding_; | 116 scoped_ptr<DevToolsAgentHostBinding> default_binding_; |
| 125 NotificationRegistrar registrar_; | |
| 126 scoped_ptr<DevToolsBrowserTarget> browser_target_; | 117 scoped_ptr<DevToolsBrowserTarget> browser_target_; |
| 127 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); | 118 DISALLOW_COPY_AND_ASSIGN(DevToolsHttpHandlerImpl); |
| 128 }; | 119 }; |
| 129 | 120 |
| 130 } // namespace content | 121 } // namespace content |
| 131 | 122 |
| 132 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ | 123 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_HTTP_HANDLER_IMPL_H_ |
| OLD | NEW |