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

Unified Diff: ios/chrome/browser/voice/text_to_speech_listener.mm

Issue 2505933009: [ObjC ARC] Converts ios/chrome/browser/voice:tts to ARC.Automatically generated ARCMigrate commit… (Closed)
Patch Set: make_unique 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/voice/BUILD.gn ('k') | ios/chrome/browser/voice/text_to_speech_parser.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..29527e409cec16a64834b6863081b5cee5b94075 100644
--- a/ios/chrome/browser/voice/text_to_speech_listener.mm
+++ b/ios/chrome/browser/voice/text_to_speech_listener.mm
@@ -6,9 +6,9 @@
#include <memory>
-#include "base/ios/weak_nsobject.h"
#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
+#include "base/memory/ptr_util.h"
#include "ios/web/public/navigation_manager.h"
#include "ios/web/public/web_state/web_state.h"
#include "ios/web/public/web_state/web_state_observer.h"
@@ -16,6 +16,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 +27,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 +67,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,21 +82,20 @@ 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 {
if ((self = [super init])) {
DCHECK(webState);
DCHECK(delegate);
- _webStateObserver.reset(new TextToSpeechWebStateObserver(webState, self));
- _delegate.reset(delegate);
+ _webStateObserver =
+ base::MakeUnique<TextToSpeechWebStateObserver>(webState, self);
+ _delegate = delegate;
}
return self;
}
@@ -103,8 +106,4 @@ void TextToSpeechWebStateObserver::WebStateDestroyed() {
return _webStateObserver->web_state();
}
-- (id<TextToSpeechListenerDelegate>)delegate {
- return _delegate.get();
-}
-
@end
« no previous file with comments | « ios/chrome/browser/voice/BUILD.gn ('k') | ios/chrome/browser/voice/text_to_speech_parser.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698