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/url_request/url_request_ftp_job.h" | 5 #include "net/url_request/url_request_ftp_job.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 namespace { | 61 namespace { |
62 | 62 |
63 class SimpleProxyConfigService : public ProxyConfigService { | 63 class SimpleProxyConfigService : public ProxyConfigService { |
64 public: | 64 public: |
65 SimpleProxyConfigService() { | 65 SimpleProxyConfigService() { |
66 // Any FTP requests that ever go through HTTP paths are proxied requests. | 66 // Any FTP requests that ever go through HTTP paths are proxied requests. |
67 config_.proxy_rules().ParseFromString("ftp=localhost"); | 67 config_.proxy_rules().ParseFromString("ftp=localhost"); |
68 } | 68 } |
69 | 69 |
70 virtual void AddObserver(Observer* observer) OVERRIDE { | 70 virtual void AddObserver(Observer* observer) override { |
71 observer_ = observer; | 71 observer_ = observer; |
72 } | 72 } |
73 | 73 |
74 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 74 virtual void RemoveObserver(Observer* observer) override { |
75 if (observer_ == observer) { | 75 if (observer_ == observer) { |
76 observer_ = NULL; | 76 observer_ = NULL; |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 virtual ConfigAvailability GetLatestProxyConfig( | 80 virtual ConfigAvailability GetLatestProxyConfig( |
81 ProxyConfig* config) OVERRIDE { | 81 ProxyConfig* config) override { |
82 *config = config_; | 82 *config = config_; |
83 return CONFIG_VALID; | 83 return CONFIG_VALID; |
84 } | 84 } |
85 | 85 |
86 void IncrementConfigId() { | 86 void IncrementConfigId() { |
87 config_.set_id(config_.id() + 1); | 87 config_.set_id(config_.id() + 1); |
88 observer_->OnProxyConfigChanged(config_, ProxyConfigService::CONFIG_VALID); | 88 observer_->OnProxyConfigChanged(config_, ProxyConfigService::CONFIG_VALID); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
(...skipping 14 matching lines...) Expand all Loading... |
106 using URLRequestFtpJob::Start; | 106 using URLRequestFtpJob::Start; |
107 using URLRequestFtpJob::Kill; | 107 using URLRequestFtpJob::Kill; |
108 using URLRequestFtpJob::priority; | 108 using URLRequestFtpJob::priority; |
109 | 109 |
110 protected: | 110 protected: |
111 virtual ~TestURLRequestFtpJob() {} | 111 virtual ~TestURLRequestFtpJob() {} |
112 }; | 112 }; |
113 | 113 |
114 class MockFtpTransactionFactory : public FtpTransactionFactory { | 114 class MockFtpTransactionFactory : public FtpTransactionFactory { |
115 public: | 115 public: |
116 virtual FtpTransaction* CreateTransaction() OVERRIDE { | 116 virtual FtpTransaction* CreateTransaction() override { |
117 return NULL; | 117 return NULL; |
118 } | 118 } |
119 | 119 |
120 virtual void Suspend(bool suspend) OVERRIDE {} | 120 virtual void Suspend(bool suspend) override {} |
121 }; | 121 }; |
122 | 122 |
123 // Fixture for priority-related tests. Priority matters when there is | 123 // Fixture for priority-related tests. Priority matters when there is |
124 // an HTTP proxy. | 124 // an HTTP proxy. |
125 class URLRequestFtpJobPriorityTest : public testing::Test { | 125 class URLRequestFtpJobPriorityTest : public testing::Test { |
126 protected: | 126 protected: |
127 URLRequestFtpJobPriorityTest() | 127 URLRequestFtpJobPriorityTest() |
128 : proxy_service_(new SimpleProxyConfigService, NULL, NULL), | 128 : proxy_service_(new SimpleProxyConfigService, NULL, NULL), |
129 req_(context_.CreateRequest(GURL("ftp://ftp.example.com"), | 129 req_(context_.CreateRequest(GURL("ftp://ftp.example.com"), |
130 DEFAULT_PRIORITY, | 130 DEFAULT_PRIORITY, |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 EXPECT_TRUE(url_request2->status().is_success()); | 702 EXPECT_TRUE(url_request2->status().is_success()); |
703 EXPECT_EQ(2, network_delegate()->completed_requests()); | 703 EXPECT_EQ(2, network_delegate()->completed_requests()); |
704 EXPECT_EQ(0, network_delegate()->error_count()); | 704 EXPECT_EQ(0, network_delegate()->error_count()); |
705 EXPECT_FALSE(request_delegate2.auth_required_called()); | 705 EXPECT_FALSE(request_delegate2.auth_required_called()); |
706 EXPECT_EQ("test2.html", request_delegate2.data_received()); | 706 EXPECT_EQ("test2.html", request_delegate2.data_received()); |
707 } | 707 } |
708 | 708 |
709 } // namespace | 709 } // namespace |
710 | 710 |
711 } // namespace net | 711 } // namespace net |
OLD | NEW |