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

Side by Side Diff: net/url_request/test_url_request_interceptor.cc

Issue 2894863002: Rename TaskRunner::RunsTasksOnCurrentThread() in //net (Closed)
Patch Set: fixed build error Created 3 years, 7 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/ssl/channel_id_service.cc ('k') | net/url_request/url_fetcher_core.cc » ('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/url_request/test_url_request_interceptor.h" 5 #include "net/url_request/test_url_request_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/threading/sequenced_worker_pool.h" 9 #include "base/threading/sequenced_worker_pool.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const std::string& hostname) { 70 const std::string& hostname) {
71 URLRequestFilter::GetInstance()->RemoveHostnameHandler(scheme, hostname); 71 URLRequestFilter::GetInstance()->RemoveHostnameHandler(scheme, hostname);
72 } 72 }
73 73
74 // When requests for |url| arrive, respond with the contents of |path|. The 74 // When requests for |url| arrive, respond with the contents of |path|. The
75 // hostname and scheme of |url| must match the corresponding parameters 75 // hostname and scheme of |url| must match the corresponding parameters
76 // passed as constructor arguments. 76 // passed as constructor arguments.
77 void SetResponse(const GURL& url, 77 void SetResponse(const GURL& url,
78 const base::FilePath& path, 78 const base::FilePath& path,
79 bool ignore_query) { 79 bool ignore_query) {
80 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 80 DCHECK(network_task_runner_->RunsTasksInCurrentSequence());
81 if (ignore_query) { 81 if (ignore_query) {
82 ignore_query_responses_[url] = path; 82 ignore_query_responses_[url] = path;
83 } else { 83 } else {
84 responses_[url] = path; 84 responses_[url] = path;
85 } 85 }
86 } 86 }
87 87
88 // Returns how many requests have been issued that have a stored reply. 88 // Returns how many requests have been issued that have a stored reply.
89 int GetHitCount() const { 89 int GetHitCount() const {
90 base::AutoLock auto_lock(hit_count_lock_); 90 base::AutoLock auto_lock(hit_count_lock_);
91 return hit_count_; 91 return hit_count_;
92 } 92 }
93 93
94 private: 94 private:
95 typedef std::map<GURL, base::FilePath> ResponseMap; 95 typedef std::map<GURL, base::FilePath> ResponseMap;
96 96
97 // When computing matches, this ignores the query parameters of the url. 97 // When computing matches, this ignores the query parameters of the url.
98 URLRequestJob* MaybeInterceptRequest( 98 URLRequestJob* MaybeInterceptRequest(
99 URLRequest* request, 99 URLRequest* request,
100 NetworkDelegate* network_delegate) const override { 100 NetworkDelegate* network_delegate) const override {
101 DCHECK(network_task_runner_->RunsTasksOnCurrentThread()); 101 DCHECK(network_task_runner_->RunsTasksInCurrentSequence());
102 if (request->url().scheme() != scheme_ || 102 if (request->url().scheme() != scheme_ ||
103 request->url().host() != hostname_) { 103 request->url().host() != hostname_) {
104 return NULL; 104 return NULL;
105 } 105 }
106 106
107 ResponseMap::const_iterator it = responses_.find(request->url()); 107 ResponseMap::const_iterator it = responses_.find(request->url());
108 if (it == responses_.end()) { 108 if (it == responses_.end()) {
109 // Search for this request's url, ignoring any query parameters. 109 // Search for this request's url, ignoring any query parameters.
110 GURL url = request->url(); 110 GURL url = request->url();
111 if (url.has_query()) { 111 if (url.has_query()) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 LocalHostTestURLRequestInterceptor::LocalHostTestURLRequestInterceptor( 194 LocalHostTestURLRequestInterceptor::LocalHostTestURLRequestInterceptor(
195 const scoped_refptr<base::TaskRunner>& network_task_runner, 195 const scoped_refptr<base::TaskRunner>& network_task_runner,
196 const scoped_refptr<base::TaskRunner>& worker_task_runner) 196 const scoped_refptr<base::TaskRunner>& worker_task_runner)
197 : TestURLRequestInterceptor("http", 197 : TestURLRequestInterceptor("http",
198 "localhost", 198 "localhost",
199 network_task_runner, 199 network_task_runner,
200 worker_task_runner) { 200 worker_task_runner) {
201 } 201 }
202 202
203 } // namespace net 203 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/channel_id_service.cc ('k') | net/url_request/url_fetcher_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698