Chromium Code Reviews| Index: ios/chrome/browser/voice/text_to_speech_listener.mm |
| diff --git a/ios/chrome/browser/voice/text_to_speech_listener.mm b/ios/chrome/browser/voice/text_to_speech_listener.mm |
| index f9a8468dec0486c4bb5f40853d5621110704505c..a387115f84949bb332501a10cdb8d6d442d7263b 100644 |
| --- a/ios/chrome/browser/voice/text_to_speech_listener.mm |
| +++ b/ios/chrome/browser/voice/text_to_speech_listener.mm |
| @@ -6,7 +6,6 @@ |
| #include <memory> |
| -#include "base/ios/weak_nsobject.h" |
| #include "base/logging.h" |
| #include "base/mac/scoped_nsobject.h" |
| #include "ios/web/public/navigation_manager.h" |
| @@ -16,6 +15,10 @@ |
| #import "ios/chrome/browser/voice/voice_search_url_rewriter.h" |
| #include "url/gurl.h" |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| #pragma mark - TextToSpeechListener Private Interface |
| class TextToSpeechWebStateObserver; |
| @@ -23,7 +26,7 @@ class TextToSpeechWebStateObserver; |
| @interface TextToSpeechListener () |
| // The TextToSpeechListenerDelegate passed on initialization. |
| -@property(nonatomic, readonly) id<TextToSpeechListenerDelegate> delegate; |
| +@property(weak, nonatomic, readonly) id<TextToSpeechListenerDelegate> delegate; |
| @end |
| @@ -63,7 +66,7 @@ void TextToSpeechWebStateObserver::PageLoaded( |
| BOOL shouldParse = [listener_.delegate shouldTextToSpeechListener:listener_ |
| parseDataFromURL:url]; |
| if (shouldParse) { |
| - base::WeakNSObject<TextToSpeechListener> weakListener(listener_); |
| + __weak TextToSpeechListener* weakListener = listener_; |
| ExtractVoiceSearchAudioDataFromWebState(web_state(), ^(NSData* audioData) { |
| [[weakListener delegate] textToSpeechListener:weakListener |
| didReceiveResult:audioData]; |
| @@ -78,13 +81,11 @@ void TextToSpeechWebStateObserver::WebStateDestroyed() { |
| } |
| #pragma mark - TextToSpeechListener |
| - |
| @implementation TextToSpeechListener { |
| - // Backing object for property of the same name. |
| - base::WeakNSProtocol<id<TextToSpeechListenerDelegate>> _delegate; |
| // The TextToSpeechWebStateObserver that listens for Text-To-Speech data. |
| std::unique_ptr<TextToSpeechWebStateObserver> _webStateObserver; |
| } |
| +@synthesize delegate = _delegate; |
| - (instancetype)initWithWebState:(web::WebState*)webState |
| delegate:(id<TextToSpeechListenerDelegate>)delegate { |
| @@ -92,7 +93,7 @@ void TextToSpeechWebStateObserver::WebStateDestroyed() { |
| DCHECK(webState); |
| DCHECK(delegate); |
| _webStateObserver.reset(new TextToSpeechWebStateObserver(webState, self)); |
|
sdefresne
2016/11/22 14:35:39
nit: can you change this to base::MakeUnique<>?
stkhapugin
2016/11/22 14:53:43
Done.
|
| - _delegate.reset(delegate); |
| + _delegate = delegate; |
| } |
| return self; |
| } |
| @@ -103,8 +104,4 @@ void TextToSpeechWebStateObserver::WebStateDestroyed() { |
| return _webStateObserver->web_state(); |
| } |
| -- (id<TextToSpeechListenerDelegate>)delegate { |
| - return _delegate.get(); |
| -} |
| - |
| @end |