| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/component_updater/test/url_request_post_interceptor.h" | 5 #include "components/component_updater/test/url_request_post_interceptor.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 DCHECK(interceptors_.find(interceptor->GetUrl()) == interceptors_.end()); | 166 DCHECK(interceptors_.find(interceptor->GetUrl()) == interceptors_.end()); |
| 167 | 167 |
| 168 interceptors_.insert(std::make_pair(interceptor->GetUrl(), interceptor)); | 168 interceptors_.insert(std::make_pair(interceptor->GetUrl(), interceptor)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 private: | 171 private: |
| 172 ~Delegate() override {} | 172 ~Delegate() override {} |
| 173 | 173 |
| 174 net::URLRequestJob* MaybeInterceptRequest( | 174 net::URLRequestJob* MaybeInterceptRequest( |
| 175 net::URLRequest* request, | 175 net::URLRequest* request, |
| 176 net::NetworkDelegate* network_delegate) const override { | 176 net::NetworkDelegate* network_delegate) override { |
| 177 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 177 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
| 178 | 178 |
| 179 // Only intercepts POST. | 179 // Only intercepts POST. |
| 180 if (!request->has_upload()) | 180 if (!request->has_upload()) |
| 181 return NULL; | 181 return NULL; |
| 182 | 182 |
| 183 GURL url = request->url(); | 183 GURL url = request->url(); |
| 184 if (url.has_query()) { | 184 if (url.has_query()) { |
| 185 GURL::Replacements replacements; | 185 GURL::Replacements replacements; |
| 186 replacements.ClearQuery(); | 186 replacements.ClearQuery(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 ++interceptor->hit_count_; | 219 ++interceptor->hit_count_; |
| 220 | 220 |
| 221 return new URLRequestMockJob( | 221 return new URLRequestMockJob( |
| 222 request, network_delegate, response_code, response_body); | 222 request, network_delegate, response_code, response_body); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 return NULL; | 226 return NULL; |
| 227 } | 227 } |
| 228 | 228 |
| 229 net::URLRequestJob* MaybeInterceptRedirect( |
| 230 net::URLRequest* request, |
| 231 net::NetworkDelegate* network_delegate, |
| 232 const GURL& location) override { |
| 233 return NULL; |
| 234 } |
| 235 |
| 236 net::URLRequestJob* MaybeInterceptResponse( |
| 237 net::URLRequest* request, |
| 238 net::NetworkDelegate* network_delegate) override { |
| 239 return NULL; |
| 240 } |
| 241 |
| 229 typedef std::map<GURL, URLRequestPostInterceptor*> InterceptorMap; | 242 typedef std::map<GURL, URLRequestPostInterceptor*> InterceptorMap; |
| 230 InterceptorMap interceptors_; | 243 InterceptorMap interceptors_; |
| 231 | 244 |
| 232 const std::string scheme_; | 245 const std::string scheme_; |
| 233 const std::string hostname_; | 246 const std::string hostname_; |
| 234 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; | 247 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; |
| 235 | 248 |
| 236 DISALLOW_COPY_AND_ASSIGN(Delegate); | 249 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 237 }; | 250 }; |
| 238 | 251 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 return CreateInterceptorForPath(POST_INTERCEPT_PATH); | 310 return CreateInterceptorForPath(POST_INTERCEPT_PATH); |
| 298 } | 311 } |
| 299 | 312 |
| 300 URLRequestPostInterceptor* InterceptorFactory::CreateInterceptorForPath( | 313 URLRequestPostInterceptor* InterceptorFactory::CreateInterceptorForPath( |
| 301 const char* url_path) { | 314 const char* url_path) { |
| 302 return URLRequestPostInterceptorFactory::CreateInterceptor( | 315 return URLRequestPostInterceptorFactory::CreateInterceptor( |
| 303 base::FilePath::FromUTF8Unsafe(url_path)); | 316 base::FilePath::FromUTF8Unsafe(url_path)); |
| 304 } | 317 } |
| 305 | 318 |
| 306 } // namespace component_updater | 319 } // namespace component_updater |
| OLD | NEW |