aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2013-08-27 13:32:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-08-27 13:32:52 +0000
commitc34a8c90027b55d8f5b5c8e90592fafb72b32c3a (patch)
tree237f3435813594f0c1a4494d0b0c0ecf39da103b
parent155ecd15c2abe3f480ce2eeb2cffc61498c04054 (diff)
parent40adcb542a80576ad761fcb7362b98e9afd754fa (diff)
downloadchromium-libpac-c34a8c90027b55d8f5b5c8e90592fafb72b32c3a.tar.gz
Merge "Fix error messages so reported to listener." into klp-dev
-rw-r--r--src/proxy_resolver_v8.cc26
-rw-r--r--src/proxy_resolver_v8.h2
2 files changed, 14 insertions, 14 deletions
diff --git a/src/proxy_resolver_v8.cc b/src/proxy_resolver_v8.cc
index deb06fe..285091d 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.
@@ -372,7 +367,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;
@@ -380,7 +376,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;
}
@@ -393,12 +390,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;
}
@@ -409,7 +408,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;
}
@@ -718,7 +718,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