| 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_test_job.h" | 11 #include "net/url_request/url_request_test_job.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using content::BrowserThread; | 14 using content::BrowserThread; |
| 15 | 15 |
| 16 namespace extensions { |
| 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, |
| 24 net::URLRequestTestJob::test_headers(), | 26 net::URLRequestTestJob::test_headers(), |
| 25 response_data, | 27 response_data, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 responses_[gurl] = path; | 86 responses_[gurl] = path; |
| 85 } | 87 } |
| 86 | 88 |
| 87 | 89 |
| 88 void AutoUpdateInterceptor::SetResponseOnIOThread(const std::string url, | 90 void AutoUpdateInterceptor::SetResponseOnIOThread(const std::string url, |
| 89 const FilePath& path) { | 91 const FilePath& path) { |
| 90 BrowserThread::PostTask( | 92 BrowserThread::PostTask( |
| 91 BrowserThread::IO, FROM_HERE, | 93 BrowserThread::IO, FROM_HERE, |
| 92 base::Bind(&AutoUpdateInterceptor::SetResponse, this, url, path)); | 94 base::Bind(&AutoUpdateInterceptor::SetResponse, this, url, path)); |
| 93 } | 95 } |
| 96 |
| 97 } // namespace extensions |
| OLD | NEW |