| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base/layered_network_delegate.h" | 5 #include "net/base/layered_network_delegate.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool OnCanSetCookie(const URLRequest& request, | 122 bool OnCanSetCookie(const URLRequest& request, |
| 123 const std::string& cookie_line, | 123 const std::string& cookie_line, |
| 124 CookieOptions* options) override { | 124 CookieOptions* options) override { |
| 125 IncrementAndCompareCounter("on_can_set_cookie_count"); | 125 IncrementAndCompareCounter("on_can_set_cookie_count"); |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 | 128 |
| 129 bool OnCanAccessFile(const URLRequest& request, | 129 bool OnCanAccessFile(const URLRequest& request, |
| 130 const base::FilePath& path) const override { | 130 const base::FilePath& original_path, |
| 131 const base::FilePath& absolute_path) const override { |
| 131 IncrementAndCompareCounter("on_can_access_file_count"); | 132 IncrementAndCompareCounter("on_can_access_file_count"); |
| 132 return false; | 133 return false; |
| 133 } | 134 } |
| 134 | 135 |
| 135 bool OnCanEnablePrivacyMode( | 136 bool OnCanEnablePrivacyMode( |
| 136 const GURL& url, | 137 const GURL& url, |
| 137 const GURL& first_party_for_cookies) const override { | 138 const GURL& first_party_for_cookies) const override { |
| 138 IncrementAndCompareCounter("on_can_enable_privacy_mode_count"); | 139 IncrementAndCompareCounter("on_can_enable_privacy_mode_count"); |
| 139 return false; | 140 return false; |
| 140 } | 141 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 OnResponseStarted(request.get(), net::OK); | 198 OnResponseStarted(request.get(), net::OK); |
| 198 OnNetworkBytesReceived(request.get(), 42); | 199 OnNetworkBytesReceived(request.get(), 42); |
| 199 OnCompleted(request.get(), false, net::OK); | 200 OnCompleted(request.get(), false, net::OK); |
| 200 OnURLRequestDestroyed(request.get()); | 201 OnURLRequestDestroyed(request.get()); |
| 201 OnPACScriptError(0, base::string16()); | 202 OnPACScriptError(0, base::string16()); |
| 202 EXPECT_EQ( | 203 EXPECT_EQ( |
| 203 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, | 204 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, |
| 204 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); | 205 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); |
| 205 EXPECT_FALSE(OnCanGetCookies(*request, CookieList())); | 206 EXPECT_FALSE(OnCanGetCookies(*request, CookieList())); |
| 206 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL)); | 207 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL)); |
| 207 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath())); | 208 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath(), base::FilePath())); |
| 208 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL())); | 209 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL())); |
| 209 EXPECT_FALSE(OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 210 EXPECT_FALSE(OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
| 210 *request, GURL(), GURL())); | 211 *request, GURL(), GURL())); |
| 211 } | 212 } |
| 212 | 213 |
| 213 protected: | 214 protected: |
| 214 void OnBeforeURLRequestInternal(URLRequest* request, | 215 void OnBeforeURLRequestInternal(URLRequest* request, |
| 215 const CompletionCallback& callback, | 216 const CompletionCallback& callback, |
| 216 GURL* new_url) override { | 217 GURL* new_url) override { |
| 217 ++(*counters_)["on_before_url_request_count"]; | 218 ++(*counters_)["on_before_url_request_count"]; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 EXPECT_EQ(1, (*counters_)["on_can_get_cookies_count"]); | 303 EXPECT_EQ(1, (*counters_)["on_can_get_cookies_count"]); |
| 303 } | 304 } |
| 304 | 305 |
| 305 void OnCanSetCookieInternal(const URLRequest& request, | 306 void OnCanSetCookieInternal(const URLRequest& request, |
| 306 const std::string& cookie_line, | 307 const std::string& cookie_line, |
| 307 CookieOptions* options) override { | 308 CookieOptions* options) override { |
| 308 ++(*counters_)["on_can_set_cookie_count"]; | 309 ++(*counters_)["on_can_set_cookie_count"]; |
| 309 EXPECT_EQ(1, (*counters_)["on_can_set_cookie_count"]); | 310 EXPECT_EQ(1, (*counters_)["on_can_set_cookie_count"]); |
| 310 } | 311 } |
| 311 | 312 |
| 312 void OnCanAccessFileInternal(const URLRequest& request, | 313 void OnCanAccessFileInternal( |
| 313 const base::FilePath& path) const override { | 314 const URLRequest& request, |
| 315 const base::FilePath& original_path, |
| 316 const base::FilePath& absolute_path) const override { |
| 314 ++(*counters_)["on_can_access_file_count"]; | 317 ++(*counters_)["on_can_access_file_count"]; |
| 315 EXPECT_EQ(1, (*counters_)["on_can_access_file_count"]); | 318 EXPECT_EQ(1, (*counters_)["on_can_access_file_count"]); |
| 316 } | 319 } |
| 317 | 320 |
| 318 void OnCanEnablePrivacyModeInternal( | 321 void OnCanEnablePrivacyModeInternal( |
| 319 const GURL& url, | 322 const GURL& url, |
| 320 const GURL& first_party_for_cookies) const override { | 323 const GURL& first_party_for_cookies) const override { |
| 321 ++(*counters_)["on_can_enable_privacy_mode_count"]; | 324 ++(*counters_)["on_can_enable_privacy_mode_count"]; |
| 322 EXPECT_EQ(1, (*counters_)["on_can_enable_privacy_mode_count"]); | 325 EXPECT_EQ(1, (*counters_)["on_can_enable_privacy_mode_count"]); |
| 323 } | 326 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 CountersMap layered_network_delegate_counters; | 361 CountersMap layered_network_delegate_counters; |
| 359 TestNetworkDelegateImpl* test_network_delegate_; | 362 TestNetworkDelegateImpl* test_network_delegate_; |
| 360 std::unique_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; | 363 std::unique_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; |
| 361 }; | 364 }; |
| 362 | 365 |
| 363 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { | 366 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { |
| 364 layered_network_delegate_->CallAndVerify(); | 367 layered_network_delegate_->CallAndVerify(); |
| 365 } | 368 } |
| 366 | 369 |
| 367 } // namespace net | 370 } // namespace net |
| OLD | NEW |