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; |
| 16 |
15 namespace net { | 17 namespace net { |
16 class SingleRequestHostResolver; | 18 class SingleRequestHostResolver; |
17 } | 19 } |
18 | 20 |
19 // Base class for web socket proxy functions. | 21 // Base class for web socket proxy functions. |
20 class WebSocketProxyPrivate | 22 class WebSocketProxyPrivate |
21 : public AsyncExtensionFunction, public content::NotificationObserver { | 23 : public AsyncExtensionFunction, public content::NotificationObserver { |
22 public: | 24 public: |
23 WebSocketProxyPrivate(); | 25 WebSocketProxyPrivate(); |
24 virtual ~WebSocketProxyPrivate(); | 26 virtual ~WebSocketProxyPrivate(); |
(...skipping 24 matching lines...) Expand all Loading... |
49 std::map<std::string, std::string> map_; | 51 std::map<std::string, std::string> map_; |
50 | 52 |
51 private: | 53 private: |
52 // Finalizes and sends respond. Overwrite 'CustomFinalize' in inherited | 54 // Finalizes and sends respond. Overwrite 'CustomFinalize' in inherited |
53 // classes. | 55 // classes. |
54 void Finalize(); | 56 void Finalize(); |
55 | 57 |
56 // Callback for DNS resolution. | 58 // Callback for DNS resolution. |
57 void OnHostResolution(int result); | 59 void OnHostResolution(int result); |
58 | 60 |
| 61 // Posts task to the IO thread, which will make dns resolution. |
| 62 void ResolveHost(); |
59 // Executes on IO thread. Performs DNS resolution. | 63 // Executes on IO thread. Performs DNS resolution. |
60 void ResolveHost(); | 64 void ResolveHostIOPart(IOThread* io_thread); |
61 | 65 |
62 // Used to signal timeout (when waiting for proxy initial launch). | 66 // Used to signal timeout (when waiting for proxy initial launch). |
63 base::OneShotTimer<WebSocketProxyPrivate> timer_; | 67 base::OneShotTimer<WebSocketProxyPrivate> timer_; |
64 // Used to register for notifications. | 68 // Used to register for notifications. |
65 content::NotificationRegistrar registrar_; | 69 content::NotificationRegistrar registrar_; |
66 // Used to cancel host resolution when out of scope. | 70 // Used to cancel host resolution when out of scope. |
67 scoped_ptr<net::SingleRequestHostResolver> resolver_; | 71 scoped_ptr<net::SingleRequestHostResolver> resolver_; |
68 // Callback which is called when host is resolved. | 72 // Callback which is called when host is resolved. |
69 bool is_finalized_; | 73 bool is_finalized_; |
70 }; | 74 }; |
(...skipping 23 matching lines...) Expand all Loading... |
94 virtual ~WebSocketProxyPrivateGetPassportForTCPFunction(); | 98 virtual ~WebSocketProxyPrivateGetPassportForTCPFunction(); |
95 | 99 |
96 private: | 100 private: |
97 // WebSocketProxyPrivate implementation: | 101 // WebSocketProxyPrivate implementation: |
98 virtual void CustomFinalize() OVERRIDE; | 102 virtual void CustomFinalize() OVERRIDE; |
99 | 103 |
100 DECLARE_EXTENSION_FUNCTION_NAME("webSocketProxyPrivate.getPassportForTCP") | 104 DECLARE_EXTENSION_FUNCTION_NAME("webSocketProxyPrivate.getPassportForTCP") |
101 }; | 105 }; |
102 | 106 |
103 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_SOCKET_PROXY_PRIVATE_API_H_ | 107 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_SOCKET_PROXY_PRIVATE_API_H_ |
OLD | NEW |