| 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 #include "chrome/browser/component_updater/component_updater_interceptor.h" | 4 #include "chrome/browser/component_updater/component_updater_interceptor.h" |
| 5 | 5 |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/threading/thread_restrictions.h" | 7 #include "base/threading/thread_restrictions.h" |
| 8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
| 9 #include "net/url_request/url_request_test_job.h" | 9 #include "net/url_request/url_request_test_job.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 ComponentUpdateInterceptor::ComponentUpdateInterceptor() { | 12 ComponentUpdateInterceptor::ComponentUpdateInterceptor() { |
| 13 net::URLRequest::RegisterRequestInterceptor(this); | 13 net::URLRequest::Deprecated::RegisterRequestInterceptor(this); |
| 14 } | 14 } |
| 15 | 15 |
| 16 ComponentUpdateInterceptor::~ComponentUpdateInterceptor() { | 16 ComponentUpdateInterceptor::~ComponentUpdateInterceptor() { |
| 17 net::URLRequest::UnregisterRequestInterceptor(this); | 17 net::URLRequest::Deprecated::UnregisterRequestInterceptor(this); |
| 18 } | 18 } |
| 19 | 19 |
| 20 net::URLRequestJob* ComponentUpdateInterceptor::MaybeIntercept( | 20 net::URLRequestJob* ComponentUpdateInterceptor::MaybeIntercept( |
| 21 net::URLRequest* request) { | 21 net::URLRequest* request) { |
| 22 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 22 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 23 if (request->url().scheme() != "http" || | 23 if (request->url().scheme() != "http" || |
| 24 request->url().host() != "localhost") { | 24 request->url().host() != "localhost") { |
| 25 return NULL; | 25 return NULL; |
| 26 } | 26 } |
| 27 | 27 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 // It's ok to do a blocking disk access on this thread; this class | 50 // It's ok to do a blocking disk access on this thread; this class |
| 51 // is just used for tests. | 51 // is just used for tests. |
| 52 base::ThreadRestrictions::ScopedAllowIO allow_io; | 52 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 53 GURL gurl(url); | 53 GURL gurl(url); |
| 54 EXPECT_EQ("http", gurl.scheme()); | 54 EXPECT_EQ("http", gurl.scheme()); |
| 55 EXPECT_EQ("localhost", gurl.host()); | 55 EXPECT_EQ("localhost", gurl.host()); |
| 56 EXPECT_TRUE(file_util::PathExists(path)); | 56 EXPECT_TRUE(file_util::PathExists(path)); |
| 57 Response response = { path, headers }; | 57 Response response = { path, headers }; |
| 58 responses_[gurl] = response; | 58 responses_[gurl] = response; |
| 59 } | 59 } |
| OLD | NEW |