OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/thread_restrictions.h" | 8 #include "base/thread_restrictions.h" |
9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
10 #include "net/url_request/url_request_test_job.h" | 10 #include "net/url_request/url_request_test_job.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 | 27 |
28 AutoUpdateInterceptor::AutoUpdateInterceptor() { | 28 AutoUpdateInterceptor::AutoUpdateInterceptor() { |
29 net::URLRequest::RegisterRequestInterceptor(this); | 29 net::URLRequest::RegisterRequestInterceptor(this); |
30 } | 30 } |
31 | 31 |
32 AutoUpdateInterceptor::~AutoUpdateInterceptor() { | 32 AutoUpdateInterceptor::~AutoUpdateInterceptor() { |
33 net::URLRequest::UnregisterRequestInterceptor(this); | 33 net::URLRequest::UnregisterRequestInterceptor(this); |
34 } | 34 } |
35 | 35 |
36 URLRequestJob* AutoUpdateInterceptor::MaybeIntercept(net::URLRequest* request) { | 36 net::URLRequestJob* AutoUpdateInterceptor::MaybeIntercept( |
| 37 net::URLRequest* request) { |
37 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 38 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
38 if (request->url().scheme() != "http" || | 39 if (request->url().scheme() != "http" || |
39 request->url().host() != "localhost") { | 40 request->url().host() != "localhost") { |
40 return NULL; | 41 return NULL; |
41 } | 42 } |
42 | 43 |
43 // It's ok to do a blocking disk access on this thread; this class | 44 // It's ok to do a blocking disk access on this thread; this class |
44 // is just used for tests. | 45 // is just used for tests. |
45 base::ThreadRestrictions::ScopedAllowIO allow_io; | 46 base::ThreadRestrictions::ScopedAllowIO allow_io; |
46 | 47 |
(...skipping 28 matching lines...) Expand all Loading... |
75 responses_[gurl] = path; | 76 responses_[gurl] = path; |
76 } | 77 } |
77 | 78 |
78 | 79 |
79 void AutoUpdateInterceptor::SetResponseOnIOThread(const std::string url, | 80 void AutoUpdateInterceptor::SetResponseOnIOThread(const std::string url, |
80 const FilePath& path) { | 81 const FilePath& path) { |
81 BrowserThread::PostTask( | 82 BrowserThread::PostTask( |
82 BrowserThread::IO, FROM_HERE, | 83 BrowserThread::IO, FROM_HERE, |
83 NewRunnableMethod(this, &AutoUpdateInterceptor::SetResponse, url, path)); | 84 NewRunnableMethod(this, &AutoUpdateInterceptor::SetResponse, url, path)); |
84 } | 85 } |
OLD | NEW |