OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 NET_PROXY_PROXY_JS_BINDINGS_H | 5 #ifndef NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_ |
6 #define NET_PROXY_PROXY_JS_BINDINGS_H | 6 #define NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 class MessageLoop; | 10 class MessageLoop; |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 class HostResolver; | 14 class HostResolver; |
| 15 struct ProxyResolverRequestContext; |
15 | 16 |
16 // Interface for the javascript bindings. | 17 // Interface for the javascript bindings. |
17 class ProxyResolverJSBindings { | 18 class ProxyResolverJSBindings { |
18 public: | 19 public: |
| 20 ProxyResolverJSBindings() : current_request_context_(NULL) {} |
| 21 |
19 virtual ~ProxyResolverJSBindings() {} | 22 virtual ~ProxyResolverJSBindings() {} |
20 | 23 |
21 // Handler for "alert(message)" | 24 // Handler for "alert(message)" |
22 virtual void Alert(const std::string& message) = 0; | 25 virtual void Alert(const std::string& message) = 0; |
23 | 26 |
24 // Handler for "myIpAddress()". Returns empty string on failure. | 27 // Handler for "myIpAddress()". Returns empty string on failure. |
25 virtual std::string MyIpAddress() = 0; | 28 virtual std::string MyIpAddress() = 0; |
26 | 29 |
27 // Handler for "myIpAddressEx()". Returns empty string on failure. | 30 // Handler for "myIpAddressEx()". Returns empty string on failure. |
28 // | 31 // |
(...skipping 14 matching lines...) Expand all Loading... |
43 // if a line number is not applicable to this error. | 46 // if a line number is not applicable to this error. |
44 virtual void OnError(int line_number, const std::string& error) = 0; | 47 virtual void OnError(int line_number, const std::string& error) = 0; |
45 | 48 |
46 // Creates a default javascript bindings implementation that will: | 49 // Creates a default javascript bindings implementation that will: |
47 // - Send script error messages to LOG(INFO) | 50 // - Send script error messages to LOG(INFO) |
48 // - Send script alert()s to LOG(INFO) | 51 // - Send script alert()s to LOG(INFO) |
49 // - Use the provided host resolver to service dnsResolve(). | 52 // - Use the provided host resolver to service dnsResolve(). |
50 // | 53 // |
51 // Note that |host_resolver| will be used in sync mode mode. | 54 // Note that |host_resolver| will be used in sync mode mode. |
52 static ProxyResolverJSBindings* CreateDefault(HostResolver* host_resolver); | 55 static ProxyResolverJSBindings* CreateDefault(HostResolver* host_resolver); |
| 56 |
| 57 // Sets details about the currently executing FindProxyForURL() request. |
| 58 void set_current_request_context( |
| 59 ProxyResolverRequestContext* current_request_context) { |
| 60 current_request_context_ = current_request_context; |
| 61 } |
| 62 |
| 63 // Retrieves details about the currently executing FindProxyForURL() request. |
| 64 ProxyResolverRequestContext* current_request_context() { |
| 65 return current_request_context_; |
| 66 } |
| 67 |
| 68 private: |
| 69 ProxyResolverRequestContext* current_request_context_; |
53 }; | 70 }; |
54 | 71 |
55 } // namespace net | 72 } // namespace net |
56 | 73 |
57 #endif // NET_PROXY_PROXY_JS_BINDINGS_H | 74 #endif // NET_PROXY_PROXY_RESOLVER_JS_BINDINGS_H_ |
OLD | NEW |