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 "content/test/net/url_request_prepackaged_interceptor.h" | 5 #include "content/test/net/url_request_prepackaged_interceptor.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/threading/thread_restrictions.h" | 8 #include "base/threading/thread_restrictions.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // When requests for |url| arrive, respond with the contents of |path|. The | 58 // When requests for |url| arrive, respond with the contents of |path|. The |
59 // hostname and scheme of |url| must match the corresponding parameters | 59 // hostname and scheme of |url| must match the corresponding parameters |
60 // passed as constructor arguments. | 60 // passed as constructor arguments. |
61 void SetResponse(const GURL& url, | 61 void SetResponse(const GURL& url, |
62 const base::FilePath& path, | 62 const base::FilePath& path, |
63 bool ignore_query) { | 63 bool ignore_query) { |
64 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 64 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
65 // It's ok to do a blocking disk access on this thread; this class | 65 // It's ok to do a blocking disk access on this thread; this class |
66 // is just used for tests. | 66 // is just used for tests. |
67 base::ThreadRestrictions::ScopedAllowIO allow_io; | 67 base::ThreadRestrictions::ScopedAllowIO allow_io; |
68 EXPECT_TRUE(file_util::PathExists(path)); | 68 EXPECT_TRUE(base::PathExists(path)); |
69 if (ignore_query) { | 69 if (ignore_query) { |
70 ignore_query_responses_[url] = path; | 70 ignore_query_responses_[url] = path; |
71 } else { | 71 } else { |
72 responses_[url] = path; | 72 responses_[url] = path; |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 // Returns how many requests have been issued that have a stored reply. | 76 // Returns how many requests have been issued that have a stored reply. |
77 int GetHitCount() const { | 77 int GetHitCount() const { |
78 base::AutoLock auto_lock(hit_count_lock_); | 78 base::AutoLock auto_lock(hit_count_lock_); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 return delegate_->GetHitCount(); | 172 return delegate_->GetHitCount(); |
173 } | 173 } |
174 | 174 |
175 | 175 |
176 URLLocalHostRequestPrepackagedInterceptor | 176 URLLocalHostRequestPrepackagedInterceptor |
177 ::URLLocalHostRequestPrepackagedInterceptor() | 177 ::URLLocalHostRequestPrepackagedInterceptor() |
178 : URLRequestPrepackagedInterceptor("http", "localhost") { | 178 : URLRequestPrepackagedInterceptor("http", "localhost") { |
179 } | 179 } |
180 | 180 |
181 } // namespace content | 181 } // namespace content |
OLD | NEW |