| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/proxy/proxy_script_fetcher_impl.h" | 5 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 storage_.set_job_factory(job_factory); | 84 storage_.set_job_factory(job_factory); |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual ~RequestContext() { | 87 virtual ~RequestContext() { |
| 88 } | 88 } |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 URLRequestContextStorage storage_; | 91 URLRequestContextStorage storage_; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 #if !defined(DISABLE_FILE_SUPPORT) |
| 94 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest. | 95 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest. |
| 95 GURL GetTestFileUrl(const std::string& relpath) { | 96 GURL GetTestFileUrl(const std::string& relpath) { |
| 96 base::FilePath path; | 97 base::FilePath path; |
| 97 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 98 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
| 98 path = path.AppendASCII("net"); | 99 path = path.AppendASCII("net"); |
| 99 path = path.AppendASCII("data"); | 100 path = path.AppendASCII("data"); |
| 100 path = path.AppendASCII("proxy_script_fetcher_unittest"); | 101 path = path.AppendASCII("proxy_script_fetcher_unittest"); |
| 101 GURL base_url = FilePathToFileURL(path); | 102 GURL base_url = FilePathToFileURL(path); |
| 102 return GURL(base_url.spec() + "/" + relpath); | 103 return GURL(base_url.spec() + "/" + relpath); |
| 103 } | 104 } |
| 105 #endif // !defined(DISABLE_FILE_SUPPORT) |
| 104 | 106 |
| 105 // Really simple NetworkDelegate so we can allow local file access on ChromeOS | 107 // Really simple NetworkDelegate so we can allow local file access on ChromeOS |
| 106 // without introducing layering violations. Also causes a test failure if a | 108 // without introducing layering violations. Also causes a test failure if a |
| 107 // request is seen that doesn't set a load flag to bypass revocation checking. | 109 // request is seen that doesn't set a load flag to bypass revocation checking. |
| 108 | 110 |
| 109 class BasicNetworkDelegate : public NetworkDelegate { | 111 class BasicNetworkDelegate : public NetworkDelegate { |
| 110 public: | 112 public: |
| 111 BasicNetworkDelegate() {} | 113 BasicNetworkDelegate() {} |
| 112 virtual ~BasicNetworkDelegate() {} | 114 virtual ~BasicNetworkDelegate() {} |
| 113 | 115 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 ASSERT_TRUE(test_server_.Start()); | 347 ASSERT_TRUE(test_server_.Start()); |
| 346 | 348 |
| 347 ProxyScriptFetcherImpl pac_fetcher(&context_); | 349 ProxyScriptFetcherImpl pac_fetcher(&context_); |
| 348 | 350 |
| 349 // Set the maximum response size to 50 bytes. | 351 // Set the maximum response size to 50 bytes. |
| 350 int prev_size = pac_fetcher.SetSizeConstraint(50); | 352 int prev_size = pac_fetcher.SetSizeConstraint(50); |
| 351 | 353 |
| 352 // These two URLs are the same file, but are http:// vs file:// | 354 // These two URLs are the same file, but are http:// vs file:// |
| 353 GURL urls[] = { | 355 GURL urls[] = { |
| 354 test_server_.GetURL("files/large-pac.nsproxy"), | 356 test_server_.GetURL("files/large-pac.nsproxy"), |
| 357 #if !defined(DISABLE_FILE_SUPPORT) |
| 355 GetTestFileUrl("large-pac.nsproxy") | 358 GetTestFileUrl("large-pac.nsproxy") |
| 359 #endif |
| 356 }; | 360 }; |
| 357 | 361 |
| 358 // Try fetching URLs that are 101 bytes large. We should abort the request | 362 // Try fetching URLs that are 101 bytes large. We should abort the request |
| 359 // after 50 bytes have been read, and fail with a too large error. | 363 // after 50 bytes have been read, and fail with a too large error. |
| 360 for (size_t i = 0; i < arraysize(urls); ++i) { | 364 for (size_t i = 0; i < arraysize(urls); ++i) { |
| 361 const GURL& url = urls[i]; | 365 const GURL& url = urls[i]; |
| 362 base::string16 text; | 366 base::string16 text; |
| 363 TestCompletionCallback callback; | 367 TestCompletionCallback callback; |
| 364 int result = pac_fetcher.Fetch(url, &text, callback.callback()); | 368 int result = pac_fetcher.Fetch(url, &text, callback.callback()); |
| 365 EXPECT_EQ(ERR_IO_PENDING, result); | 369 EXPECT_EQ(ERR_IO_PENDING, result); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 { | 483 { |
| 480 GURL url(kEncodedUrlBroken); | 484 GURL url(kEncodedUrlBroken); |
| 481 base::string16 text; | 485 base::string16 text; |
| 482 TestCompletionCallback callback; | 486 TestCompletionCallback callback; |
| 483 int result = pac_fetcher.Fetch(url, &text, callback.callback()); | 487 int result = pac_fetcher.Fetch(url, &text, callback.callback()); |
| 484 EXPECT_EQ(ERR_FAILED, result); | 488 EXPECT_EQ(ERR_FAILED, result); |
| 485 } | 489 } |
| 486 } | 490 } |
| 487 | 491 |
| 488 } // namespace net | 492 } // namespace net |
| OLD | NEW |