Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: net/proxy/proxy_script_fetcher_impl_unittest.cc

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/proxy/proxy_script_fetcher_impl.h ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 storage_.set_http_transaction_factory(new HttpCache( 77 storage_.set_http_transaction_factory(new HttpCache(
78 network_session.get(), HttpCache::DefaultBackend::InMemory(0))); 78 network_session.get(), HttpCache::DefaultBackend::InMemory(0)));
79 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl(); 79 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl();
80 #if !defined(DISABLE_FILE_SUPPORT) 80 #if !defined(DISABLE_FILE_SUPPORT)
81 job_factory->SetProtocolHandler( 81 job_factory->SetProtocolHandler(
82 "file", new FileProtocolHandler(base::MessageLoopProxy::current())); 82 "file", new FileProtocolHandler(base::MessageLoopProxy::current()));
83 #endif 83 #endif
84 storage_.set_job_factory(job_factory); 84 storage_.set_job_factory(job_factory);
85 } 85 }
86 86
87 virtual ~RequestContext() { 87 ~RequestContext() override { AssertNoURLRequests(); }
88 AssertNoURLRequests();
89 }
90 88
91 private: 89 private:
92 URLRequestContextStorage storage_; 90 URLRequestContextStorage storage_;
93 }; 91 };
94 92
95 #if !defined(DISABLE_FILE_SUPPORT) 93 #if !defined(DISABLE_FILE_SUPPORT)
96 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest. 94 // Get a file:// url relative to net/data/proxy/proxy_script_fetcher_unittest.
97 GURL GetTestFileUrl(const std::string& relpath) { 95 GURL GetTestFileUrl(const std::string& relpath) {
98 base::FilePath path; 96 base::FilePath path;
99 PathService::Get(base::DIR_SOURCE_ROOT, &path); 97 PathService::Get(base::DIR_SOURCE_ROOT, &path);
100 path = path.AppendASCII("net"); 98 path = path.AppendASCII("net");
101 path = path.AppendASCII("data"); 99 path = path.AppendASCII("data");
102 path = path.AppendASCII("proxy_script_fetcher_unittest"); 100 path = path.AppendASCII("proxy_script_fetcher_unittest");
103 GURL base_url = FilePathToFileURL(path); 101 GURL base_url = FilePathToFileURL(path);
104 return GURL(base_url.spec() + "/" + relpath); 102 return GURL(base_url.spec() + "/" + relpath);
105 } 103 }
106 #endif // !defined(DISABLE_FILE_SUPPORT) 104 #endif // !defined(DISABLE_FILE_SUPPORT)
107 105
108 // Really simple NetworkDelegate so we can allow local file access on ChromeOS 106 // Really simple NetworkDelegate so we can allow local file access on ChromeOS
109 // without introducing layering violations. Also causes a test failure if a 107 // without introducing layering violations. Also causes a test failure if a
110 // request is seen that doesn't set a load flag to bypass revocation checking. 108 // request is seen that doesn't set a load flag to bypass revocation checking.
111 109
112 class BasicNetworkDelegate : public NetworkDelegate { 110 class BasicNetworkDelegate : public NetworkDelegate {
113 public: 111 public:
114 BasicNetworkDelegate() {} 112 BasicNetworkDelegate() {}
115 virtual ~BasicNetworkDelegate() {} 113 ~BasicNetworkDelegate() override {}
116 114
117 private: 115 private:
118 virtual int OnBeforeURLRequest(URLRequest* request, 116 int OnBeforeURLRequest(URLRequest* request,
119 const CompletionCallback& callback, 117 const CompletionCallback& callback,
120 GURL* new_url) override { 118 GURL* new_url) override {
121 EXPECT_TRUE(request->load_flags() & LOAD_DISABLE_CERT_REVOCATION_CHECKING); 119 EXPECT_TRUE(request->load_flags() & LOAD_DISABLE_CERT_REVOCATION_CHECKING);
122 return OK; 120 return OK;
123 } 121 }
124 122
125 virtual int OnBeforeSendHeaders(URLRequest* request, 123 int OnBeforeSendHeaders(URLRequest* request,
126 const CompletionCallback& callback, 124 const CompletionCallback& callback,
127 HttpRequestHeaders* headers) override { 125 HttpRequestHeaders* headers) override {
128 return OK; 126 return OK;
129 } 127 }
130 128
131 virtual void OnSendHeaders(URLRequest* request, 129 void OnSendHeaders(URLRequest* request,
132 const HttpRequestHeaders& headers) override {} 130 const HttpRequestHeaders& headers) override {}
133 131
134 virtual int OnHeadersReceived( 132 int OnHeadersReceived(
135 URLRequest* request, 133 URLRequest* request,
136 const CompletionCallback& callback, 134 const CompletionCallback& callback,
137 const HttpResponseHeaders* original_response_headers, 135 const HttpResponseHeaders* original_response_headers,
138 scoped_refptr<HttpResponseHeaders>* override_response_headers, 136 scoped_refptr<HttpResponseHeaders>* override_response_headers,
139 GURL* allowed_unsafe_redirect_url) override { 137 GURL* allowed_unsafe_redirect_url) override {
140 return OK; 138 return OK;
141 } 139 }
142 140
143 virtual void OnBeforeRedirect(URLRequest* request, 141 void OnBeforeRedirect(URLRequest* request,
144 const GURL& new_location) override {} 142 const GURL& new_location) override {}
145 143
146 virtual void OnResponseStarted(URLRequest* request) override {} 144 void OnResponseStarted(URLRequest* request) override {}
147 145
148 virtual void OnRawBytesRead(const URLRequest& request, 146 void OnRawBytesRead(const URLRequest& request, int bytes_read) override {}
149 int bytes_read) override {}
150 147
151 virtual void OnCompleted(URLRequest* request, bool started) override {} 148 void OnCompleted(URLRequest* request, bool started) override {}
152 149
153 virtual void OnURLRequestDestroyed(URLRequest* request) override {} 150 void OnURLRequestDestroyed(URLRequest* request) override {}
154 151
155 virtual void OnPACScriptError(int line_number, 152 void OnPACScriptError(int line_number, const base::string16& error) override {
156 const base::string16& error) override {} 153 }
157 154
158 virtual NetworkDelegate::AuthRequiredResponse OnAuthRequired( 155 NetworkDelegate::AuthRequiredResponse OnAuthRequired(
159 URLRequest* request, 156 URLRequest* request,
160 const AuthChallengeInfo& auth_info, 157 const AuthChallengeInfo& auth_info,
161 const AuthCallback& callback, 158 const AuthCallback& callback,
162 AuthCredentials* credentials) override { 159 AuthCredentials* credentials) override {
163 return NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; 160 return NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION;
164 } 161 }
165 162
166 virtual bool OnCanGetCookies(const URLRequest& request, 163 bool OnCanGetCookies(const URLRequest& request,
167 const CookieList& cookie_list) override { 164 const CookieList& cookie_list) override {
168 return true; 165 return true;
169 } 166 }
170 167
171 virtual bool OnCanSetCookie(const URLRequest& request, 168 bool OnCanSetCookie(const URLRequest& request,
172 const std::string& cookie_line, 169 const std::string& cookie_line,
173 CookieOptions* options) override { 170 CookieOptions* options) override {
174 return true; 171 return true;
175 } 172 }
176 173
177 virtual bool OnCanAccessFile(const net::URLRequest& request, 174 bool OnCanAccessFile(const net::URLRequest& request,
178 const base::FilePath& path) const override { 175 const base::FilePath& path) const override {
179 return true; 176 return true;
180 } 177 }
181 virtual bool OnCanThrottleRequest(const URLRequest& request) const override { 178 bool OnCanThrottleRequest(const URLRequest& request) const override {
182 return false; 179 return false;
183 } 180 }
184 181
185 virtual int OnBeforeSocketStreamConnect( 182 int OnBeforeSocketStreamConnect(SocketStream* stream,
186 SocketStream* stream, 183 const CompletionCallback& callback) override {
187 const CompletionCallback& callback) override {
188 return OK; 184 return OK;
189 } 185 }
190 186
191 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate); 187 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate);
192 }; 188 };
193 189
194 } // namespace 190 } // namespace
195 191
196 class ProxyScriptFetcherImplTest : public PlatformTest { 192 class ProxyScriptFetcherImplTest : public PlatformTest {
197 public: 193 public:
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 { 480 {
485 GURL url(kEncodedUrlBroken); 481 GURL url(kEncodedUrlBroken);
486 base::string16 text; 482 base::string16 text;
487 TestCompletionCallback callback; 483 TestCompletionCallback callback;
488 int result = pac_fetcher.Fetch(url, &text, callback.callback()); 484 int result = pac_fetcher.Fetch(url, &text, callback.callback());
489 EXPECT_EQ(ERR_FAILED, result); 485 EXPECT_EQ(ERR_FAILED, result);
490 } 486 }
491 } 487 }
492 488
493 } // namespace net 489 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_script_fetcher_impl.h ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698