diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 23:40:15 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 23:40:15 +0000 |
commit | 88fb4ada915e7f37a6ac939c10ef0ff96889dc71 (patch) | |
tree | e7457fbdbde126435002d6e29d1c7d1565d19ec7 | |
parent | bd18902708017f8b22ed9a4c6e9b3e1b130f2a4c (diff) | |
download | chromium_src-88fb4ada915e7f37a6ac939c10ef0ff96889dc71.zip chromium_src-88fb4ada915e7f37a6ac939c10ef0ff96889dc71.tar.gz chromium_src-88fb4ada915e7f37a6ac939c10ef0ff96889dc71.tar.bz2 |
Convert the HTTP cache to use FilePath rather than wstring for the
disk cache path.
BUG=24672
Review URL: http://codereview.chromium.org/276048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29213 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/net/chrome_url_request_context.cc | 6 | ||||
-rw-r--r-- | net/http/http_cache.cc | 11 | ||||
-rw-r--r-- | net/http/http_cache.h | 7 | ||||
-rw-r--r-- | webkit/tools/test_shell/node_leak_test.cc | 2 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_request_context.cc | 7 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_request_context.h | 6 |
7 files changed, 22 insertions, 20 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 6d6632c..7d713d8 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -131,7 +131,7 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateOriginal( new net::HttpCache(context->host_resolver_, context->proxy_service_, context->ssl_config_service_, - disk_cache_path.ToWStringHack(), cache_size); + disk_cache_path, cache_size); if (command_line.HasSwitch(switches::kEnableByteRangeSupport)) cache->set_enable_range_support(true); @@ -297,14 +297,14 @@ ChromeURLRequestContext* ChromeURLRequestContext::CreateRequestContextForMedia( net::HttpNetworkLayer* original_network_layer = static_cast<net::HttpNetworkLayer*>(original_cache->network_layer()); cache = new net::HttpCache(original_network_layer->GetSession(), - disk_cache_path.ToWStringHack(), cache_size); + disk_cache_path, cache_size); } else { // If original HttpCache doesn't exist, simply construct one with a whole // new set of network stack. cache = new net::HttpCache(original_context->host_resolver(), original_context->proxy_service(), original_context->ssl_config_service(), - disk_cache_path.ToWStringHack(), cache_size); + disk_cache_path, cache_size); } if (CommandLine::ForCurrentProcess()->HasSwitch( diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index 86544c6..ded4565 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -1589,7 +1589,7 @@ void HttpCache::Transaction::OnCacheEntryReady(int result) { HttpCache::HttpCache(HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service, - const std::wstring& cache_dir, + const FilePath& cache_dir, int cache_size) : disk_cache_dir_(cache_dir), mode_(NORMAL), @@ -1603,7 +1603,7 @@ HttpCache::HttpCache(HostResolver* host_resolver, } HttpCache::HttpCache(HttpNetworkSession* session, - const std::wstring& cache_dir, + const FilePath& cache_dir, int cache_size) : disk_cache_dir_(cache_dir), mode_(NORMAL), @@ -1670,10 +1670,9 @@ int HttpCache::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { // was an in-memory cache. disk_cache_.reset(disk_cache::CreateInMemoryCacheBackend(cache_size_)); } else if (!disk_cache_dir_.empty()) { - disk_cache_.reset(disk_cache::CreateCacheBackend( - FilePath::FromWStringHack(disk_cache_dir_), true, cache_size_, - type_)); - disk_cache_dir_.clear(); // Reclaim memory. + disk_cache_.reset(disk_cache::CreateCacheBackend(disk_cache_dir_, true, + cache_size_, type_)); + disk_cache_dir_ = FilePath(); // Reclaim memory. } } trans->reset(new HttpCache::Transaction(this, enable_range_support_)); diff --git a/net/http/http_cache.h b/net/http/http_cache.h index 35d16c6..fe77912 100644 --- a/net/http/http_cache.h +++ b/net/http/http_cache.h @@ -18,6 +18,7 @@ #include <set> #include "base/basictypes.h" +#include "base/file_path.h" #include "base/hash_tables.h" #include "base/scoped_ptr.h" #include "base/task.h" @@ -64,7 +65,7 @@ class HttpCache : public HttpTransactionFactory, HttpCache(HostResolver* host_resolver, ProxyService* proxy_service, SSLConfigService* ssl_config_service, - const std::wstring& cache_dir, + const FilePath& cache_dir, int cache_size); // Initialize the cache from the directory where its data is stored. The @@ -73,7 +74,7 @@ class HttpCache : public HttpTransactionFactory, // Provide an existing HttpNetworkSession, the cache can construct a // network layer with a shared HttpNetworkSession in order for multiple // network layers to share information (e.g. authenication data). - HttpCache(HttpNetworkSession* session, const std::wstring& cache_dir, + HttpCache(HttpNetworkSession* session, const FilePath& cache_dir, int cache_size); // Initialize using an in-memory cache. The cache is initialized lazily @@ -186,7 +187,7 @@ class HttpCache : public HttpTransactionFactory, // Variables ---------------------------------------------------------------- // used when lazily constructing the disk_cache_ - std::wstring disk_cache_dir_; + FilePath disk_cache_dir_; Mode mode_; CacheType type_; diff --git a/webkit/tools/test_shell/node_leak_test.cc b/webkit/tools/test_shell/node_leak_test.cc index dc5a2b8..bfa0408 100644 --- a/webkit/tools/test_shell/node_leak_test.cc +++ b/webkit/tools/test_shell/node_leak_test.cc @@ -53,7 +53,7 @@ class NodeLeakTest : public TestShellTest { parsed_command_line.HasSwitch(test_shell::kPlaybackMode) ? net::HttpCache::PLAYBACK : net::HttpCache::NORMAL; SimpleResourceLoaderBridge::Init( - new TestShellRequestContext(cache_path.ToWStringHack(), mode, false)); + new TestShellRequestContext(cache_path, mode, false)); TestShellTest::SetUp(); } diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 3b00164..b00a348 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -143,8 +143,7 @@ int main(int argc, char* argv[]) { // Initializing with a default context, which means no on-disk cookie DB, // and no support for directory listings. SimpleResourceLoaderBridge::Init( - new TestShellRequestContext(cache_path.ToWStringHack(), - cache_mode, layout_test_mode)); + new TestShellRequestContext(cache_path, cache_mode, layout_test_mode)); // Load ICU data tables icu_util::Initialize(); diff --git a/webkit/tools/test_shell/test_shell_request_context.cc b/webkit/tools/test_shell/test_shell_request_context.cc index b016c94..a673d87 100644 --- a/webkit/tools/test_shell/test_shell_request_context.cc +++ b/webkit/tools/test_shell/test_shell_request_context.cc @@ -6,6 +6,7 @@ #include "build/build_config.h" +#include "base/file_path.h" #include "net/base/cookie_monster.h" #include "net/base/host_resolver.h" #include "net/base/ssl_config_service.h" @@ -14,18 +15,18 @@ #include "webkit/glue/webkit_glue.h" TestShellRequestContext::TestShellRequestContext() { - Init(std::wstring(), net::HttpCache::NORMAL, false); + Init(FilePath(), net::HttpCache::NORMAL, false); } TestShellRequestContext::TestShellRequestContext( - const std::wstring& cache_path, + const FilePath& cache_path, net::HttpCache::Mode cache_mode, bool no_proxy) { Init(cache_path, cache_mode, no_proxy); } void TestShellRequestContext::Init( - const std::wstring& cache_path, + const FilePath& cache_path, net::HttpCache::Mode cache_mode, bool no_proxy) { cookie_store_ = new net::CookieMonster(); diff --git a/webkit/tools/test_shell/test_shell_request_context.h b/webkit/tools/test_shell/test_shell_request_context.h index befb630..332107f 100644 --- a/webkit/tools/test_shell/test_shell_request_context.h +++ b/webkit/tools/test_shell/test_shell_request_context.h @@ -8,6 +8,8 @@ #include "net/http/http_cache.h" #include "net/url_request/url_request_context.h" +class FilePath; + // A basic URLRequestContext that only provides an in-memory cookie store. class TestShellRequestContext : public URLRequestContext { public: @@ -16,7 +18,7 @@ class TestShellRequestContext : public URLRequestContext { // Use an on-disk cache at the specified location. Optionally, use the cache // in playback or record mode. - TestShellRequestContext(const std::wstring& cache_path, + TestShellRequestContext(const FilePath& cache_path, net::HttpCache::Mode cache_mode, bool no_proxy); @@ -25,7 +27,7 @@ class TestShellRequestContext : public URLRequestContext { virtual const std::string& GetUserAgent(const GURL& url) const; private: - void Init(const std::wstring& cache_path, net::HttpCache::Mode cache_mode, + void Init(const FilePath& cache_path, net::HttpCache::Mode cache_mode, bool no_proxy); }; |