| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_SOCKET_PROXY_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_SOCKET_PROXY_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_SOCKET_PROXY_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_SOCKET_PROXY_PRIVATE_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/timer.h" | 9 #include "base/timer.h" |
| 10 #include "chrome/browser/extensions/extension_function.h" | 10 #include "chrome/browser/extensions/extension_function.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "net/base/address_list.h" | 13 #include "net/base/address_list.h" |
| 14 | 14 |
| 15 class IOThread; | 15 class IOThread; |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 class SingleRequestHostResolver; | 18 class SingleRequestHostResolver; |
| 19 } | 19 } |
| 20 | 20 |
| 21 // Base class for web socket proxy functions. | 21 // Base class for web socket proxy functions. |
| 22 class WebSocketProxyPrivate | 22 class WebSocketProxyPrivate |
| 23 : public AsyncExtensionFunction, public content::NotificationObserver { | 23 : public AsyncExtensionFunction, public content::NotificationObserver { |
| 24 public: | 24 public: |
| 25 WebSocketProxyPrivate(); | 25 WebSocketProxyPrivate(); |
| 26 |
| 27 protected: |
| 26 virtual ~WebSocketProxyPrivate(); | 28 virtual ~WebSocketProxyPrivate(); |
| 27 | 29 |
| 28 protected: | |
| 29 // Custom finalization. | 30 // Custom finalization. |
| 30 virtual void CustomFinalize() = 0; | 31 virtual void CustomFinalize() = 0; |
| 31 | 32 |
| 32 // ExtensionFunction implementation. | 33 // ExtensionFunction implementation. |
| 33 virtual bool RunImpl() OVERRIDE; | 34 virtual bool RunImpl() OVERRIDE; |
| 34 | 35 |
| 35 // content::NotificationObserver implementation. | 36 // content::NotificationObserver implementation. |
| 36 virtual void Observe( | 37 virtual void Observe( |
| 37 int type, const content::NotificationSource& source, | 38 int type, const content::NotificationSource& source, |
| 38 const content::NotificationDetails& details) OVERRIDE; | 39 const content::NotificationDetails& details) OVERRIDE; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Used to cancel host resolution when out of scope. | 71 // Used to cancel host resolution when out of scope. |
| 71 scoped_ptr<net::SingleRequestHostResolver> resolver_; | 72 scoped_ptr<net::SingleRequestHostResolver> resolver_; |
| 72 // Callback which is called when host is resolved. | 73 // Callback which is called when host is resolved. |
| 73 bool is_finalized_; | 74 bool is_finalized_; |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 // New API function for web socket proxy, which should be used. | 77 // New API function for web socket proxy, which should be used. |
| 77 class WebSocketProxyPrivateGetURLForTCPFunction | 78 class WebSocketProxyPrivateGetURLForTCPFunction |
| 78 : public WebSocketProxyPrivate { | 79 : public WebSocketProxyPrivate { |
| 79 public: | 80 public: |
| 81 DECLARE_EXTENSION_FUNCTION_NAME("webSocketProxyPrivate.getURLForTCP") |
| 82 |
| 80 WebSocketProxyPrivateGetURLForTCPFunction(); | 83 WebSocketProxyPrivateGetURLForTCPFunction(); |
| 84 |
| 85 protected: |
| 81 virtual ~WebSocketProxyPrivateGetURLForTCPFunction(); | 86 virtual ~WebSocketProxyPrivateGetURLForTCPFunction(); |
| 82 | 87 |
| 83 private: | |
| 84 // ExtensionFunction implementation. | 88 // ExtensionFunction implementation. |
| 85 virtual bool RunImpl() OVERRIDE; | 89 virtual bool RunImpl() OVERRIDE; |
| 86 | 90 |
| 87 // WebSocketProxyPrivate implementation: | 91 // WebSocketProxyPrivate implementation: |
| 88 virtual void CustomFinalize() OVERRIDE; | 92 virtual void CustomFinalize() OVERRIDE; |
| 89 | |
| 90 DECLARE_EXTENSION_FUNCTION_NAME("webSocketProxyPrivate.getURLForTCP") | |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 // Legacy API function for web socket proxy, to be eliminated. | 95 // Legacy API function for web socket proxy, to be eliminated. |
| 94 class WebSocketProxyPrivateGetPassportForTCPFunction | 96 class WebSocketProxyPrivateGetPassportForTCPFunction |
| 95 : public WebSocketProxyPrivate { | 97 : public WebSocketProxyPrivate { |
| 96 public: | 98 public: |
| 99 DECLARE_EXTENSION_FUNCTION_NAME("webSocketProxyPrivate.getPassportForTCP") |
| 100 |
| 97 WebSocketProxyPrivateGetPassportForTCPFunction(); | 101 WebSocketProxyPrivateGetPassportForTCPFunction(); |
| 102 |
| 103 protected: |
| 98 virtual ~WebSocketProxyPrivateGetPassportForTCPFunction(); | 104 virtual ~WebSocketProxyPrivateGetPassportForTCPFunction(); |
| 99 | 105 |
| 100 private: | |
| 101 // WebSocketProxyPrivate implementation: | 106 // WebSocketProxyPrivate implementation: |
| 102 virtual void CustomFinalize() OVERRIDE; | 107 virtual void CustomFinalize() OVERRIDE; |
| 103 | |
| 104 DECLARE_EXTENSION_FUNCTION_NAME("webSocketProxyPrivate.getPassportForTCP") | |
| 105 }; | 108 }; |
| 106 | 109 |
| 107 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_SOCKET_PROXY_PRIVATE_API_H_ | 110 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_SOCKET_PROXY_PRIVATE_API_H_ |
| OLD | NEW |