diff options
author | Jason Monk <jmonk@google.com> | 2013-08-23 17:19:31 -0400 |
---|---|---|
committer | Jason Monk <jmonk@google.com> | 2013-08-23 18:48:54 -0400 |
commit | 40adcb542a80576ad761fcb7362b98e9afd754fa (patch) | |
tree | dad09c46f641f71867e44f62c88e1c1989e030d2 | |
parent | c06a8d69b50384113df4a17824c68bbfce7fb578 (diff) | |
download | chromium-libpac-40adcb542a80576ad761fcb7362b98e9afd754fa.tar.gz |
Fix error messages so reported to listener.
Change the errors to report to listener rather than return them.
Also fixed set function to take a const parameter as it should.
Bug: 10458767
Change-Id: Iaba9bc7ca384961ea420b31b9e03d30d3093a3cd
-rw-r--r-- | src/proxy_resolver_v8.cc | 26 | ||||
-rw-r--r-- | src/proxy_resolver_v8.h | 2 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/proxy_resolver_v8.cc b/src/proxy_resolver_v8.cc index ee0510b..cb08ebb 100644 --- a/src/proxy_resolver_v8.cc +++ b/src/proxy_resolver_v8.cc @@ -170,13 +170,8 @@ android::String16 V8StringToUTF16(v8::Handle<v8::String> s) { } std::string UTF16ToASCII(const android::String16& str) { - android::String8 rstr(str); - return std::string(rstr.string()); -} - -android::String16 ASCIIToUTF16(const std::string str) { - android::String8 str8(str.c_str()); - return android::String16(str8); + android::String8 rstr(str); + return std::string(rstr.string()); } // Converts an ASCII std::string to a V8 string. @@ -369,7 +364,8 @@ class ProxyResolverV8::Context { PurgeMemory(); } - int ResolveProxy(const android::String16 url, const android::String16 host, android::String16* results) { + int ResolveProxy(const android::String16 url, const android::String16 host, + android::String16* results) { v8::Locker locked; v8::HandleScope scope; @@ -377,7 +373,8 @@ class ProxyResolverV8::Context { v8::Local<v8::Value> function; if (!GetFindProxyForURL(&function)) { - *results = ASCIIToUTF16("FindProxyForURL() is undefined"); + error_listener_->ErrorMessage( + android::String16("FindProxyForURL() is undefined")); return ERR_PAC_SCRIPT_FAILED; } @@ -390,12 +387,14 @@ class ProxyResolverV8::Context { v8_context_->Global(), 2, argv); if (try_catch.HasCaught()) { - *results = V8StringToUTF16(try_catch.Message()->Get()); + error_listener_->ErrorMessage( + V8StringToUTF16(try_catch.Message()->Get())); return ERR_PAC_SCRIPT_FAILED; } if (!ret->IsString()) { - *results = ASCIIToUTF16("FindProxyForURL() did not return a string."); + error_listener_->ErrorMessage( + android::String16("FindProxyForURL() did not return a string.")); return ERR_PAC_SCRIPT_FAILED; } @@ -406,7 +405,8 @@ class ProxyResolverV8::Context { // could extend the parsing to handle IDNA hostnames by // converting them to ASCII punycode. // crbug.com/47234 - *results = ASCIIToUTF16("FindProxyForURL() returned a non-ASCII string"); + error_listener_->ErrorMessage( + android::String16("FindProxyForURL() returned a non-ASCII string")); return ERR_PAC_SCRIPT_FAILED; } @@ -715,7 +715,7 @@ void ProxyResolverV8::PurgeMemory() { context_->PurgeMemory(); } -int ProxyResolverV8::SetPacScript(android::String16& script_data) { +int ProxyResolverV8::SetPacScript(const android::String16& script_data) { if (context_ != NULL) { delete context_; context_ = NULL; diff --git a/src/proxy_resolver_v8.h b/src/proxy_resolver_v8.h index ea36f03..818cb58 100644 --- a/src/proxy_resolver_v8.h +++ b/src/proxy_resolver_v8.h @@ -59,7 +59,7 @@ class ProxyResolverV8 { virtual int GetProxyForURL(const android::String16 spec, const android::String16 host, android::String16* results); virtual void PurgeMemory(); - virtual int SetPacScript(android::String16& script_data); + virtual int SetPacScript(const android::String16& script_data); private: // Context holds the Javascript state for the most recently loaded PAC |