diff options
Diffstat (limited to 'net/proxy/proxy_resolver_v8.h')
-rw-r--r-- | net/proxy/proxy_resolver_v8.h | 43 |
1 files changed, 4 insertions, 39 deletions
diff --git a/net/proxy/proxy_resolver_v8.h b/net/proxy/proxy_resolver_v8.h index 4c364e5..6689191 100644 --- a/net/proxy/proxy_resolver_v8.h +++ b/net/proxy/proxy_resolver_v8.h @@ -15,6 +15,7 @@ class MessageLoop; namespace net { class HostResolver; +class ProxyResolverJSBindings; // Implementation of ProxyResolver that uses V8 to evaluate PAC scripts. // @@ -36,12 +37,10 @@ class HostResolver; // and does not use locking since it expects to be alone. class ProxyResolverV8 : public ProxyResolver { public: - class JSBindings; - // Constructs a ProxyResolverV8 with custom bindings. ProxyResolverV8 takes // ownership of |custom_js_bindings| and deletes it when ProxyResolverV8 // is destroyed. - explicit ProxyResolverV8(JSBindings* custom_js_bindings); + explicit ProxyResolverV8(ProxyResolverJSBindings* custom_js_bindings); virtual ~ProxyResolverV8(); @@ -52,22 +51,7 @@ class ProxyResolverV8 : public ProxyResolver { RequestHandle* /*request*/); virtual void CancelRequest(RequestHandle request); - JSBindings* js_bindings() const { return js_bindings_.get(); } - - // Creates a default javascript bindings implementation that will: - // - Send script error messages to LOG(INFO) - // - Send script alert()s to LOG(INFO) - // - Use the provided host resolver to service dnsResolve(). - // - // For clients that need more control (for example, sending the script output - // to a UI widget), use the ProxyResolverV8(JSBindings*) and specify your - // own bindings. - // - // |host_resolver| will be used in async mode on |host_resolver_loop|. If - // |host_resolver_loop| is NULL, then |host_resolver| will be used in sync - // mode on the PAC thread. - static JSBindings* CreateDefaultBindings(HostResolver* host_resolver, - MessageLoop* host_resolver_loop); + ProxyResolverJSBindings* js_bindings() const { return js_bindings_.get(); } private: // Context holds the Javascript state for the most recently loaded PAC @@ -80,30 +64,11 @@ class ProxyResolverV8 : public ProxyResolver { scoped_ptr<Context> context_; - scoped_ptr<JSBindings> js_bindings_; + scoped_ptr<ProxyResolverJSBindings> js_bindings_; DISALLOW_COPY_AND_ASSIGN(ProxyResolverV8); }; -// Interface for the javascript bindings. -class ProxyResolverV8::JSBindings { - public: - virtual ~JSBindings() {} - - // Handler for "alert(message)" - virtual void Alert(const std::string& message) = 0; - - // Handler for "myIpAddress()". Returns empty string on failure. - virtual std::string MyIpAddress() = 0; - - // Handler for "dnsResolve(host)". Returns empty string on failure. - virtual std::string DnsResolve(const std::string& host) = 0; - - // Handler for when an error is encountered. |line_number| may be -1 - // if a line number is not applicable to this error. - virtual void OnError(int line_number, const std::string& error) = 0; -}; - } // namespace net #endif // NET_PROXY_PROXY_RESOLVER_V8_H_ |