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 "base/files/file_util.h" | 5 #include "base/files/file_util.h" |
6 #include "base/json/json_file_value_serializer.h" | 6 #include "base/json/json_file_value_serializer.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 class ThrottleController : public base::SupportsUserData::Data, | 41 class ThrottleController : public base::SupportsUserData::Data, |
42 public ResourceController { | 42 public ResourceController { |
43 public: | 43 public: |
44 ThrottleController(net::URLRequest* request, ResourceThrottle* throttle) | 44 ThrottleController(net::URLRequest* request, ResourceThrottle* throttle) |
45 : request_(request), | 45 : request_(request), |
46 throttle_(throttle) { | 46 throttle_(throttle) { |
47 throttle_->set_controller_for_testing(this); | 47 throttle_->set_controller_for_testing(this); |
48 } | 48 } |
49 | 49 |
50 // ResourceController implementation: | 50 // ResourceController implementation: |
51 virtual void Resume() OVERRIDE { | 51 virtual void Resume() override { |
52 request_->Start(); | 52 request_->Start(); |
53 } | 53 } |
54 virtual void Cancel() OVERRIDE { | 54 virtual void Cancel() override { |
55 NOTREACHED(); | 55 NOTREACHED(); |
56 } | 56 } |
57 virtual void CancelAndIgnore() OVERRIDE { | 57 virtual void CancelAndIgnore() override { |
58 NOTREACHED(); | 58 NOTREACHED(); |
59 } | 59 } |
60 virtual void CancelWithError(int error_code) OVERRIDE { | 60 virtual void CancelWithError(int error_code) override { |
61 NOTREACHED(); | 61 NOTREACHED(); |
62 } | 62 } |
63 | 63 |
64 private: | 64 private: |
65 net::URLRequest* request_; | 65 net::URLRequest* request_; |
66 scoped_ptr<ResourceThrottle> throttle_; | 66 scoped_ptr<ResourceThrottle> throttle_; |
67 }; | 67 }; |
68 | 68 |
69 // A simple test net::URLRequestJob. We don't care what it does, only that | 69 // A simple test net::URLRequestJob. We don't care what it does, only that |
70 // whether it starts and finishes. | 70 // whether it starts and finishes. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 class SimpleTestJobURLRequestInterceptor | 108 class SimpleTestJobURLRequestInterceptor |
109 : public net::URLRequestInterceptor { | 109 : public net::URLRequestInterceptor { |
110 public: | 110 public: |
111 SimpleTestJobURLRequestInterceptor() {} | 111 SimpleTestJobURLRequestInterceptor() {} |
112 virtual ~SimpleTestJobURLRequestInterceptor() {} | 112 virtual ~SimpleTestJobURLRequestInterceptor() {} |
113 | 113 |
114 // net::URLRequestJobFactory::ProtocolHandler | 114 // net::URLRequestJobFactory::ProtocolHandler |
115 virtual net::URLRequestJob* MaybeInterceptRequest( | 115 virtual net::URLRequestJob* MaybeInterceptRequest( |
116 net::URLRequest* request, | 116 net::URLRequest* request, |
117 net::NetworkDelegate* network_delegate) const OVERRIDE { | 117 net::NetworkDelegate* network_delegate) const override { |
118 return new SimpleTestJob(request, network_delegate); | 118 return new SimpleTestJob(request, network_delegate); |
119 } | 119 } |
120 | 120 |
121 private: | 121 private: |
122 DISALLOW_COPY_AND_ASSIGN(SimpleTestJobURLRequestInterceptor); | 122 DISALLOW_COPY_AND_ASSIGN(SimpleTestJobURLRequestInterceptor); |
123 }; | 123 }; |
124 | 124 |
125 } // namespace | 125 } // namespace |
126 | 126 |
127 class UserScriptListenerTest : public ExtensionServiceTestBase { | 127 class UserScriptListenerTest : public ExtensionServiceTestBase { |
128 public: | 128 public: |
129 UserScriptListenerTest() { | 129 UserScriptListenerTest() { |
130 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( | 130 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( |
131 "http", "google.com", | 131 "http", "google.com", |
132 scoped_ptr<net::URLRequestInterceptor>( | 132 scoped_ptr<net::URLRequestInterceptor>( |
133 new SimpleTestJobURLRequestInterceptor())); | 133 new SimpleTestJobURLRequestInterceptor())); |
134 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( | 134 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( |
135 "http", "example.com", | 135 "http", "example.com", |
136 scoped_ptr<net::URLRequestInterceptor>( | 136 scoped_ptr<net::URLRequestInterceptor>( |
137 new SimpleTestJobURLRequestInterceptor())); | 137 new SimpleTestJobURLRequestInterceptor())); |
138 } | 138 } |
139 | 139 |
140 virtual ~UserScriptListenerTest() { | 140 virtual ~UserScriptListenerTest() { |
141 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler("http", | 141 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler("http", |
142 "google.com"); | 142 "google.com"); |
143 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler("http", | 143 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler("http", |
144 "example.com"); | 144 "example.com"); |
145 } | 145 } |
146 | 146 |
147 virtual void SetUp() OVERRIDE { | 147 virtual void SetUp() override { |
148 ExtensionServiceTestBase::SetUp(); | 148 ExtensionServiceTestBase::SetUp(); |
149 | 149 |
150 InitializeEmptyExtensionService(); | 150 InitializeEmptyExtensionService(); |
151 service_->Init(); | 151 service_->Init(); |
152 base::MessageLoop::current()->RunUntilIdle(); | 152 base::MessageLoop::current()->RunUntilIdle(); |
153 | 153 |
154 listener_ = new UserScriptListener(); | 154 listener_ = new UserScriptListener(); |
155 } | 155 } |
156 | 156 |
157 virtual void TearDown() OVERRIDE { | 157 virtual void TearDown() override { |
158 listener_ = NULL; | 158 listener_ = NULL; |
159 base::MessageLoop::current()->RunUntilIdle(); | 159 base::MessageLoop::current()->RunUntilIdle(); |
160 ExtensionServiceTestBase::TearDown(); | 160 ExtensionServiceTestBase::TearDown(); |
161 } | 161 } |
162 | 162 |
163 protected: | 163 protected: |
164 scoped_ptr<net::URLRequest> StartTestRequest( | 164 scoped_ptr<net::URLRequest> StartTestRequest( |
165 net::URLRequest::Delegate* delegate, | 165 net::URLRequest::Delegate* delegate, |
166 const std::string& url_string, | 166 const std::string& url_string, |
167 net::TestURLRequestContext* context) { | 167 net::TestURLRequestContext* context) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 base::MessageLoop::current()->RunUntilIdle(); | 351 base::MessageLoop::current()->RunUntilIdle(); |
352 | 352 |
353 bool defer = false; | 353 bool defer = false; |
354 throttle->WillStartRequest(&defer); | 354 throttle->WillStartRequest(&defer); |
355 ASSERT_FALSE(defer); | 355 ASSERT_FALSE(defer); |
356 } | 356 } |
357 | 357 |
358 } // namespace | 358 } // namespace |
359 | 359 |
360 } // namespace extensions | 360 } // namespace extensions |
OLD | NEW |