diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 22:20:50 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 22:20:50 +0000 |
commit | 9b9ae9556a0b51fc0201e925624ae6bd76686536 (patch) | |
tree | cc0643d59f985f5c28f73e4056dac5a20bfe0e0d /net/proxy/single_threaded_proxy_resolver_unittest.cc | |
parent | 947405b19c553f4cba8d0027f472ed932b2d84d5 (diff) | |
download | chromium_src-9b9ae9556a0b51fc0201e925624ae6bd76686536.zip chromium_src-9b9ae9556a0b51fc0201e925624ae6bd76686536.tar.gz chromium_src-9b9ae9556a0b51fc0201e925624ae6bd76686536.tar.bz2 |
Optimization: reduce the copying of string data between C++ and javascript in proxy_resolver_v8.cc.
This is done by sharing the string storage using ExternalStringResource.
An accompanying change was to pass around the PAC script data as a UTF16 string16 rather than a UTF8 std::string -- this required changing plumbing in the other files.
This optimization will be important when creating multiple ProxyResolverV8's so they don't end up duplicating the script text.
BUG=11079
Review URL: http://codereview.chromium.org/2817043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/single_threaded_proxy_resolver_unittest.cc')
-rw-r--r-- | net/proxy/single_threaded_proxy_resolver_unittest.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/net/proxy/single_threaded_proxy_resolver_unittest.cc b/net/proxy/single_threaded_proxy_resolver_unittest.cc index 753fcdd..a84253c 100644 --- a/net/proxy/single_threaded_proxy_resolver_unittest.cc +++ b/net/proxy/single_threaded_proxy_resolver_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/string_util.h" #include "base/waitable_event.h" #include "googleurl/src/gurl.h" #include "net/base/net_log.h" @@ -55,10 +56,10 @@ class MockProxyResolver : public ProxyResolver { } virtual int SetPacScript(const GURL& pac_url, - const std::string& bytes, + const string16& text, CompletionCallback* callback) { CheckIsOnWorkerThread(); - last_pac_bytes_ = bytes; + last_pac_script_ = text; return OK; } @@ -69,7 +70,7 @@ class MockProxyResolver : public ProxyResolver { int purge_count() const { return purge_count_; } - const std::string& last_pac_bytes() const { return last_pac_bytes_; } + const string16& last_pac_script() const { return last_pac_script_; } void SetResolveLatency(int latency_ms) { resolve_latency_ms_ = latency_ms; @@ -87,7 +88,7 @@ class MockProxyResolver : public ProxyResolver { MessageLoop* wrong_loop_; int request_count_; int purge_count_; - std::string last_pac_bytes_; + string16 last_pac_script_; int resolve_latency_ms_; }; @@ -151,10 +152,11 @@ TEST(SingleThreadedProxyResolverTest, Basic) { // Call SetPacScriptByData() -- verify that it reaches the synchronous // resolver. TestCompletionCallback set_script_callback; - rv = resolver.SetPacScriptByData("pac script bytes", &set_script_callback); + rv = resolver.SetPacScriptByData(ASCIIToUTF16("pac script bytes"), + &set_script_callback); EXPECT_EQ(ERR_IO_PENDING, rv); EXPECT_EQ(OK, set_script_callback.WaitForResult()); - EXPECT_EQ("pac script bytes", mock->last_pac_bytes()); + EXPECT_EQ(ASCIIToUTF16("pac script bytes"), mock->last_pac_script()); // Start request 0. TestCompletionCallback callback0; @@ -216,7 +218,7 @@ TEST(SingleThreadedProxyResolverTest, Basic) { // we queue up a dummy request after the PurgeMemory() call and wait until it // finishes to ensure PurgeMemory() has had a chance to run. TestCompletionCallback dummy_callback; - rv = resolver.SetPacScriptByData("dummy", &dummy_callback); + rv = resolver.SetPacScriptByData(ASCIIToUTF16("dummy"), &dummy_callback); EXPECT_EQ(OK, dummy_callback.WaitForResult()); EXPECT_EQ(1, mock->purge_count()); } @@ -437,7 +439,8 @@ TEST(SingleThreadedProxyResolverTest, CancelSetPacScript) { mock->WaitUntilBlocked(); TestCompletionCallback set_pac_script_callback; - rv = resolver.SetPacScriptByData("data", &set_pac_script_callback); + rv = resolver.SetPacScriptByData(ASCIIToUTF16("data"), + &set_pac_script_callback); EXPECT_EQ(ERR_IO_PENDING, rv); // Cancel the SetPacScriptByData request (it can't have finished yet, |