Commit 78892548 authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

Fix crash with InteresteFeedV2

Bug: 1070141
Change-Id: If483f5c4c85dcd5ff7a20d75a87ea7d6be16d8a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2145250Reviewed-by: default avatarJian Li <jianli@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758571}
parent bd216c63
...@@ -298,8 +298,10 @@ public class FeedSurfaceCoordinator { ...@@ -298,8 +298,10 @@ public class FeedSurfaceCoordinator {
// Native should already have been loaded because of FeedSurfaceMediator. // Native should already have been loaded because of FeedSurfaceMediator.
if (ChromeFeatureList.isEnabled(ChromeFeatureList.INTEREST_FEED_V2)) { if (ChromeFeatureList.isEnabled(ChromeFeatureList.INTEREST_FEED_V2)) {
// TODO(iwells): Temporary. This should probably move to FeedSurfaceMediator. // TODO(jianli): Temporary: simulate opening the feed V2 surface. This should probably
// move to FeedSurfaceMediator.
mFeedStreamSurface = new FeedStreamSurface(mActivity); mFeedStreamSurface = new FeedStreamSurface(mActivity);
mFeedStreamSurface.surfaceOpened();
} }
} }
......
...@@ -40,8 +40,6 @@ FeedStreamSurface::FeedStreamSurface(const JavaRef<jobject>& j_this) ...@@ -40,8 +40,6 @@ FeedStreamSurface::FeedStreamSurface(const JavaRef<jobject>& j_this)
feed_stream_api_ = feed_stream_api_ =
FeedServiceFactory::GetForBrowserContext(profile)->GetStream(); FeedServiceFactory::GetForBrowserContext(profile)->GetStream();
if (feed_stream_api_)
feed_stream_api_->AttachSurface(this);
} }
FeedStreamSurface::~FeedStreamSurface() { FeedStreamSurface::~FeedStreamSurface() {
...@@ -86,10 +84,20 @@ void FeedStreamSurface::DiscardEphemeralChange(JNIEnv* env, ...@@ -86,10 +84,20 @@ void FeedStreamSurface::DiscardEphemeralChange(JNIEnv* env,
int change_id) {} int change_id) {}
void FeedStreamSurface::SurfaceOpened(JNIEnv* env, void FeedStreamSurface::SurfaceOpened(JNIEnv* env,
const JavaParamRef<jobject>& obj) {} const JavaParamRef<jobject>& obj) {
if (feed_stream_api_ && !attached_) {
attached_ = true;
feed_stream_api_->AttachSurface(this);
}
}
void FeedStreamSurface::SurfaceClosed(JNIEnv* env, void FeedStreamSurface::SurfaceClosed(JNIEnv* env,
const JavaParamRef<jobject>& obj) {} const JavaParamRef<jobject>& obj) {
if (feed_stream_api_ && attached_) {
attached_ = false;
feed_stream_api_->DetachSurface(this);
}
}
void FeedStreamSurface::ReportOpenAction(JNIEnv* env, void FeedStreamSurface::ReportOpenAction(JNIEnv* env,
const JavaParamRef<jobject>& obj) { const JavaParamRef<jobject>& obj) {
......
...@@ -98,6 +98,7 @@ class FeedStreamSurface : public FeedStreamApi::SurfaceInterface { ...@@ -98,6 +98,7 @@ class FeedStreamSurface : public FeedStreamApi::SurfaceInterface {
private: private:
base::android::ScopedJavaGlobalRef<jobject> java_ref_; base::android::ScopedJavaGlobalRef<jobject> java_ref_;
FeedStreamApi* feed_stream_api_; FeedStreamApi* feed_stream_api_;
bool attached_ = false;
}; };
} // namespace feed } // namespace feed
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment