OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/autoupdate_interceptor.h" | 5 #include "chrome/browser/extensions/autoupdate_interceptor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "net/url_request/url_request.h" |
| 12 #include "net/url_request/url_request_context.h" |
11 #include "net/url_request/url_request_test_job.h" | 13 #include "net/url_request/url_request_test_job.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 | 15 |
14 using content::BrowserThread; | 16 using content::BrowserThread; |
15 | 17 |
16 // This is a specialized version of net::URLRequestTestJob that lets us specify | 18 // This is a specialized version of net::URLRequestTestJob that lets us specify |
17 // response data and make sure the response code is 200, which the autoupdate | 19 // response data and make sure the response code is 200, which the autoupdate |
18 // code relies on. | 20 // code relies on. |
19 class AutoUpdateTestRequestJob : public net::URLRequestTestJob { | 21 class AutoUpdateTestRequestJob : public net::URLRequestTestJob { |
20 public: | 22 public: |
21 AutoUpdateTestRequestJob(net::URLRequest* request, | 23 AutoUpdateTestRequestJob(net::URLRequest* request, |
22 const std::string& response_data) | 24 const std::string& response_data) |
23 : net::URLRequestTestJob(request, | 25 : net::URLRequestTestJob(request, |
| 26 request->context()->network_delegate(), |
24 net::URLRequestTestJob::test_headers(), | 27 net::URLRequestTestJob::test_headers(), |
25 response_data, | 28 response_data, |
26 true) { | 29 true) { |
27 } | 30 } |
28 | 31 |
29 virtual int GetResponseCode() const { return 200; } | 32 virtual int GetResponseCode() const { return 200; } |
30 | 33 |
31 private: | 34 private: |
32 ~AutoUpdateTestRequestJob() {} | 35 ~AutoUpdateTestRequestJob() {} |
33 }; | 36 }; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 responses_[gurl] = path; | 87 responses_[gurl] = path; |
85 } | 88 } |
86 | 89 |
87 | 90 |
88 void AutoUpdateInterceptor::SetResponseOnIOThread(const std::string url, | 91 void AutoUpdateInterceptor::SetResponseOnIOThread(const std::string url, |
89 const FilePath& path) { | 92 const FilePath& path) { |
90 BrowserThread::PostTask( | 93 BrowserThread::PostTask( |
91 BrowserThread::IO, FROM_HERE, | 94 BrowserThread::IO, FROM_HERE, |
92 base::Bind(&AutoUpdateInterceptor::SetResponse, this, url, path)); | 95 base::Bind(&AutoUpdateInterceptor::SetResponse, this, url, path)); |
93 } | 96 } |
OLD | NEW |