Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(630)

Side by Side Diff: components/cronet/ios/Cronet.mm

Issue 2510463002: [Cronet] Retain block passed to setRequestFilterBlock on iOS. (Closed)
Patch Set: Address comment. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/cronet/ios/test/cronet_http_test.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | components/cronet/ios/test/cronet_http_test.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698