| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // net::HTTPProtocolHandlerDelegate for Cronet. | 60 // net::HTTPProtocolHandlerDelegate for Cronet. |
| 61 class CronetHttpProtocolHandlerDelegate | 61 class CronetHttpProtocolHandlerDelegate |
| 62 : public net::HTTPProtocolHandlerDelegate { | 62 : public net::HTTPProtocolHandlerDelegate { |
| 63 public: | 63 public: |
| 64 CronetHttpProtocolHandlerDelegate(net::URLRequestContextGetter* getter, | 64 CronetHttpProtocolHandlerDelegate(net::URLRequestContextGetter* getter, |
| 65 RequestFilterBlock filter) | 65 RequestFilterBlock filter) |
| 66 : getter_(getter), filter_(filter, base::scoped_policy::RETAIN) {} | 66 : getter_(getter), filter_(filter, base::scoped_policy::RETAIN) {} |
| 67 | 67 |
| 68 void SetRequestFilterBlock(RequestFilterBlock filter) { | 68 void SetRequestFilterBlock(RequestFilterBlock filter) { |
| 69 base::AutoLock auto_lock(lock_); | 69 base::AutoLock auto_lock(lock_); |
| 70 filter_.reset(filter); | 70 filter_.reset(filter, base::scoped_policy::RETAIN); |
| 71 } | 71 } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 // net::HTTPProtocolHandlerDelegate implementation: | 74 // net::HTTPProtocolHandlerDelegate implementation: |
| 75 bool CanHandleRequest(NSURLRequest* request) override { | 75 bool CanHandleRequest(NSURLRequest* request) override { |
| 76 base::AutoLock auto_lock(lock_); | 76 base::AutoLock auto_lock(lock_); |
| 77 if (filter_) { | 77 if (filter_) { |
| 78 RequestFilterBlock block = filter_.get(); | 78 RequestFilterBlock block = filter_.get(); |
| 79 return block(request); | 79 return block(request); |
| 80 } | 80 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 base::SysNSStringToUTF8(hostResolverRulesForTesting)); | 279 base::SysNSStringToUTF8(hostResolverRulesForTesting)); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // This is a non-public dummy method that prevents the linker from stripping out | 282 // This is a non-public dummy method that prevents the linker from stripping out |
| 283 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. | 283 // the otherwise non-referenced methods from 'bidirectional_stream.cc'. |
| 284 + (void)preventStrippingCronetBidirectionalStream { | 284 + (void)preventStrippingCronetBidirectionalStream { |
| 285 bidirectional_stream_create(NULL, 0, 0); | 285 bidirectional_stream_create(NULL, 0, 0); |
| 286 } | 286 } |
| 287 | 287 |
| 288 @end | 288 @end |
| OLD | NEW |