| OLD | NEW | 
|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/net/crn_http_protocol_handler_proxy_with_client_thread.h" | 5 #import "ios/net/crn_http_protocol_handler_proxy_with_client_thread.h" | 
| 6 | 6 | 
| 7 #include "base/logging.h" | 7 #include "base/logging.h" | 
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" | 
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" | 
| 10 #import "ios/net/protocol_handler_util.h" | 10 #import "ios/net/protocol_handler_util.h" | 
| 11 #include "net/base/auth.h" | 11 #include "net/base/auth.h" | 
| 12 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" | 
| 13 | 13 | 
| 14 // When the protocol is invalidated, no synchronization (lock) is needed: | 14 // When the protocol is invalidated, no synchronization (lock) is needed: | 
| 15 // - The actual calls to the protocol and its invalidation are all done on | 15 // - The actual calls to the protocol and its invalidation are all done on | 
| 16 //   clientThread_ and thus are serialized. | 16 //   clientThread_ and thus are serialized. | 
| 17 // - When a proxy method is called, the protocol is compared to nil. There may | 17 // - When a proxy method is called, the protocol is compared to nil. There may | 
| 18 //   be a conflict at this point, in the case the protocol is being invalidated | 18 //   be a conflict at this point, in the case the protocol is being invalidated | 
| 19 //   during this comparison. However, in such a case, the actual value of the | 19 //   during this comparison. However, in such a case, the actual value of the | 
| 20 //   pointer does not matter: an invalid pointer will behave as a valid one and | 20 //   pointer does not matter: an invalid pointer will behave as a valid one and | 
| 21 //   post a task on the clientThread_, and that task will be handled correctly, | 21 //   post a task on the clientThread_, and that task will be handled correctly, | 
| 22 //   as described by the item above. | 22 //   as described by the item above. | 
| 23 | 23 | 
| 24 @interface CRNHTTPProtocolHandlerProxyWithClientThread () { | 24 @interface CRNHTTPProtocolHandlerProxyWithClientThread () { | 
| 25   __weak NSURLProtocol* _protocol; | 25   NSURLProtocol* _protocol;  // weak | 
| 26   // Thread used to call the client back. | 26   // Thread used to call the client back. | 
| 27   // This thread does not have a base::MessageLoop, and thus does not work with | 27   // This thread does not have a base::MessageLoop, and thus does not work with | 
| 28   // the usual task posting functions. | 28   // the usual task posting functions. | 
| 29   __weak NSThread* _clientThread; | 29   NSThread* _clientThread;  // weak | 
| 30   // The run loop modes to use when posting tasks to |clientThread_|. | 30   // The run loop modes to use when posting tasks to |clientThread_|. | 
| 31   base::scoped_nsobject<NSArray> _runLoopModes; | 31   base::scoped_nsobject<NSArray> _runLoopModes; | 
| 32   // The request URL. | 32   // The request URL. | 
| 33   base::scoped_nsobject<NSString> _url; | 33   base::scoped_nsobject<NSString> _url; | 
| 34   // The creation time of the request. | 34   // The creation time of the request. | 
| 35   base::Time _creationTime; | 35   base::Time _creationTime; | 
| 36   // |requestComplete_| is used in debug to check that the client is not called | 36   // |requestComplete_| is used in debug to check that the client is not called | 
| 37   // after completion. | 37   // after completion. | 
| 38   BOOL _requestComplete; | 38   BOOL _requestComplete; | 
| 39   BOOL _paused; | 39   BOOL _paused; | 
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 255 } | 255 } | 
| 256 | 256 | 
| 257 - (void)resume { | 257 - (void)resume { | 
| 258   DCHECK([NSThread currentThread] == _clientThread); | 258   DCHECK([NSThread currentThread] == _clientThread); | 
| 259   DCHECK(!_requestComplete || !_protocol); | 259   DCHECK(!_requestComplete || !_protocol); | 
| 260   _paused = NO; | 260   _paused = NO; | 
| 261   [self runInvocationQueueOnClientThread]; | 261   [self runInvocationQueueOnClientThread]; | 
| 262 } | 262 } | 
| 263 | 263 | 
| 264 @end | 264 @end | 
| OLD | NEW | 
|---|