| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "components/cronet/ios/Cronet.h" | 5 #import "components/cronet/ios/Cronet.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return result; | 61 return result; |
| 62 } | 62 } |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // net::HTTPProtocolHandlerDelegate for Cronet. | 65 // net::HTTPProtocolHandlerDelegate for Cronet. |
| 66 class CronetHttpProtocolHandlerDelegate | 66 class CronetHttpProtocolHandlerDelegate |
| 67 : public net::HTTPProtocolHandlerDelegate { | 67 : public net::HTTPProtocolHandlerDelegate { |
| 68 public: | 68 public: |
| 69 CronetHttpProtocolHandlerDelegate(net::URLRequestContextGetter* getter, | 69 CronetHttpProtocolHandlerDelegate(net::URLRequestContextGetter* getter, |
| 70 RequestFilterBlock filter) | 70 RequestFilterBlock filter) |
| 71 : getter_(getter), filter_(filter, base::scoped_policy::RETAIN) {} | 71 : getter_(getter), filter_(filter) {} |
| 72 | 72 |
| 73 void SetRequestFilterBlock(RequestFilterBlock filter) { | 73 void SetRequestFilterBlock(RequestFilterBlock filter) { |
| 74 base::AutoLock auto_lock(lock_); | 74 base::AutoLock auto_lock(lock_); |
| 75 filter_.reset(filter, base::scoped_policy::RETAIN); | 75 filter_.reset(filter); |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 // net::HTTPProtocolHandlerDelegate implementation: | 79 // net::HTTPProtocolHandlerDelegate implementation: |
| 80 bool CanHandleRequest(NSURLRequest* request) override { | 80 bool CanHandleRequest(NSURLRequest* request) override { |
| 81 base::AutoLock auto_lock(lock_); | 81 base::AutoLock auto_lock(lock_); |
| 82 if (!IsRequestSupported(request)) | 82 if (!IsRequestSupported(request)) |
| 83 return false; | 83 return false; |
| 84 if (filter_) { | 84 if (filter_) { |
| 85 RequestFilterBlock block = filter_.get(); | 85 RequestFilterBlock block = filter_.get(); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 base::SysNSStringToUTF8(hostResolverRulesForTesting)); | 329 base::SysNSStringToUTF8(hostResolverRulesForTesting)); |
| 330 } | 330 } |
| 331 | 331 |
| 332 // This is a non-public dummy method that prevents the linker from stripping out | 332 // This is a non-public dummy method that prevents the linker from stripping out |
| 333 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. | 333 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. |
| 334 + (void)preventStrippingCronetBidirectionalStream { | 334 + (void)preventStrippingCronetBidirectionalStream { |
| 335 bidirectional_stream_create(NULL, 0, 0); | 335 bidirectional_stream_create(NULL, 0, 0); |
| 336 } | 336 } |
| 337 | 337 |
| 338 @end | 338 @end |
| OLD | NEW |