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

Unified Diff: ios/chrome/browser/reading_list/reading_list_web_state_observer.mm

Issue 2513403003: Explicitely pass ownership of ReadingListWebStateObserverUserDataWrapper (Closed)
Patch Set: Addressed 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/reading_list/reading_list_web_state_observer.mm
diff --git a/ios/chrome/browser/reading_list/reading_list_web_state_observer.mm b/ios/chrome/browser/reading_list/reading_list_web_state_observer.mm
index c12abae78171eafa251ea9e0b5a0ec03647c861e..7c8a9fc926206fb6bcddaff038a96c4bc6727ecc 100644
--- a/ios/chrome/browser/reading_list/reading_list_web_state_observer.mm
+++ b/ios/chrome/browser/reading_list/reading_list_web_state_observer.mm
@@ -6,6 +6,7 @@
#import <Foundation/Foundation.h>
+#include "base/memory/ptr_util.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/reading_list/reading_list_model.h"
#include "ios/chrome/browser/reading_list/reading_list_model_factory.h"
@@ -34,8 +35,11 @@ class ReadingListWebStateObserverUserDataWrapper
static_cast<ReadingListWebStateObserverUserDataWrapper*>(
web_state->GetUserData(kObserverKey));
if (!wrapper) {
- wrapper = new ReadingListWebStateObserverUserDataWrapper(
- web_state, reading_list_model);
+ auto newDataWrapper =
sdefresne 2016/11/22 10:01:31 style: this is a C++ class, so the variable should
+ base::MakeUnique<ReadingListWebStateObserverUserDataWrapper>(
+ web_state, reading_list_model);
+ wrapper = newDataWrapper.get();
+ web_state->SetUserData(kObserverKey, newDataWrapper.release());
}
return wrapper;
}
@@ -45,7 +49,6 @@ class ReadingListWebStateObserverUserDataWrapper
ReadingListModel* reading_list_model)
: observer_(web_state, reading_list_model) {
DCHECK(web_state);
- web_state->SetUserData(kObserverKey, this);
}
ReadingListWebStateObserver* observer() { return &observer_; }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698